Repository navigation
fix: close the defects a fifth audit found - #6
Merged
Merged
Conversation
A client hanging up was classified as a provider failure, with the same breaker weight and cooldown as an unreachable host, so five cancelled requests from one impatient tab retired a healthy provider. A 404 was treated the same way, retiring a fleet that had merely been pointed at a model the provider no longer serves. Both now fail over without charging the provider. The SSRF guard recognised only IPv4-mapped addresses. NAT64, the prefix an IPv6-only pod uses to reach an IPv4 literal, carries 127.0.0.1 and 169.254.169.254 unchanged and was judged as ordinary IPv6. The login lockout counted inside a hard-coded hour while the setting allows any duration, so a two-hour lockout forgot its own evidence halfway through; the count was also capped by `LIMIT 50`, which a threshold above fifty could never reach. The dashboard authenticated in its handlers, after the body had been parsed, so an unauthenticated 50 MiB POST was buffered before refusal - the hole invariant 4 closes for /v1. It now runs in preParsing, which also lets the per-address limiter count the refusal; at onRequest the limiter's hook had not run yet and a 401 was free. Changing the dashboard password signed the operator out: the kept session still carried the old token version, which the guard compares. The session read route skipped that comparison entirely. Elsewhere: a queue-full refusal was counted as an error and its 30 s wait as latency; a JSON body was masked by value shape, hiding `model` and `error_code`; the SSE scanner never resynchronised after an over-long line and lost every later frame; a mapped TRUSTED_PROXIES entry with an IPv4-sized prefix matched every address; an abandoned CSV export hung holding the SQLite cursor; a log search let the term act as a LIKE pattern. nextActiveAt had a tested implementation and no caller, so the Providers tab could not say when an out-of-schedule provider returns.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A fresh audit of the engine, the gateway, the dashboard and the storage layer.
What was wrong
cancelled requests from one impatient tab retired a healthy provider.
404did the same,retiring a fleet merely pointed at a model the provider no longer serves.
64:ff9b::/96,64:ff9b:1::/48), IPv4-compatible and 6to4 all carry a real IPv4 host — on an IPv6-only pod,http://[64:ff9b::7f00:1]/is a working request to loopback.LOGIN_LOCKOUT_MSallows any duration, and the count was capped byLIMIT 50, which athreshold above fifty could never reach.
/api/*authenticated after the body was parsed, so an unauthenticated 50 MiBPOST /api/providerswas buffered before refusal — the hole invariant 4 closes for/v1.the old
token_version, and/api/auth/sessionskipped the comparison entirely.503 queue_fullcounted as an error and its 30 s wait as latency, contradictinginvariant 8 on both charts read for provider health and speed.
LOG_BODIES=1logged{"model":"[REDACTED]","error_code":"[REDACTED]"}.[DONE]and everyin-band error behind it.
TRUSTED_PROXIEStypo —::ffff:10.0.0.0/8— matched every address, turning the onesetting whose purpose is to narrow trust into a fail-open.
LIKEpattern;nextActiveAthad a testedimplementation and no caller.
Verification
pnpm run check,pnpm run typecheck,pnpm test:unit(400 checks),SMOKE_SLOW=1 pnpm run test:smoke(349 checks) andpnpm run buildall pass, and the routerboots with
/health200,/v1/modelspublic,/api/*401 unauthenticated and a clean SIGTERM.New tests cover the abort and 404 classifications,
Retry-After: 0, the three additional SSRFprefixes, the scanner resync, a lockout longer than an hour, a threshold above fifty, JSON
masking by name,
LIKEmetacharacters, the queue-full metric, the reissued session version, themapped-prefix refusal, and a refusal that arrives before the body is read.