From b2f431a9f29bff65877712e8ed745cdcda1276a8 Mon Sep 17 00:00:00 2001 From: Connor Burgess Date: Fri, 4 Dec 2026 10:51:17 +0700 Subject: [PATCH 1/2] search: the redaction fast path lets through every text sessionpipe-core 0.19 redacts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Symptom: with sessionpipe-core 0.19.1 (the bump in #271), the search index keeps `Cookie: sessionid=…`, `curl -b 'sid=…'`, `GET /x?sig=…`, `fetch('/dl?X-Amz-Signature=…')` and `{"name": "Authorization", "value": "…"}` as they are, while core's own redactSecrets cuts each of them. On main (core 0.17.0) core redacts none of them, so nothing leaks today. Cause: redact() skips redactSecrets when MAYBE_SECRET finds no trigger and the ruleset id is secrets@1. Core 0.18 added cookie, named-value and link-query rules under the same id (f31fc51, 556a8c0, c410cf4), and none of their words is a trigger. redact.test.ts's guard counts only TOKEN_PATTERNS, which did not change, so it passes on 0.19.1 too. Fix: MAYBE_SECRET also takes `cookie`, `authorization`, `-b ` and the query keys core reads after `?`, `&` or `&` (`k`, `sig`, `signature`, `x-amz-signature`, `x-goog-signature`; `key` was one already), and the Kelvin sign, which core's lower-casing turns into `k`. A text with `name` and `value` beside a cookie attribute takes the full path too. redact.test.ts gets a sample of every rule 0.18 added (parity only: 0.17.0 leaves them alone) and pins the core versions the list was checked on, so the next bump has to look at it. Signed-off-by: Connor Burgess --- server/search/sources/redact.test.ts | 37 +++++++++++++++++++++++++++- server/search/sources/text.ts | 22 ++++++++++++----- 2 files changed, 52 insertions(+), 7 deletions(-) diff --git a/server/search/sources/redact.test.ts b/server/search/sources/redact.test.ts index 76ab0459..1cb8ae11 100644 --- a/server/search/sources/redact.test.ts +++ b/server/search/sources/redact.test.ts @@ -57,6 +57,27 @@ const SECRETS = [ 'apiKey: "Zq81mLkP0vXy"', "client_secret=Hj28Ks91Lq", ]; +/** One sample of every text rule core 0.18 added under the same id (cookies, named values, + * a link's query key). Core 0.17.0 leaves them as they are, so for these only the parity + * with core is asserted: it is what fails when a core bump adds a rule MAYBE_SECRET lacks. */ +const LATER = [ + `Cookie: sessionid=${R(16)}`, + `curl -H 'Set-Cookie: sid=${R(16)}; Path=/; HttpOnly'`, + `HTTP_COOKIE=sid=${R(16)}`, + `curl --cookie "sid=${R(16)}" https-less.example`, + `curl -b 'sid=${R(16)}' example.com/a`, + `added cookie sid=${R(16)}`, + `{"name": "Authorization", "value": "${R(24)}"}`, + `{"name": "sid", "value": "${R(20)}", "domain": ".example.com", "path": "/"}`, + `page.addCookies([{ name: "sid", value: "${R(20)}" }])`, + `GET /x?sig=${R(20)} HTTP/1.1`, + `fetch('/dl?X-Amz-Signature=${R(24, HEX)}')`, + `/o?a=1&x-goog-signature=${R(24, HEX)}`, + `/m?k=${R(20)}`, + `/m?signature=${R(20)}`, + ``, + `{"coo\u212aie": {"name": "sid", "value": "${R(20)}"}}`, +]; const WORDS = "the retry webhook delivery fix build test deploy src/a.ts --flag x=1 key: value TOKEN tokenizer passes :// https://example.com".split( " ", @@ -69,6 +90,19 @@ describe("redaction fast path", () => { const src = readFileSync(new URL("../../../node_modules/sessionpipe-core/dist/index.js", import.meta.url), "utf8"); const block = /var TOKEN_PATTERNS = \[([\s\S]*?)\n\];/.exec(src)?.[1] ?? ""; expect(block.split("\n").filter((l) => /^\s*\/.*\/g,?\s*$/.test(l))).toHaveLength(34); + // Core adds rules under the same id (0.18 did: cookies, named values, query keys), so the + // fast path is checked against each core release: a bump must add its rules' samples + // to LATER and its version here. + const pkg = new URL("../../../node_modules/sessionpipe-core/package.json", import.meta.url); + expect(["0.17.0", "0.19.1"]).toContain(JSON.parse(readFileSync(pkg, "utf8")).version); + }); + + it("every rule core added under the same id is redacted exactly as core does", () => { + for (const s of LATER) { + for (const t of [s, `see ${s} here`, `${s}\n`, s.toUpperCase(), s.toLowerCase()]) { + expect(redact(t)).toBe(redactSecrets(t)); + } + } }); it("every rule's sample is redacted exactly as core does", () => { @@ -92,8 +126,9 @@ describe("redaction fast path", () => { const n = 1 + rnd(12); for (let k = 0; k < n; k++) { const r = rnd(10); + const pool = rnd(2) ? SECRETS : LATER; parts.push( - r === 0 ? (SECRETS[rnd(SECRETS.length)] ?? "") : r === 1 ? R(5 + rnd(50)) : (WORDS[rnd(WORDS.length)] ?? ""), + r === 0 ? (pool[rnd(pool.length)] ?? "") : r === 1 ? R(5 + rnd(50)) : (WORDS[rnd(WORDS.length)] ?? ""), ); } const t = parts.join(rnd(3) ? " " : ""); diff --git a/server/search/sources/text.ts b/server/search/sources/text.ts index 68fa3023..6f81060f 100644 --- a/server/search/sources/text.ts +++ b/server/search/sources/text.ts @@ -26,18 +26,28 @@ export function cut(text: string, max: number): string { /** * A necessary condition for `redactSecrets` (secrets@1) to change a text: every rule needs a * trigger word (`pass…`, `pwd`, `secret`, `…key`, `token`, `cred…`, `Bearer`/`Basic`), a URL - * (`://`), or one of its token prefixes. A text with none of them comes back unchanged, so - * it skips the ~35 regex passes (a quarter of the build's CPU on dense history). Bound to the - * ruleset id: when core ships another ruleset, every text takes the full path again until - * this list is checked against it (redact.test.ts pins the parity). + * (`://`), or one of its token prefixes. Since sessionpipe-core 0.18 the same id also cuts a + * cookie (`Cookie:`, `Set-Cookie`, `--cookie`, curl's `-b '…'`), a value named `Authorization` + * or written beside a cookie's attributes, and a link's `?sig=`/`&X-Amz-Signature=`-style key + * (also written `&sig=`). Core lower-cases names, and the Kelvin sign K (U+212A) lower-cases + * to `k`, so a text holding it takes the full path too. + * A text with none of them comes back unchanged, so it skips the ~35 regex passes (a quarter + * of the build's CPU on dense history). Bound to the ruleset id: when core ships another + * ruleset, every text takes the full path again until this list is checked against it + * (redact.test.ts pins the parity and the core versions it was checked on). */ const MAYBE_SECRET = - /pass|pwd|secret|key|token|cred|bearer|basic|:\/\/|AKIA|ASIA|ABIA|ACCA|gh[pousr]_|github_pat_|glpat-|xox[abposre]-|sk-|[sr]k_(?:live|test)_|whsec_|AIza|ya29\.|1\/\/0|GOCSPX-|xai-|gsk_|pplx-|hf_|pcsk_|npm_|pypi-|SG\.|shp(?:at|ss|ca|pa)_|dop_v1_|lin_(?:api|oauth)_|ntn_|sbp_|figd_|dp\.(?:pt|st|sa|ct)\.|grn_|ss_|:AA|eyJ/i; + /pass|pwd|secret|key|token|cred|bearer|basic|cookie|authorization|-b\s|(?:[?&]|&)(?:k|sig|signature|x-amz-signature|x-goog-signature)=|\u212a|:\/\/|AKIA|ASIA|ABIA|ACCA|gh[pousr]_|github_pat_|glpat-|xox[abposre]-|sk-|[sr]k_(?:live|test)_|whsec_|AIza|ya29\.|1\/\/0|GOCSPX-|xai-|gsk_|pplx-|hf_|pcsk_|npm_|pypi-|SG\.|shp(?:at|ss|ca|pa)_|dop_v1_|lin_(?:api|oauth)_|ntn_|sbp_|figd_|dp\.(?:pt|st|sa|ct)\.|grn_|ss_|:AA|eyJ/i; +/** A cookie written as an object with no cookie word in sight: a `name` and a `value` beside + * two of its attributes (`{"name":"sid","value":"…","domain":"…","path":"/"}`). */ +const COOKIE_MARK = /domain|path|expires|httponly|secure|samesite/i; const FAST = RULESET_SECRETS === "secrets@1"; /** sessionpipe-core's redactSecrets, skipped only when it provably changes nothing. */ export function redact(text: string): string { - return FAST && !MAYBE_SECRET.test(text) ? text : redactSecrets(text); + return FAST && !MAYBE_SECRET.test(text) && !(/value/i.test(text) && /name/i.test(text) && COOKIE_MARK.test(text)) + ? text + : redactSecrets(text); } /** Redacted and cut: the last step for every emitted text. Redaction runs before the cut From 0612019c40192afc306819f66ce18dd636e25acb Mon Sep 17 00:00:00 2001 From: Connor Burgess Date: Sat, 5 Dec 2026 07:19:28 +0700 Subject: [PATCH 2/2] docs: record the fix under Unreleased Signed-off-by: Connor Burgess --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5299e266..33f072c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ All notable changes to `sessionpipe-gui`. The format follows ## [Unreleased] +### Fixed + +- Search's redaction fast path recognizes the cookie, authorization and signed-link triggers added in sessionpipe-core 0.18–0.19. + ## [0.8.18] - 2026-12-04 ### Fixed