Skip to content

fix(rules): rank admin-named search keys - #1523

Closed
WilliamK112 wants to merge 1 commit into
squirrelscan:mainfrom
WilliamK112:codex/leaked-secrets-admin-tier-1515
Closed

WilliamK112 wants to merge 1 commit into
squirrelscan:mainfrom
WilliamK112:codex/leaked-secrets-admin-tier-1515

Conversation

@WilliamK112

Copy link
Copy Markdown
Contributor

Fixes #1515

What changed

  • rank 32-character Algolia and Typesense-shaped keys under admin-named variables at high confidence
  • keep search-named keys at medium with the existing search-only hint
  • detect Meilisearch masterKey at high and searchKey at medium, limited to Meilisearch context
  • document the variable-name tier rules and add the release note

Verification

  • bun test across all 10 leaked-secrets suites: 2807 pass, 25 existing todo, 0 fail
  • focused rule/corpus rerun after the final adjustment: 2465 pass, 25 existing todo, 0 fail
  • mutation check with the admin escalation disabled: the three new admin/Meilisearch assertions fail
  • bun run --cwd packages/rules typecheck
  • bun run docs:check
  • detect-secrets-hook on the changed files and refreshed baseline
  • git diff --check

Docs: updated docs/rules/security/leaked-secrets.mdx. Skill: none.

nc9 commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Reviewed head: a3c6d47

Thanks for the PR, William. Verdict: pending maintainer review. The change reads correct and CI is green (all checks pass, DCO sign-off present, CHANGELOG [Unreleased] and the rule doc are updated, no new dependency). The open question is overlap: #1524 also fixes #1515 and touches the same code in packages/rules/src/security/leaked-secrets.ts, so only one of the two can land as is.

Findings, most severe first:

  1. Medium: overlap with fix(rules): leaked-secrets hosted-search key under an admin name is high; Meilisearch master and search keys #1515 #1524. Both PRs rank admin-named hosted-search keys at high and add Meilisearch masterKey and searchKey detection. The maintainer will pick one, and the other will conflict.
  2. Low: isAdminSearchProviderKey (leaked-secrets.ts, the words.includes("master") branch) ranks any key with a master word at high with no length or provider check. The doc table scopes this to Meilisearch config, but master_api_key in any other context is also promoted. Consider matching the doc, or documenting it.
  3. Low: the new Meilisearch gate in scanContent (skip bare searchKey and masterKey outside Meilisearch context) has no negative test. Add one showing {"searchKey":"<20+ chars>"} with no meili nearby stays unreported.
  4. Info: the keywords list for "Generic API Key Assignment" grew by six entries. The prefilter cost looks small, but a corpus timing run would confirm.

nik

@WilliamK112

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I compared #1524: its dedicated Meilisearch context pattern matches the documented scope, and its standalone negative, generator, and snapshot coverage address the two low findings here. It is the more complete implementation. I will not push a competing follow-up; it is fine to close #1523 in favor of #1524.

@nc9 nc9 mentioned this pull request Nov 2, 2026
@nc9

nc9 commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Thank you William for #1515. We adopted your commit as it was (kept with your authorship, 54e59af4) and it ships in v0.0.159: https://github.com/squirrelscan/squirrelscan/releases/tag/v0.0.159. The admin escalation and the Meilisearch handling cover what the issue asked for, and CI was green on the first push.

Review found four things, which we fixed in a follow-up commit on top of yours so each is visible in the diff: (1) a name that spells apikey as one word (ALGOLIA_SEARCH_APIKEY, search_apikey) was skipped as a bare Meilisearch name outside a Meilisearch config, where it used to be reported at medium, so it is read as a provider name again; (2) the one-word spellings MASTERKEY, masterkey and searchkey slipped past the Meilisearch context check and were reported anywhere, so they are gated the same way; (3) placeholder values such as YOUR_MASTER_KEY_GOES_HERE reported at high, so the placeholder list now covers them; (4) the docs and changelog now describe the Meilisearch context (the word meili in the name or in the 120 characters before it) and that a master name is high at any length. We also added a hint on the admin tier (an admin key can write and delete an index) and tests for each of these, including that names which merely contain the letters admin stay at medium. Thank you for the careful tests: they made the review quick.

nik

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.

security/leaked-secrets: a key under an admin-named variable reports at medium, same as a search-named one

2 participants