Conversation
…rch#6396) The secret redaction engine only handled database-specific protocol URLs (postgres, mysql, etc.) but missed generic https/git/ssh URLs with embedded credentials like `https://PASSWORD@github.com/user/repo.git`. This caused passwords and tokens to be displayed in plain text when the agent suggested git commands or displayed URL output containing credentials. Changes: - Extend URL credential regex to cover https, http, git, ssh, ftp protocols for user:password@host format (replaces DB-only _DB_CONNSTR_RE) - Add bare token pattern for protocol://TOKEN@host URLs (8+ char threshold to avoid false positives on short usernames like "git" or "admin") - Run URL credential redaction before prefix patterns so tokens in URLs are redacted holistically without partial leakage - Add 13 test cases covering the reported scenario and edge cases
|
merge conflicts This PR does not merge cleanly with the base branch. Please rebase or merge current Signed: GPT-5.5-medium in Codex |
|
Thanks for this, and for the clean tests — the bug in #6396 is real and your reproduction was spot-on. We're closing this one as intentional-design, not because the work is wrong. After this PR was opened, commit acd05c6 ("fix(redact): pass web URLs through unchanged", #34029) deliberately removed userinfo + query-param URL redaction: The underlying leak is still worth fixing, though, just more narrowly. We shipped #54475, which redacts only the colon-less bare-token userinfo form ( Credited your report and repro in that PR. Appreciate the contribution. |
Summary
Fixes #6396
The secret redaction engine in
agent/redact.pypreviously only handled database-specific protocol URLs (postgres, mysql, mongodb, redis, amqp) for credential redaction. This meant that passwords and tokens embedded in generic URLs likehttps://PASSWORD@github.com/user/repo.gitwere displayed in plain text in agent output.This is exactly what happened in the reported issue — the agent suggested a
git remote set-urlcommand with the user's password embedded in the URL, and the redaction engine failed to mask it.Changes
Extended URL credential regex (
_URL_CRED_RE): Now covershttps,http,git,ssh,ftp,ftps,sftpprotocols in addition to the existing database protocols foruser:password@hostformat. Replaces the old DB-only_DB_CONNSTR_RE.Added bare token regex (
_URL_BARE_TOKEN_RE): Catchesprotocol://TOKEN@hostURLs where a password/token is embedded without a username prefix (the exact pattern from the bug report). Uses an 8-character threshold to avoid false positives on short usernames like "git" or "admin".Reordered redaction pipeline: URL credential patterns now run before prefix patterns (sk-, ghp_, etc.) so that tokens inside URLs are redacted holistically without partial leakage.
13 new test cases covering the reported scenario and various edge cases (bare passwords, user:password, GitHub PATs in URLs, DB URLs still working, false positive avoidance).
Test Plan
tests/agent/test_redact.py)https://mysecretpassword123@github.com/user/repo.git→https://***@github.com/user/repo.git