From 64795163af36f9129b5d8b32627ace4f7ac39292 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Fri, 20 Nov 2026 12:20:22 -0800 Subject: [PATCH] Redactor hides key=value secrets that follow a slash, so /cso history stops printing them (GST-3297) (#4571) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gstack's redactor now hides `password=…`, `api_key=…` and `token=…` values that come after a `/`, such as a symlink target `../password=…`, `cfg/api_key=…` or a Markdown link to such a path. Why: `/cso`'s retained Git history went through this redactor and kept those values, so `gstack-cso history` printed them; review packets, telemetry and ship logs use the same redactor. Nothing to do. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: p1/red-team#1 reader=red-team --- .../redactor-catches-secrets-after-a-slash.md | 4 + lib/redact-patterns.ts | 40 +++- test/redact-kv-after-slash.test.ts | 185 ++++++++++++++++++ 3 files changed, 225 insertions(+), 4 deletions(-) create mode 100644 changelog.d/redactor-catches-secrets-after-a-slash.md create mode 100644 test/redact-kv-after-slash.test.ts diff --git a/changelog.d/redactor-catches-secrets-after-a-slash.md b/changelog.d/redactor-catches-secrets-after-a-slash.md new file mode 100644 index 000000000..894b414b0 --- /dev/null +++ b/changelog.d/redactor-catches-secrets-after-a-slash.md @@ -0,0 +1,4 @@ +--- +important: security +--- +- **Secret values written as `name=value` at the end of a path are now hidden.** gstack's redactor only recognized `password=…`, `api_key=…` or `token=…` at the start of a line, so the same thing after a slash (`../password=…`, `cfg/api_key=…`, `https://host/cb/token=…`) came back unredacted. `/cso` was the visible case: its retained Git history kept such a value from a symlink target, a link that only exists in history, or ordinary file content, and `gstack-cso history` printed it. The same redactor covers review packets, telemetry and ship logs, so they now hide these values too. Paths and code that only mention these words, values that are placeholders or `${VAR}` references, and regex literals in code are left as they were. diff --git a/lib/redact-patterns.ts b/lib/redact-patterns.ts index 6137672da..0f97cb836 100644 --- a/lib/redact-patterns.ts +++ b/lib/redact-patterns.ts @@ -1205,11 +1205,36 @@ function concatenationHoldsSecret(match: RegExpExecArray): boolean { * match that starts after other text on its line is a comment's, and its value, * less trailing punctuation, reports only when it is a secret run by * isSecretRun. Code before the comment is matched from the line start and - * checked as before. + * checked as before. GST-3297: a match that starts after a path's `/` is not + * a comment's (`a/token=…`), so it is checked like a line-start match; one + * after a comment marker that opens a quoted string or bracket (`"// key: …"`) + * is still a comment's. */ +const COMMENT_MARKER_BEFORE = /(?:^|[ \t"'`([])(?:#{1,6}|\/{2,3}|\/\*{1,2}|