Repository navigation
feat(egress): stream responses with credential redaction - #345
Merged
Merged
Conversation
The gateway reads every response body whole before the workload gets any of it, and refuses one over 16 MiB (#171). So an npm package over 16 MiB, a large Git pack, or a long download cannot pass through a box. Only two steps need the whole body: the leak-back scrub, for a target with a bound credential, and catalog staging, for a configured MCP server. A response that neither applies to, and that does not answer a HEAD request, now streams. The gateway checks its head as before, claims the ResponseRelease before the first body byte, and hands the body to the workload as hyper reads it. The upstream is read only as fast as the workload reads, so memory no longer grows with the body. - ResponseRelease.body_bytes becomes Option<usize>: the bytes in hand for a buffered response, the declared Content-Length for a streamed one, and None for a chunked one. The policy adapter and telemetry read nothing from it, so no decision changes. The release outcome reports the bytes the workload took, and a body that fails partway is reported as Partial. - The 300 s upstream deadline covers the wait for a streamed response's head. After that, each gap between body pieces may last 300 s. - A credentialed target or an MCP server keeps the buffered path and the 16 MiB limit. Request bodies stay buffered. Two behaviours change for a streamed response: a body the upstream cuts short reaches the workload up to the cut, and a chunked body stays chunked. Tests for the old behaviour now run against a credentialed target, which is still buffered. Prototype for the design in #171. The design is not reviewed yet.
Deliver response bodies progressively with bounded credential redaction. Keep tools/list capture for schema staging and preserve the absolute upstream deadline. Remove the unused response-release body length and document the streaming behavior and remaining limits. Integrate current main while preserving the existing PR history. Co-authored-by: Patrick Gray <[email protected]>
Co-authored-by: Patrick Gray <[email protected]>
Co-authored-by: Patrick Gray <[email protected]>
Co-authored-by: Patrick Gray <[email protected]>
|
Assessment: Approve I reviewed Checks that held
The added disconnect rows in the real-policy e2e test guard the precondition case directly. |
abhisheksp
approved these changes
Nov 6, 2026
8 tasks done
3 tasks done
7 tasks done
leo237
pushed a commit
to leo237/box
that referenced
this pull request
Nov 10, 2026
… refuse dead/unsafe re-routes Addresses the human review of the re-routing CR (code only; not every comment). - redact box-owned backend token in streamed responses. `Vault::response_redactor` (the strands-agents#345 streaming scrubber) read only `opaque`, so a backend echoing `Authorization` returned the backend token to the workload. It now covers `box_owned` as `redact_leaks` does. Pinned by the e2e `a_backend_echo_of_its_token_is_redacted`. - stop double-encoding the SigV4 canonical query. The query arrives already percent-encoded, and `canonical_query` re-encoded it (`%3A` -> `%253A`), so an encoded query (a GitHub search re-route) signed wrong and AWS answered 403. It now decodes each key/value before encoding once. Pinned by `canonical_query_encodes_each_parameter_exactly_once`. - refuse a destination `secret` beside an `http` backend at load. Its strip route matched the original destination and tripped the plaintext-credential floor, 403ing every request. Pinned by `a_destination_secret_beside_an_http_backend_is_refused`. - refuse an encoded path separator (`%2F`, `%5C`) in a re-routed path under a backend prefix, which the backend could decode to escape the prefix. Pinned by `a_backend_reroute_refuses_an_encoded_separator_in_the_path`.
leo237
pushed a commit
to leo237/box
that referenced
this pull request
Nov 11, 2026
… refuse dead/unsafe re-routes Addresses the human review of the re-routing CR (code only; not every comment). - redact box-owned backend token in streamed responses. `Vault::response_redactor` (the strands-agents#345 streaming scrubber) read only `opaque`, so a backend echoing `Authorization` returned the backend token to the workload. It now covers `box_owned` as `redact_leaks` does. Pinned by the e2e `a_backend_echo_of_its_token_is_redacted`. - stop double-encoding the SigV4 canonical query. The query arrives already percent-encoded, and `canonical_query` re-encoded it (`%3A` -> `%253A`), so an encoded query (a GitHub search re-route) signed wrong and AWS answered 403. It now decodes each key/value before encoding once. Pinned by `canonical_query_encodes_each_parameter_exactly_once`. - refuse a destination `secret` beside an `http` backend at load. Its strip route matched the original destination and tripped the plaintext-credential floor, 403ing every request. Pinned by `a_destination_secret_beside_an_http_backend_is_refused`. - refuse an encoded path separator (`%2F`, `%5C`) in a re-routed path under a backend prefix, which the backend could decode to escape the prefix. Pinned by `a_backend_reroute_refuses_an_encoded_separator_in_the_path`.
leo237
pushed a commit
to leo237/box
that referenced
this pull request
Nov 11, 2026
… refuse dead/unsafe re-routes Addresses the human review of the re-routing CR (code only; not every comment). - redact box-owned backend token in streamed responses. `Vault::response_redactor` (the strands-agents#345 streaming scrubber) read only `opaque`, so a backend echoing `Authorization` returned the backend token to the workload. It now covers `box_owned` as `redact_leaks` does. Pinned by the e2e `a_backend_echo_of_its_token_is_redacted`. - stop double-encoding the SigV4 canonical query. The query arrives already percent-encoded, and `canonical_query` re-encoded it (`%3A` -> `%253A`), so an encoded query (a GitHub search re-route) signed wrong and AWS answered 403. It now decodes each key/value before encoding once. Pinned by `canonical_query_encodes_each_parameter_exactly_once`. - refuse a destination `secret` beside an `http` backend at load. Its strip route matched the original destination and tripped the plaintext-credential floor, 403ing every request. Pinned by `a_destination_secret_beside_an_http_backend_is_refused`. - refuse an encoded path separator (`%2F`, `%5C`) in a re-routed path under a backend prefix, which the backend could decode to escape the prefix. Pinned by `a_backend_reroute_refuses_an_encoded_separator_in_the_path`.
6 of 8 tasks
siwachabhi
pushed a commit
that referenced
this pull request
Nov 17, 2026
4 of 6 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
The gateway buffers complete responses and rejects bodies above 16 MiB. This delays interactive output until a response finishes and breaks large package downloads.
Stream HTTP responses with backpressure, including credential-bound responses and MCP replies. Credential redaction runs before delivery and retains a credential-sized tail between chunks, so partial matches do not change release boundaries. Small events can wait for more data or clean completion. MCP
tools/listkeeps bounded capture so schema staging finishes before release.HTTP and HTTP MCP request outcomes remain pending until the upstream response completes, fails, or reaches its deadline. If downstream delivery ends early, the connection retains the upstream reader and drains it under the existing deadline and connection cap. A workload disconnect cannot advance a temporal prerequisite. Downstream delivery retains its own partial or failed outcome. Existing partial and uncertain outcome semantics remain; a
::responsedoes not prove tool success.The existing 300-second upstream deadline remains absolute, including when downstream backpressure stalls an incomplete upstream response. Request bodies and
tools/listcapture retain their 16 MiB limits. Timeout configuration and upload streaming are separate follow-ups.The Rust interface adds the opaque
ResponseRedactorandVault::response_redactor, and removes the unusedEffectAttempt::ResponseRelease.body_bytesfield. Consumers constructing that attempt must omit the field. No configuration or stored-record format changes.Related Issues
Closes #171. Upload limits in #172 remain.
Type of Change
Bug fix; breaking Rust interface change; documentation update.
Testing
/usr/bin/falsewith a launch-constraint violation. The same test fails on unchanged main (c8856a1), and the copied executable fails outside Box. A separate fixture-only prototype makes all 11 tool-grammar tests pass; that fix is not included here.Linux validation of the latest commit is left to PR CI; the local cross-check lacks
aarch64-linux-gnu-gcc.Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.