Conversation
…ntry Two additions at the proxy's request boundary: - Inbound bodies are buffered once so each failover attempt can replay them, with no size limit — any loopback caller could make the proxy read an unbounded body into memory before routing. Cap the buffer at 32 MiB and refuse anything larger with 413 before resolving a candidate or reserving scheduler capacity. A mid-body read error is refused the same way rather than forwarded truncated, and the 413 uses the same JSON error shape as every other proxy rejection. Long-context prompts fit well below the cap. - The loopback listener is reachable from a browser page on any origin, and a simple cross-origin POST needs no preflight, so header policy alone cannot stop an unlisted page from driving the local engines. Add a deny-by-default allowlist gate ahead of forwarding: a request carrying an Origin is admitted only from an exact origin listed in NVPAIR_PROXY_ALLOWED_ORIGINS, otherwise it is refused with 403 origin-not-allowed. Callers that send no Origin (Electron main, CLI, probes) are unaffected. This sits above the existing per-engine intersection policy, which still decides what an admitted origin may read. Signed-off-by: woodsonl <65194841+woodsonl@users.noreply.github.com>
7 tasks
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.
Description
Request bodies are bounded. Inbound bodies are buffered once so each
failover attempt can replay them, with no size limit, so any loopback caller
could make the proxy read an unbounded body into memory before routing. The
buffer is now capped at 32 MiB and anything larger is refused with
413beforea candidate is resolved or scheduler capacity is reserved. Long-context prompts
fit well below the cap.
Browser origins are gated at entry. The loopback listener is reachable from
a browser page on any origin, and a simple cross-origin POST needs no
preflight, so header policy alone cannot stop an unlisted page from driving the
local engines. A deny-by-default allowlist now runs ahead of forwarding. A
request that carries an
Originis admitted only from an exact origin listedin
NVPAIR_PROXY_ALLOWED_ORIGINS; anything else is refused with403origin-not-allowed. Callers that send noOrigin(the Electron main process,CLI tools, health probes) are unaffected. This sits above the existing
per-engine intersection policy, which still decides what an admitted origin may
read.
Release intent
Changelog title
Proxy caps request bodies and gates browser origins
Changelog body
The local proxy refuses request bodies larger than 32 MiB instead of buffering
them without limit. Browser callers are admitted only from origins the operator
lists in
NVPAIR_PROXY_ALLOWED_ORIGINS; a browser origin that is not listed isrefused before it reaches an engine, while non-browser callers are unaffected.
Bumps
Scope
Included: the body-size cap and 413 path, the allowlist gate and its
NVPAIR_PROXY_ALLOWED_ORIGINSconfiguration, the sharedcorsallowlisthelper, and tests for both.
Excluded: the per-engine CORS intersection policy is unchanged; the gate runs
before it and only admits or refuses.
Validation
go build ./...andgo test ./...inservices/sharedandservices/nvpair-proxyservices/nvpair-proxy/body_limit_test.gocovers the 413 path, andingress_test.gocovers the allowlist gate.Risk
Behavior change for browser clients: with
NVPAIR_PROXY_ALLOWED_ORIGINSunset(the default), a browser
Originis refused. Non-browser callers areunaffected, and the setting is comma-separated exact origins.
Checklist
git commit -s), certifying the Developer Certificate of Origin.services/versions.jsonis written by automation — do not edit it by hand.