Skip to content

Stop the secrets check flagging JavaScript template-literal keys built from variables and short words (#4287) - #4309

Closed
atharva081106 wants to merge 1 commit into
garrytan:mainfrom
atharva081106:fix/env-kv-ts-template-literal
Closed

atharva081106 wants to merge 1 commit into
garrytan:mainfrom
atharva081106:fix/env-kv-ts-template-literal

Conversation

@atharva081106

Copy link
Copy Markdown
Contributor

Fixes #4287.

Summary

  • Exempt unquoted top-level JS/TS template literals in env.kv when they contain ${...} interpolations, benign static chunks, no secret literals inside interpolations, and no trailing secret literals on the line.
  • Keep negative controls failing closed (uninterpolated backticks, secret prefixes like sk-/AKIA, high-entropy static text or split secrets, literals inside ${...}, non-JS/TS files, block comments, and unclosed multiline templates).

Tests

  • bun test test/redact-engine.test.ts test/redact-pattern-lint.test.ts test/redact-env-kv-attribute-reference.test.ts test/redact-hostname-property-read.test.ts test/redact-context-exemptions.test.ts (520 pass, 0 fail)
  • bun run typecheck & bun run typecheck:test (pass)

@trunk-io

trunk-io Bot commented Nov 12, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@capy-ai

capy-ai Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Thanks @atharva081106. This fixes #4287, which was already on our list. Because it changes what the secrets check lets through, it will get a careful security read, and it lands after our tooling freeze ends on November 21. We'll bring it onto current main ourselves and credit you.

@capy-ai

capy-ai Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Thank you, @atharva081106. We rebuilt this on current main in #4457 (e1cfcea), including a template-literal exemption, then removed that part after a second-model security audit. Exempting a template by its fixed text's entropy let random hex secrets and encoded literals in slots through, so template keys stay reported for now and are documented as a known limit. The other fixes from #4289 landed. We're leaving this PR open for the maintainers to decide on.

@capy-ai

capy-ai Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Closing this with thanks. Correcting my last note: in the cross-model audit, the template-key exemption let random secrets through, so template keys stay a documented known limit in docs/pregate.md. #4287 stays open to track it.

@capy-ai capy-ai Bot closed this Nov 17, 2026
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.

pregate secrets: env.kv flags a TypeScript template literal made of ${…} slots and a fixed word

1 participant