Skip to content

Detect more kinds of secrets when packaging (Secretlint 13.1.0 rules) - #1358

Merged
Benjamin Christopher Simmonds (benibenj) merged 2 commits into
mainfrom
benibenj/agents/secretlint-rules-13
Nov 24, 2026
Merged

Benjamin Christopher Simmonds (benibenj) merged 2 commits into
mainfrom
benibenj/agents/secretlint-rules-13

Conversation

@benibenj

@benibenj Benjamin Christopher Simmonds (benibenj) commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What changes: vsce package and vsce publish now block 15 more kinds of secrets, using Secretlint 13.1.0's recommended rules: Stripe, GitLab, Grafana, Anthropic, Groq, Hugging Face, Notion, HashiCorp Vault, Vercel, Databricks, Docker, Figma, Cloudflare and Tailscale tokens, plus database connection strings with a password. They also stop flagging two things that aren't secrets: placeholder private-key blocks (a BEGIN … PRIVATE KEY header followed by AAAA…) and strings that are too long to be npm tokens.

Still blocks every private key it blocks today: the new rules skip EC (P-256) private keys, Ed25519 private keys and encrypted private keys. vsce adds a small check of its own for exactly those keys. --allow-package-secrets privatekey still covers them.

Avoids new false alarms from placeholders:

  • Tokens that repeat a character 8 or more times in a row, such as sk_live_xxxxxxxxxxxxxxxxxxxxxxxx or glpat-xxxxxxxxxxxxxxxxxxxx, are allowed. Real tokens are random and practically never do this.
  • Database URLs with placeholder credentials such as <password>, or with a local host such as localhost, are allowed. These are common in documentation and bundled libraries. For example, the Prisma extension ships a mysql://[<user>[:<password>]@]<host>… template that would otherwise fail packaging.

Possible side effects:

  • An extension that contains one of the new secret types fails to package until the secret is removed or the type is allowed with --allow-package-secrets <name>. The name is shown in the error, for example [stripe].
  • The placeholder allowance also applies to token types vsce already checks, so placeholders it rejects today now package, for example Slack's documented example webhook URL (…/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX).
  • Scanning runs 27 rules instead of 12, so it's slower than main is now, but still far faster than before Speed up secret scanning by turning off Secretlint's profiler #1352.

Measured locally (macOS, Apple Silicon, Node 24), with extensions made of VS Code source files:

Before #1352 main (with #1352) this PR
vsce package, 2,048 files (median of 3) 11.8 s 1.5 s 2.7 s
Secret scan only, 8,192 files 174 s 1.1 s 3.2 s
Secret scan of 31 real extensions (9,892 files) 70.6 s 9.4 s 15.6 s
Details

Changes

  • @secretlint/secretlint-rule-preset-recommend goes from 10.2.2 to 13.1.0. All other Secretlint packages are already at 13.1.0 from Speed up secret scanning by turning off Secretlint's profiler #1352.
  • New rule vsce-rule-privatekey (src/secretLintPrivateKeyRule.ts). The preset only reports PEM keys whose Base64 body starts with MI or the OpenSSH magic and has at least 100 characters, and it doesn't recognize ENCRYPTED PRIVATE KEY. The new rule reports PEM blocks with at least 50 Base64 characters (vsce's existing threshold from False positive found private key error #1147) that start with an ASN.1 SEQUENCE (M followed by A–P) and that the preset doesn't report. It mirrors the preset's type, length and prefix checks, so no key is reported twice. Placeholder bodies don't start with a SEQUENCE, so they stay allowed. Its rule name is privatekey, so the existing allow flag applies.
  • Every scanner rule in the preset gets the allows pattern /([A-Za-z0-9])\1{7,}/, added to vsce's existing per-rule allows. The list comes from the preset's exported rules, so rules added in later upgrades get it too. privatekey and gcp are excluded, because real private keys often contain long runs of A (zero bytes in Base64); the OpenSSH key fixture fails the packaging tests if they aren't.
  • database-connection-string also gets two allows patterns: <…> placeholders and localhost / 127.0.0.1 / [::1] hosts.
  • The npm rule now requires a token boundary: a 45-character string, or a valid token directly followed by _, is no longer flagged. The npm test fixture is corrected to the real 40-character length.
  • Inline secretlint-disable comments still don't suppress findings in vsce (unchanged from main).

Testing

  • npm test: 409 passing. New tests cover placeholder keys and npm tokens, the Stripe rule, placeholder tokens allowed while a realistic GitLab token is reported, each private-key format reported exactly once with rule name privatekey, and placeholder/local database URLs allowed while a real one is reported. Removing the private-key rule, the placeholder allowance or the database allowances makes the matching test fail, and giving the placeholder allowance to the private-key rules makes the OpenSSH key packaging tests fail.
  • 42 hand-written samples: every real private key (RSA, EC, Ed25519, encrypted, OpenSSH) and every realistic token is still reported. The only samples that changed with the placeholder allowance are placeholders made of repeated characters.
  • Real vsce package runs, compared with main: EC, Ed25519, RSA, encrypted PKCS#8 and OpenSSH keys still fail packaging; --allow-package-secrets privatekey still lets an EC key through; a placeholder key block now packages; the Prisma template and a MongoDB Atlas <db_password> example still package; a production-looking Postgres URL now fails.
  • 31 marketplace and installed extensions (9,892 files): no findings lost compared with main, and no new findings.
  • Profiled a 2,048-file vsce package with dbgjs: no Secretlint profiling marks, and the new private-key rule takes about 2 ms in total. The extra time compared with Speed up secret scanning by turning off Secretlint's profiler #1352 is spread across the 15 new upstream rules.

Follow-ups

  • The preset's private-key gap (EC, Ed25519, encrypted keys) is still present in Secretlint v14 and is worth reporting upstream.
  • Secretlint v14 scans faster and removes the deprecated preset package; see draft Scan for secrets faster with Secretlint v14 #1359, which builds on this one.

Upgrade @secretlint/secretlint-rule-preset-recommend from 10.2.2 to 13.1.0, which adds detectors for 15 more kinds of secrets (for example Stripe, GitLab, Hugging Face, Docker, Anthropic and database connection strings) and ignores placeholder private keys and malformed npm tokens.

Keep blocking every private key vsce blocked before: the new preset skips short DER keys such as EC P-256 and Ed25519 and ENCRYPTED PRIVATE KEY blocks, so a small vsce rule reports exactly those keys. It uses the privatekey rule name, so --allow-package-secrets privatekey still applies.

Allow database URLs with <placeholder> credentials or a local host, which appear in documentation and bundled libraries such as Prisma.

Correct the npm token fixture to the real 40-character length, which the stricter npm rule requires.

Co-authored-by: Copilot <[email protected]>
Documentation and sample files use placeholders such as sk_live_xxxxxxxxxxxxxxxxxxxxxxxx or glpat-xxxxxxxxxxxxxxxxxxxx, which the recommended rules report because they only check a token's prefix and length. Allow any match that repeats a character 8 times in a row: real tokens are random and practically never do.

The allowance is added to every scanner rule in the recommended preset, keeping vsce's existing per-rule allows. The privatekey and gcp rules don't get it, because real private keys often contain long runs of "A".

Co-authored-by: Copilot <[email protected]>
@benibenj
Benjamin Christopher Simmonds (benibenj) merged commit 86ad55f into main Nov 24, 2026
7 checks passed
@benibenj
Benjamin Christopher Simmonds (benibenj) deleted the benibenj/agents/secretlint-rules-13 branch November 24, 2026 13:50
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.

5 participants