Skip to content

v1.92.3.0 fix(redact): env.kv catches a credential on a diff line (GST-543) - #3726

Merged
capy-ai[bot] merged 6 commits into
mainfrom
gst-543-redact-diff-prefix
Oct 31, 2026
Merged

capy-ai[bot] merged 6 commits into
mainfrom
gst-543-redact-diff-prefix

Conversation

@garrytan

@garrytan garrytan commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner
{
  "schema_version": 1,
  "pr": 3726,
  "head": "0fe45594fee341cb95dd183d7e06031713b2e6d0",
  "version": "1.91.376.0",
  "base": "main",
  "gate": {
    "redact": {
      "pass": 347,
      "fail": 0,
      "skip": 0
    },
    "remote-pregate": {
      "pass": 8104,
      "fail": 0,
      "skip": 0
    }
  },
  "session_kind": "unattended",
  "head_tree": "c8bec08fcc477a0b406dfca31395a64c68dd5085",
  "product_patch_id": "ec56dcd721603b70129712d4db14c7ce0ba37dc7",
  "gstack_version": "1.91.376.0",
  "review_depth": {
    "depth": "light",
    "class": "code",
    "runtime_lines": 15,
    "rules": "150435b0a543019a",
    "base": "2d1b55d7621df1a71e02037c79b63b7ee2fdc64f",
    "registry": "2d1b55d7621df1a71e02037c79b63b7ee2fdc64f",
    "gate_scan": {
      "tagged": 0,
      "head": "0fe45594fee341cb95dd183d7e06031713b2e6d0"
    },
    "reasons": [
      "runtime=15<=50"
    ]
  },
  "pregate": "requires-remote cleared @c8bec08fcc47 (1 checks, current for 0fe45594fee3)",
  "requires_remote": [
    "free-tests.yml/cso-macos-launcher: https://github.com/garrytan/gstack/actions/runs/41231135017",
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/41231135017",
    "free-tests.yml/cso-windows-launcher: https://github.com/garrytan/gstack/actions/runs/41231135017",
    "windows-free-tests.yml/windows-free-shard: https://github.com/garrytan/gstack/actions/runs/41231134985",
    "pregate.json/remote_gate: remote-gate tree=c8bec08fcc47 tests=8104"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "docs/pregate.md, docs/CONTRIBUTOR_REFERENCE.md, CLAUDE.md, changelog fragment"
  },
  "review_loop": {
    "passes": 1,
    "blocking_found": 1,
    "deferred": 0,
    "noted": 3,
    "fixed": 4,
    "scope": "frozen",
    "fix_checks": 3,
    "dispatches": {
      "specialist": 1
    }
  }
}

What changed

git diff | gstack-redact missed a credential on a diff line. env.kv matched from the start of the line, so the +/- diff marker stopped the match. Now env.kv accepts a unified or combined diff marker before the name.

Before (main 5ba425a): a hunk with +API_TOKEN=<random value> piped to gstack-redact --json gives "findings": [], exit 0.
After (this branch): env.kv MEDIUM, exit 2.

Why

This is a wrong security result (S1, GST-543), found while working on #3630. A diff code block in a PR body, or a diff piped into the CLI, could carry a live credential past the scanner. Pregate's secrets check and the pre-push hook were not affected, because both strip the + before scanning.

Proof: test/redact-diff-prefix.test.ts was written first and failed on main (env.kv (+), env.kv (hunk), env.kv (indented hunk), and the CLI exit-2 test).

Blast radius

  • lib/redact-patterns.ts: the env.kv regex, ENV_KV_NAME and SCHEMA_FIELD_NAME take an optional marker, (?:[ +-]?\+|[ +-]?-(?! [^ \t]))?. A - followed by one space and text is still a Markdown bullet or YAML list item, not a marker.
  • Scanning every tracked file, env.kv results at this tree match base 5ba425a: 0 files differ.
  • The test gives every pattern in PATTERNS a sample. Each sample must report bare, behind every marker, and inside a real hunk. env.kv was the only rule with this blind spot.

Pre-Landing Review

REVIEW_LOOP: passes=1 blocking_found=1 deferred=0 noted=3 fixed=4 scope=frozen fix_checks=3 dispatches=1
Gate edits: none

Review notes below the blocking floor, not fixed:

  • A removed line whose content starts with exactly one space, - API_TOKEN=…, reads as a bullet and stays unreported. The same is true for a two-parent --cc line removed against the first parent only. This is the cost of keeping Markdown bullets clean.
  • A three-parent (octopus) combined line, +API_TOKEN=…, is still missed. Only one extra marker column is read.
  • + bullets, and bullets indented by one space ( + x, - x), now read as diff markers. No tracked file has one.
  • YAML list-item credentials (- token: …) never matched env.kv. That was true before this change too.

Documentation

Docs audit (gst543-docs-1): current. Scope checked: docs/pregate.md, docs/CONTRIBUTOR_REFERENCE.md, CLAUDE.md and the changelog fragment.

Test plan

  • bun test test/redact-diff-prefix.test.ts failed on main 5ba425a and passes here.
  • Redact lane: 347 pass, 0 fail.
  • Remote pregate (Ubicloud, tree c8bec08f): 8104 tests, 0 failed. The macOS and Windows lanes were cleared from this PR's CI runs 41231135017 and 41231134985.

Open in Capy

garrytan and others added 6 commits October 31, 2026 18:11
…ST-543)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…ation or export)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@trunk-io

trunk-io Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

@github-actions github-actions Bot changed the title fix(redact): env.kv catches a credential on a diff line (GST-543) v1.92.3.0 fix(redact): env.kv catches a credential on a diff line (GST-543) Oct 31, 2026
@capy-ai
capy-ai Bot merged commit d9182b6 into main Oct 31, 2026
62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant