Skip to content

fix: harden redirects, trace redaction, and custom-policy limits - #869

Merged
ewhauser merged 7 commits into
mainfrom
claude/fix-policy-network-review-381361
Oct 19, 2026
Merged

ewhauser merged 7 commits into
mainfrom
claude/fix-policy-network-review-381361

Conversation

@ewhauser

Copy link
Copy Markdown
Owner

Fixes five verified findings from the security review in network/, policy/, internal/runtime/, and the top-level package.

User-visible behavior

  • Redirects (network): matches curl. A 301/302/303 rewrites any method other than GET/HEAD into a body-less GET (dropping Content-* headers); 307/308 keep method and body. Authorization, Proxy-Authorization, Cookie, and Cookie2 are only sent to hops on the initial request's origin (scheme + host + port, default ports normalized). Previously a 303 to another allowed origin leaked the bearer token and POST body.
  • Trace redaction (TraceRedacted): now strips URL userinfo (https://[REDACTED]@host/); handles attached -uuser:pass / -H…, short-flag groups ending in a value flag (-su user:pass, -sH …), and --proxy-user/-U; matches secret-looking header/query/form names broadly (contains token, secret, passw, auth, cookie, session, …, or a key/sig component, e.g. PRIVATE-TOKEN, X-Goog-Api-Key); redacts secret key=value pairs and JSON string members in -d/--data*/-F/--json bodies.
  • Limits for custom policies: a custom Policy whose Limits fields are zero used to disable every cap (including the stdout capture cap). Zero fields now inherit the runtime defaults; the new policy.Unlimited (-1) explicitly disables a single limit (custom policies and LimitOverrides), reported as 0 by Session.Limits(). The merge is reflection-based so new policy.Limits fields are picked up automatically, and a test asserts every field has a default.
  • Process group: the default virtual host reports process group 1 instead of the real unix.Getpgrp() (which bash -i printed on Linux without a tty). Only host.NewSystem() exposes the host value.
  • Spill truncation: new StdoutSpillTruncated / StderrSpillTruncated on gbash.ExecutionResult, the runtime result, and commands.ExecutionResult, set when a spill file is cut short at MaxSpillBytes.

SPEC updates

Small localized edits: redirect semantics (§12 network), default-limit inheritance and policy.Unlimited (§12), redaction coverage (§13), virtual host metadata, and spill truncation reporting.

Testing

  • Regression tests for each fix (two-httptest-server redirect tests, table-driven redactArgv tests plus an end-to-end trace test, custom-policy limit tests, process-group tests through the public API, spill truncation tests at buffer/runtime/public levels).
  • go test ./network/... ./internal/runtime/... . ./policy/... passes; make lint clean (0 issues).

@ewhauser
ewhauser enabled auto-merge (squash) October 19, 2026 17:53
@ewhauser
ewhauser merged commit 9d5463c into main Oct 19, 2026
17 checks passed
@ewhauser
ewhauser deleted the claude/fix-policy-network-review-381361 branch October 19, 2026 18:32
@ewhauser ewhauser mentioned this pull request Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant