Context
Two Google Maps API keys sat in the tracked tree from 2022-12-28 until #18828 removed them. Nothing in this repository noticed. GitHub's secret scanner did, out-of-band, and the alerts are what started the investigation.
Proposed by @neo-opus-grace while reviewing #18830, filed separately because it is a new guard on a shared job rather than part of a content change already under review.
The Problem
The failure was silent for years, and the reason it stayed silent is instructive.
Of the two keys, the one in examples/ was dead (BillingNotEnabledMapError) and the one in learn/tutorials/Earthquakes.md was live, funded, and not origin-locked. The dead key is the one a maintainer opening the example would hit, so the visible breakage pointed away from the real exposure. A broken credential masked a working one, and only an external scanner distinguished them.
It also reached further than the repository: npm pack neo.mjs@13.1.0 contains learn/tutorials/Earthquakes.md plus 194 deck pages, with the live key inside. Registry versions are immutable, so that copy is permanent. The window between committing a credential and it becoming unrecallable is one npm publish.
A local guard would have closed that window at the commit.
The Architectural Reality
.husky/pre-commit runs staged-file checks through buildScripts/util/check-*.mjs. #18828's own commit was blocked by check-whitespace.mjs over five pre-existing lines, so the mechanism demonstrably has teeth on content files.
- No existing check inspects file content for credential shapes. The closest are
check-ticket-archaeology.mjs and check-content-logical-identity.mjs, both about ticket references and duplication rather than secrets.
- The CI
baseline workflow runs the same family of guards.
resources/content/archive/** contains the literal token AIza… — with an ellipsis, inside prose describing a redaction test. Any pattern must not match it, and its existence is why a naive AIza substring search is wrong.
The Fix
Add a content guard over staged and tracked files that fails on credential-shaped literals, run from the same place the other check-* scripts run.
The pattern set is the design question and should not be guessed:
AIza[0-9A-Za-z_-]{35} — Google. Note the length anchor: it is what separates a real key from the archive's AIza… prose.
sk-[A-Za-z0-9]{20,} / sk-ant- — OpenAI / Anthropic.
ghp_ / gho_ / ghs_ / github_pat_ — GitHub tokens.
AKIA[0-9A-Z]{16} — AWS access key ids.
ya29\. — Google OAuth.
An allowlist mechanism is required, not optional: tests and docs legitimately contain credential-shaped strings, and #18828 itself introduced the placeholder YOUR_GOOGLE_MAPS_API_KEY.
Contract Ledger Matrix
| Target Surface |
Source of Authority |
Proposed Behavior |
Fallback |
Docs |
Evidence |
new buildScripts/util/check-secrets.mjs |
this ticket |
non-zero exit naming file, line and matched pattern kind — never echoing the secret |
none |
its own module docblock |
sibling check-*.mjs scripts |
.husky/pre-commit |
.husky/pre-commit |
runs the guard over staged files |
commit proceeds if unstaged |
— |
check-whitespace blocked #18828's first commit |
CI baseline |
.github/workflows |
runs it over the tracked tree |
— |
— |
existing baseline jobs |
Decision Record impact
none.
Acceptance Criteria
Out of Scope
- Revoking or rotating the existing keys — account-owner action tracked on
#18828.
- Scanning git history. @tobiu ruled no rewrite on 2026-09-17; a guard that fails on every historical commit would be unusable anyway.
- Replacing GitHub's secret scanning. This is a faster local tripwire, not a substitute — GitHub's scanner has provider-verified patterns and out-of-band reach this cannot match.
- Scanning
node_modules or build output.
Avoided Traps
- ⛔ Do not print the matched secret in the failure message. CI logs are a published surface; a guard that echoes findings converts a private commit into a public disclosure.
- ⛔ Do not match on prefix alone.
AIza without a length anchor matches the archive's prose and would make the guard noisy on day one, which is how guards get disabled.
- ⛔ Do not ship without an allowlist. The tree already contains a deliberate
YOUR_GOOGLE_MAPS_API_KEY placeholder, and specs legitimately carry credential-shaped fixtures.
- ⛔ Do not assume a broken-looking credential is harmless. The incident that motivated this had one dead key and one live one; the dead one was more visible, and that asymmetry is what hid the live one for years.
Related
#18828 — removing the keys and teaching readers to mint their own
#18830 — the PR where @neo-opus-grace proposed this guard, and measured the npm exposure
unowned-rationale: parked deliberately. My two Maps lanes are under review and this is a shared-guard change that wants its own design pass on the pattern set; @neo-opus-grace proposed it and has first claim if she wants it.
Origin Session ID: 2b78af80-54a8-4e14-afd8-85c6dfe41004
Retrieval Hint: "committed api key lint guard, check-secrets buildScripts, AIza length anchor vs archive prose, npm tarball immutable credential"
Context
Two Google Maps API keys sat in the tracked tree from 2022-12-28 until
#18828removed them. Nothing in this repository noticed. GitHub's secret scanner did, out-of-band, and the alerts are what started the investigation.Proposed by @neo-opus-grace while reviewing
#18830, filed separately because it is a new guard on a shared job rather than part of a content change already under review.The Problem
The failure was silent for years, and the reason it stayed silent is instructive.
Of the two keys, the one in
examples/was dead (BillingNotEnabledMapError) and the one inlearn/tutorials/Earthquakes.mdwas live, funded, and not origin-locked. The dead key is the one a maintainer opening the example would hit, so the visible breakage pointed away from the real exposure. A broken credential masked a working one, and only an external scanner distinguished them.It also reached further than the repository:
npm pack neo.mjs@13.1.0containslearn/tutorials/Earthquakes.mdplus 194 deck pages, with the live key inside. Registry versions are immutable, so that copy is permanent. The window between committing a credential and it becoming unrecallable is onenpm publish.A local guard would have closed that window at the commit.
The Architectural Reality
.husky/pre-commitruns staged-file checks throughbuildScripts/util/check-*.mjs.#18828's own commit was blocked bycheck-whitespace.mjsover five pre-existing lines, so the mechanism demonstrably has teeth on content files.check-ticket-archaeology.mjsandcheck-content-logical-identity.mjs, both about ticket references and duplication rather than secrets.baselineworkflow runs the same family of guards.resources/content/archive/**contains the literal tokenAIza…— with an ellipsis, inside prose describing a redaction test. Any pattern must not match it, and its existence is why a naiveAIzasubstring search is wrong.The Fix
Add a content guard over staged and tracked files that fails on credential-shaped literals, run from the same place the other
check-*scripts run.The pattern set is the design question and should not be guessed:
AIza[0-9A-Za-z_-]{35}— Google. Note the length anchor: it is what separates a real key from the archive'sAIza…prose.sk-[A-Za-z0-9]{20,}/sk-ant-— OpenAI / Anthropic.ghp_/gho_/ghs_/github_pat_— GitHub tokens.AKIA[0-9A-Z]{16}— AWS access key ids.ya29\.— Google OAuth.An allowlist mechanism is required, not optional: tests and docs legitimately contain credential-shaped strings, and
#18828itself introduced the placeholderYOUR_GOOGLE_MAPS_API_KEY.Contract Ledger Matrix
buildScripts/util/check-secrets.mjscheck-*.mjsscripts.husky/pre-commit.husky/pre-commitcheck-whitespaceblocked#18828's first commitbaseline.github/workflowsDecision Record impact
none.Acceptance Criteria
#18828's merge commit, and specifically does not matchresources/content/archive/**'sAIza…prose or theYOUR_GOOGLE_MAPS_API_KEYplaceholder. Both are named in the test, so a future pattern widening cannot silently start matching them.learn/tutorials/Earthquakes.mdas it stood before#18828, it reports. This is the ticket's whole premise and is the one check that proves the guard would have caught the real incident rather than a synthetic one.Out of Scope
#18828.node_modulesor build output.Avoided Traps
AIzawithout a length anchor matches the archive's prose and would make the guard noisy on day one, which is how guards get disabled.YOUR_GOOGLE_MAPS_API_KEYplaceholder, and specs legitimately carry credential-shaped fixtures.Related
#18828— removing the keys and teaching readers to mint their own#18830— the PR where @neo-opus-grace proposed this guard, and measured the npm exposureunowned-rationale:parked deliberately. My two Maps lanes are under review and this is a shared-guard change that wants its own design pass on the pattern set; @neo-opus-grace proposed it and has first claim if she wants it.Origin Session ID: 2b78af80-54a8-4e14-afd8-85c6dfe41004
Retrieval Hint: "committed api key lint guard, check-secrets buildScripts, AIza length anchor vs archive prose, npm tarball immutable credential"