Skip to content

fix(sanitizer): URL-userinfo redaction no longer swallows JSON across keys (abilityai/trinity#3769) - #3770

Merged
vybe merged 1 commit into
devfrom
feature/3769-url-userinfo-json
Oct 15, 2026
Merged

vybe merged 1 commit into
devfrom
feature/3769-url-userinfo-json

Conversation

@vybe

@vybe vybe commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • redact_url_userinfo matched :// up to the next @, excluding only /, @ and whitespace, so compact JSON pairing a URL with a later @-bearing value was swallowed across keys. The AAuth whoami reply {"iss":"https://agent.example","sub":"aauth:[email protected]"} reached the agent as {"iss":"https://***@agent.example"}.
  • The userinfo span now also stops at ", <, > and an escaped quote \". None of these can appear unencoded in a URL's userinfo, and they delimit JSON strings (nested ones too) and HTML attributes. A bare \ still matches, so CORP\user:pw@proxy stays redacted.
  • Same pattern in the backend and agent-server copies.

Changes

  • src/backend/utils/credential_sanitizer.py: the rule now reads ://(?:[^/@\s"\\<>]|\\(?!"))+@
  • docker/base-image/agent_server/utils/credential_sanitizer.py: same rule
  • tests/unit/test_3769_url_userinfo_json.py (new): runs both copies against one shared table, plus the AAuth path through a2a_client.sanitize_outbound_text

Security note

The only credential-bearing input that is no longer redacted is a password containing a raw ", <, > or \". A valid URL must percent-encode these, and the encoded forms still redact. A2A replies are also scrubbed for the exact credential before this rule runs. There is no ReDoS risk: the span cannot contain /, so a match can't run past the next ://. A hostile 400 KB input runs in about 3 ms.

Test Plan

  • New tests pass: cd tests && pytest unit/test_3769_url_userinfo_json.py -v (37 passed; 13 fail on the old regex)
  • Every unit test touching the sanitizer: 1555 passed, 7 skipped, 1 xfailed
  • Live: an agent calling whoami.aauth.dev through call_aauth_resource sees its full aauth:<agent>@<issuer-host> identity (not run: no stack available this session)

Follow-up, out of scope: utils/url_validation.py::scrub_url_credentials_in_text has the same over-match on compact JSON. It runs on skill-source and git paths, not A2A or AAuth.

Fixes #3769

🤖 Generated with Claude Code

…3769)

`redact_url_userinfo` matched `://` up to the next `@`, excluding only `/`,
`@` and whitespace. Compact JSON has none of those between a URL value and
the next key, so `{"iss":"https://agent.example","sub":"aauth:[email protected]"}`
became `{"iss":"https://***@agent.example"}` — the AAuth identity an external
verifier echoes back never reached the agent, and the body was no longer
valid JSON. The same rule runs on every foreign-text exit (A2A replies, AAuth
resource bodies, git and docker errors) on both sides of the boundary.

The userinfo span now also stops at `"`, `<`, `>` and an escaped quote `\"`,
none of which can appear unencoded in userinfo. A bare backslash still
matches, so `CORP\user:pw@proxy` stays redacted. Applied to the backend and
agent-server copies alike; a shared table pins both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vybe vybe added the ui PR touches the frontend UI — triggers Playwright e2e tests label Oct 15, 2026
@vybe
vybe enabled auto-merge (squash) October 15, 2026 19:55

@trinity-ability trinity-ability left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validated: Lane C, all Tier 1 checks plus journey-smoke/e2e green on the PR; the regression test goes red (13 cases) with the fix reverted.

@vybe
vybe merged commit 211b087 into dev Oct 15, 2026
25 checks passed
dolho added a commit that referenced this pull request Oct 22, 2026
)

Review follow-up on #3876. The name-only suffix rule took secret-bearing
URLs out of the exact-value set: capability paths (Slack response URL,
private iCal feed), SAS `&sig=` queries, fragments, `;PWD=` connection
strings, and userinfo the #3770 regex stops short of. None of those are
caught by redact_url_userinfo or the KEY=value pass.

A URL-suffixed value now leaves the set only when it parses as a plain
http(s)/ws(s) URL with no userinfo, query, fragment, `;`, percent-encoding,
or token-shaped/secret-named path segment; anything else stays in
(fail-closed). Host/repo/region/team-id names stay name-based. PAT joins
the secret name words to match secret_settings._CREDENTIAL_SUFFIXES.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
vybe pushed a commit that referenced this pull request Oct 23, 2026
#3840) (#3876)

* fix(sanitizer): keep non-secret config values out of the redaction set (#3840)

The vendor prefixes in SENSITIVE_VAR_PATTERNS (FIBERY_.*, GITHUB_.*,
TRINITY_MCP.*) put the VALUE of every matching variable into the exact-value
set, so FIBERY_HOST=acme.fibery.io erased the hostname from every link an
agent replied with (https://***REDACTED***/...).

A name ending in a non-secret suffix (_HOST, _URL, _REPO, _TEAM_ID, _REGION,
...) now stays out of the value set unless it also carries a secret word
(KEY, TOKEN, SECRET, PASS, AUTH, HOOK, ...), so SLACK_WEBHOOK_URL still
redacts. Credentials inside a config URL are still caught by
redact_url_userinfo, and the KEY=value pass keeps every vendor prefix.

Fixes #3840

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(sanitizer): pin the #3840 name check as linear and off the hot path

Measured linear (0.46ms at 4 KB, 6.3ms at 64 KB, ~100ms at 1 MB) and
reached only from the cached value loader; sanitize_text is unchanged
(238ms per MB on both dev and this branch). The tests keep it that way.

Related to #3840

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(sanitizer): exempt _URL/_URI/_ENDPOINT values only when plain (#3840)

Review follow-up on #3876. The name-only suffix rule took secret-bearing
URLs out of the exact-value set: capability paths (Slack response URL,
private iCal feed), SAS `&sig=` queries, fragments, `;PWD=` connection
strings, and userinfo the #3770 regex stops short of. None of those are
caught by redact_url_userinfo or the KEY=value pass.

A URL-suffixed value now leaves the set only when it parses as a plain
http(s)/ws(s) URL with no userinfo, query, fragment, `;`, percent-encoding,
or token-shaped/secret-named path segment; anything else stays in
(fail-closed). Host/repo/region/team-id names stay name-based. PAT joins
the secret name words to match secret_settings._CREDENTIAL_SUFFIXES.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(sanitizer): exempt _HOST/_REPO/... values only when plain, and any 16+ segment is token-shaped (#3840)

Second #3876 review. The non-URL non-secret suffixes were still exempted
on the name alone, the class already closed for _URL: DB_HOST=Server=x;
Pwd=..., MONGO_HOST=mongodb://app:ab"cd@db/app and DATABASE_PROJECT=
Host=db;Password=... left the value set and reached replies verbatim. A
_HOST/_REPO/_PROJECT/... value now leaves the set only when it holds none
of ;@?#%"', whitespace, backslash or ://.

_is_token_shaped no longer requires mixed letters and digits: a 16+
character path segment that is all letters (a capability URL) or all
digits (a private feed id) keeps the URL in the set.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ui PR touches the frontend UI — triggers Playwright e2e tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants