Skip to content

fix(flow): withhold secrets and tokens in JSON bodies and headers from network capture - #1367

Merged
abrichr merged 2 commits into
mainfrom
fix/network-capture-redact-json
Oct 19, 2026
Merged

abrichr merged 2 commits into
mainfrom
fix/network-capture-redact-json

Conversation

@abrichr

@abrichr abrichr commented Oct 19, 2026

Copy link
Copy Markdown
Member

First of six fixes from an external review of #1269 (the API step). This is the security one. It is independent of the API-step stack and targets main.

Bug

network_capture.redact found secret and token names only in form fields and URL queries. As a result:

  • a JSON login body ({"user": {"password": ...}}) kept the password in network.jsonl;
  • a token that only a response carried (a login's access_token, a Set-Cookie value) was missed wherever later traffic echoed it.

Fix

  • Names are now read in JSON request and response bodies at any depth. In a JSON body, a password-like or token-like field is replaced field by field, whatever the length of its value. Every value found is then withheld wherever else it appears.
  • Set-Cookie values and Authorization credentials are kept in memory only, and withheld wherever a body, URL or script echoes them (<session:cookie>, <session:authorization>). Headers are still never written.
  • The name patterns now also cover session, api_key, jwt, bearer, authorization, passphrase and private_key, plus exactly pin, otp, sid and auth.
  • NETWORK_CAPTURE.md (the file contract) and API_TIER.md are updated.

Tests

tests/test_network_capture_redact_json.py (new) runs a synthetic JSON login through the real NetworkCapture path into network.jsonl:

  • no password, access token, refresh token, Set-Cookie value or bearer credential survives anywhere;
  • a 3-character JSON secret is withheld by its field name;
  • nested lists are read.

All three tests fail on main. The existing capture, proposal and actuator tests still pass (34 with the new ones).

Synthetic values only.

🤖 Generated with Claude Code

abrichr and others added 2 commits October 19, 2026 14:05
…m network capture

Review of #1269: redaction found secret and token names only in form fields
and URL queries, so a JSON login body ({"password": ...}) kept the password,
and a token that only a response carried (a login's access_token) was missed.

- Names are now found in JSON request and response bodies at any depth. A
  JSON body's password-like or token-like field is replaced field by field,
  whatever its length; every value found is then withheld wherever else it
  appears.
- Set-Cookie values and Authorization credentials are kept in memory and
  withheld wherever traffic echoes them (<session:cookie>,
  <session:authorization>).
- The name patterns cover session, api_key, jwt, bearer, authorization,
  passphrase, private_key, and exactly pin, otp, sid and auth.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gitleaks flagged two of the literals in the first commit; they are pinned
in .gitleaksignore by commit, file, rule and line, as other reviewed test
literals are, and are no longer literals.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@abrichr
abrichr merged commit 8bf3e39 into main Oct 19, 2026
40 checks passed
@abrichr
abrichr deleted the fix/network-capture-redact-json branch October 19, 2026 22:22
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