Skip to content

Commit 1b2ad4b

Browse files
committed
fix(packaged): restore bare auth= scrubbing dropped in the Authorization fix
Review (nettee): removing authorization/auth from the key=value branch to fix the Authorization-header leak also dropped generic 'auth=abc' / 'auth: abc' scrubbing. Re-add 'auth' to the key=value alternation — it can't misfire on 'Authorization'/'author' because a [=:] separator must immediately follow the word, and the Authorization header itself is still handled by the dedicated whole-value rule.
1 parent 928533a commit 1b2ad4b

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

apps/packaged/src/startup-telemetry.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,12 @@ export function scrubSecrets(value: string): string {
195195
// scheme word ("Bearer"/"Basic") and leave the credential
196196
// ("Authorization: Bearer abc" -> "<redacted> abc"), so handle it first.
197197
.replace(/(\bAuthorization\s*[:=]\s*)\S[^\r\n]*/gi, "$1<redacted>")
198-
// `key = value` / `key: value` secrets (password, token, secret, api_key, …).
198+
// `key = value` / `key: value` secrets (password, token, secret, api_key,
199+
// auth, …). `auth` is kept here for bare `auth=…` fields; it can't misfire on
200+
// "Authorization"/"author" because a `[=:]` separator must immediately follow
201+
// the matched word (the Authorization *header* is handled by the rule above).
199202
.replace(
200-
/\b(pass(?:word|wd)?|pwd|secret|token|api[_-]?key|access[_-]?key|client[_-]?secret)(\s*[=:]\s*)("?)[^\s"'&]+\3/gi,
203+
/\b(pass(?:word|wd)?|pwd|secret|token|api[_-]?key|access[_-]?key|client[_-]?secret|auth)(\s*[=:]\s*)("?)[^\s"'&]+\3/gi,
201204
"$1$2<redacted>",
202205
)
203206
// Inline Bearer/Basic token values not under an Authorization header.

apps/packaged/tests/startup-telemetry.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,14 @@ describe('scrubSecrets', () => {
192192
expect(scrubSecrets('using key sk-ant-api03-ABC123DEF456GHI789 now')).not.toContain('ABC123DEF456');
193193
});
194194

195+
it('redacts a bare auth=… / auth: … field without misfiring on author or the header', () => {
196+
expect(scrubSecrets('auth=abc12345')).toBe('auth=<redacted>');
197+
expect(scrubSecrets('auth: abc12345')).toBe('auth: <redacted>');
198+
// A `[=:]` must follow the word, so "author"/"Authorization" don't misfire here.
199+
expect(scrubSecrets('author=jane')).toBe('author=jane');
200+
expect(scrubSecrets('Authorization: Bearer abc12345')).toBe('Authorization: <redacted>');
201+
});
202+
195203
it('redacts key=value secrets and bare emails', () => {
196204
expect(scrubSecrets('password=hunter2 token: abc12345')).toBe('password=<redacted> token: <redacted>');
197205
expect(scrubSecrets('login failed for user ontf116@gmail.com')).toBe(

0 commit comments

Comments
 (0)