Repository navigation
Description
Observed on squirrel v0.0.138; packages/rules/src/security/leaked-secrets.ts is unchanged since on main. I checked each case against the shipped binary with a local page, so this lists only what still fires. Cases that earlier work already handles (API_KEY="YOUR_API_KEY", apiKey = "your-api-key-here", postgres://app:[email protected]:5432/prod, Password: ••••••••) no longer report and need no change.
Still flagged: placeholders and documentation examples
Each snippet is placed in its own inline <script>; all hosts and values are made up.
| Snippet | Reported as |
|---|---|
var u = "postgres://user:s3cret@localhost:5432/app"; |
PostgreSQL Connection String, in leaked-secrets-high (fail) |
var s = "curl https://api.example.com/v1/charges -u sk_test_<the sample key printed in Stripe's own API reference>:"; |
Stripe Test Key, leaked-secrets-high (fail) |
var h = "Paste your key, it starts with -----BEGIN OPENSSH PRIVATE KEY-----"; (UI help text or an input placeholder; no key material follows) |
Private Key (OpenSSH), leaked-secrets-high (fail) |
var o = { password: 'example-password' }; (SDK JSDoc style example) |
Generic Secret Assignment, leaked-secrets-medium (warn) |
Why these are noise: a connection string pointing at localhost with a short human word as the password is documentation, not a credential; a published vendor sample key is public by definition and unusable; a PEM header with no base64 body is not a private key; example-password names itself as an example.
Expected
- A PEM header counts only when a base64 body follows (at least one plausible line of base64 and, ideally, the matching
-----END ...-----), for everyPrivate Key (...)pattern. - A connection string whose host is
localhost,127.0.0.1,*.internal,*.local,*.testor*.exampleis treated as a placeholder, likeexample.comalready is. - The placeholder-word list covers
example-*,sample-*,changemeands3cret-style leetspeak words, and the vendor-published sample keys (an allowlist of exact documented values) are suppressed.
Acceptance Criteria
-
None of the four snippets above produces an item in
security/leaked-secrets(fixture test per snippet). -
A real-shaped PEM block (header, base64 body, footer) is still reported as a private key.
-
A connection string with a non-local host and a high-entropy password is still reported.
-
The existing placeholder fixtures (
YOUR_API_KEY,your-api-key-here) still pass. -
A PEM block whose body is elided (
...,MIIE...) or under 64 base64 chars is not reported (fixture). (amended 2026-11-01: the floor is 32 base64 characters in a run, as built and tested: 31 stay silent, 32, 40 and 63 report, and a test pins that two 40-character lines report.) -
A connection string whose user, password or host contains
${,{{,%sor<…>is not reported (fixture from a bundled driver's template literal), and a password-lessredis://host:port/isn't a secret. -
Stripe's published documentation key is suppressed in its
sk_live_/rk_live_variants as well assk_test_. -
Bearerfollowed by a placeholder (YOUR_*,PASTE_*,<…>,{{…}},xxx…) is not reported (fixture). -
A JWT that is only a header segment (no payload or signature) is not reported (fixture).
-
A live-shaped token (
sk_live_,ghp_, an AKIA pair, a PEM with a body) inside<pre>/<code>is still reported at its normal confidence: a secret pasted into a docs block is still a leak; only the documented exact-match samples (vendor doc sample keys, the jwt.io sample token, bodiless PEM headers, placeholder words) are dropped (amended 2026-11-01, replaces the downgrade-to-info criterion)
Activity
nc9 commentedon Oct 29, 2026
Corpus evidence from a ~38k-site batch (v0.0.141, up to 200 first-party scripts per site, hand-triaged with masked context; no credential used or tested):
Private Key (RSA/OpenSSH/EC/PGP)flags were false positives. They came from input placeholders and labels (placeholder:"-----BEGIN RSA PRIVATE KEY-----\n..."), other scanners' rule tables (/-----BEGIN (?:RSA )?PRIVATE KEY-----/g), key-type validators, and docs with elided bodies (MIIE...). This confirms the PEM-body requirement here. Add: skip bodies that contain...or other elisions.postgresql://${encodeURIComponent(user)}:${encodeURIComponent(password)}@${host}/${db}inside bundled DB-driver code (11 rows from 6 different driver builds), compose/deploy docs (DATABASE_URL=postgres://app:pw@service-name:5432/db) and password-lessredis://redis7:6379/.sk_live_prefix, as used in redaction demos (2 rows). The current allowlist covers only thesk_test_form.Adding criteria for these to the checklist.
nc9 commentedon Oct 29, 2026
More corpus evidence (hand-verified JWT/bearer and generic-secret lanes, v0.0.141, masked, nothing used): documentation and code-block examples are a large false-positive class that a value-only check can't separate. It needs code-block / docs context:
Bearer YOUR_TOKEN,Bearer PASTE_*,Authorization: Bearer <token>in docs and MCP-config snippets: 39 flags.curl -H 'x-api-key: …'and MCPheaders:examples on docs pages: 24 flags.Bearer eyJhbGciOiJIUzI1NiIs, header only) in tutorials and glossaries: 10 flags..env/ test-runner examples inside<pre>/<code>blocks: 45 flags on 27 sites.Adding criteria.
fix(rules): leaked-secrets allowlists read the matcher's own text: ex…
fix(rules): leaked-secrets allowlists narrowed after review: PEM bodi…
fix(rules): armor header lines must be armor headers; braced random p…
fix(rules): PEM body search is bounded per header; any HTML tag separ…
fix(rules): leaked-secrets ignores jwt.io samples, bodiless PEM heade…
fix(rules): leaked-secrets ignores jwt.io samples, bodiless PEM heade…
fix(rules): leaked-secrets ignores jwt.io samples, bodiless PEM heade…
nc9 commentedon Nov 1, 2026
Amended acceptance criterion: the third criterion (values inside
<pre>/<code>on docs-like pages downgraded to an info note) is descoped. A secret pasted into a docs block is still a leak, and a downgrade by context would also hide real tokens that sit in a docs-looking page. The criterion now says a live-shaped token inside<pre>/<code>is still reported at its normal confidence, and only the documented exact-match samples (vendor doc sample keys, the jwt.io sample token, bodiless PEM headers, placeholder words) are dropped. A probe on the stack's first PR confirms a live-shapedsk_live_andghp_token inside<pre><code>is still reported.nik
fix(rules): leaked-secrets ignores jwt.io samples, bodiless PEM heade…
fix(rules): leaked-secrets ignores jwt.io samples, bodiless PEM heade…
fix(rules): leaked-secrets ignores jwt.io samples, bodiless PEM heade…
fix(rules): leaked-secrets ignores jwt.io samples, bodiless PEM heade…
fix(rules): leaked-secrets ignores jwt.io samples, bodiless PEM heade…
fix(rules): leaked-secrets ignores jwt.io samples, bodiless PEM heade…
fix(rules): leaked-secrets ignores jwt.io samples, bodiless PEM heade…
nc9 commentedon Nov 1, 2026
Amended the PEM criterion to the shipped floor: a body of fewer than 32 base64 characters in a run is not reported (31 silent; 32, 40 and 63 report; a test pins that two 40-character lines report). The other criteria are ticked as met on v0.0.158. One criterion stays open: a header-only JWT after
Bearer(Bearer eyJ...with no dot) still reports at medium; a fix is in progress.nik
fix(rules): leaked-secrets header-only Bearer JWT dropped only for a …
fix(rules): leaked-secrets drops a header-only JWT after Bearer #1227
fix(rules): leaked-secrets header-only Bearer JWT dropped only for a …
nc9 commentedon Nov 2, 2026
Shipped in v0.0.159 and checked against it: every acceptance criterion is met, including the last open one. A header-only
Bearer eyJ...value (a bare header, a truncated header, a full header with no dot) is no longer reported, while an opaque base64url JSON bearer, a full JWT afterBearer, and a%2E- or comma-separated JWT afterBearerstill report. Release: https://github.com/squirrelscan/squirrelscan/releases/tag/v0.0.159nik