Skip to content

fix(scripts): extend the packaged-secret detector to the 12 hard-block formats#7508

Closed
lourincedaging0-commits wants to merge 1 commit into
JSONbored:mainfrom
lourincedaging0-commits:fix/forbidden-content-secret-formats-7433
Closed

fix(scripts): extend the packaged-secret detector to the 12 hard-block formats#7508
lourincedaging0-commits wants to merge 1 commit into
JSONbored:mainfrom
lourincedaging0-commits:fix/forbidden-content-secret-formats-7433

Conversation

@lourincedaging0-commits

Copy link
Copy Markdown
Contributor

Closes #7433

Problem

scripts/forbidden-content.mjs's FORBIDDEN_CONTENT — the single source of truth the miner/mcp package checkers (check-miner-package.mjs/check-mcp-package.mjs, run in CI + at publish) and the AMS MCP contract test use to reject a packed file or tool response containing a secret — only matched PEM private-key headers, github_pat_/gh[pousr]_/gts_ tokens, and a generic <NAME>_SECRET= assignment. It missed 12 concrete formats that this repo's own src/review/secret-patterns.ts already hard-blocks (HARD_SECRET_KINDS), so e.g. an AWS/Slack/OpenAI/Anthropic key baked into a packed npm file shipped undetected.

Change

Widen FORBIDDEN_CONTENT to also match all 12 (aws_access_key, slack_token, google_api_key, gitlab_token, npm_token, stripe_secret_key, sendgrid_key, huggingface_token, voyage_api_key, firecrawl_api_key, openai_api_key, anthropic_api_key) using the exact regex bodies from SECRET_PATTERNS.

Approach — hand-copied, not imported. I checked the import route first (the issue notes check-engine-parity.ts imports across the scripts/src/ boundary), but that script is run via tsx; forbidden-content.mjs is loaded by plain node scripts/check-*.mjs in ci.yml and publish-miner.yml, which cannot import a .ts source at runtime. So per the issue's fallback, FORBIDDEN_CONTENT stays a single literal RegExp with the bodies hand-copied and a comment pointing back to the source of truth.

Deliberately excluded: jwt (out of scope for this packaged-secret detector — considered and left out, not silently added), and seed_or_mnemonic / bittensor_key (documented in secret-patterns.ts as weak, false-positive-prone heuristics kept out of HARD_SECRET_KINDS — a hotkey = line or the word "mnemonic" in ordinary docs is not a leaked secret).

Zero call-site changes

check-miner-package.mjs, check-mcp-package.mjs, and miner-mcp-contract.test.ts are untouched — this only widens what the shared constant matches. Verified locally: the full test/unit/forbidden-content.test.ts (extended with per-format coverage — all 12 new + 4 original shapes flagged, and jwt / mnemonic / Bittensor-key / plain text correctly not flagged; probes fragment-assembled so the file holds no contiguous credential literal) and test/unit/miner-mcp-contract.test.ts (33 tests) both pass.

…k formats

scripts/forbidden-content.mjs's FORBIDDEN_CONTENT -- the single source of
truth the miner/mcp package checkers and the AMS MCP contract test use to
reject a packed file or tool response embedding a secret -- only matched
PEM private-key headers, github_pat_/gh[pousr]_/gts_ tokens, and a generic
<NAME>_SECRET= assignment. It missed 12 concrete formats that this repo's
own src/review/secret-patterns.ts already hard-blocks (HARD_SECRET_KINDS):
AWS access keys, Slack/GitLab/npm/Stripe/SendGrid/Hugging Face/Voyage/
Firecrawl tokens, Google API keys, and watermark-anchored OpenAI/Anthropic
keys -- so any of those baked into a packed miner/mcp npm file was shipped
undetected.

Widen FORBIDDEN_CONTENT to also match those 12, using the exact regex bodies
from SECRET_PATTERNS. Approach: hand-copied (not imported) -- forbidden-
content.mjs is loaded by plain `node scripts/check-*.mjs` in ci.yml and
publish-miner.yml, not tsx, so it cannot import the .ts source at runtime
(check-engine-parity.ts can only because it is itself run via tsx); a comment
points back to the source of truth. Deliberately excluded: jwt (out of scope
for this detector -- considered and left out), and seed_or_mnemonic /
bittensor_key (documented there as weak, false-positive-prone heuristics kept
out of HARD_SECRET_KINDS). The three call sites are unchanged -- this only
widens what the shared constant matches; miner-mcp-contract.test.ts still
passes (no tool-response fixture trips a new pattern).

Closes JSONbored#7433
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.41%. Comparing base (fa67da4) to head (8ed18e9).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7508   +/-   ##
=======================================
  Coverage   91.41%   91.41%           
=======================================
  Files         717      717           
  Lines       73038    73038           
  Branches    21635    21635           
=======================================
  Hits        66768    66768           
  Misses       5227     5227           
  Partials     1043     1043           
Flag Coverage Δ
shard-1 35.26% <ø> (ø)
shard-2 41.91% <ø> (ø)
shard-3 35.15% <ø> (ø)
shard-4 40.64% <ø> (ø)
shard-5 30.97% <ø> (+0.01%) ⬆️
shard-6 30.73% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 20, 2026
@loopover-orb

loopover-orb Bot commented Jul 20, 2026

Copy link
Copy Markdown

Caution

🛑 LoopOver review result - reject/close recommended

Review updated: 2026-07-20 15:38:47 UTC

2 files · 2 blockers · CI green · clean

🛑 Suggested Action - Reject/Close

  • AI review already in progress for this PR head: Another LoopOver pass is already running the AI review for this exact PR head. This pass is skipping to avoid a duplicate LLM call.

Review summary
AI review is already running for this PR head in another LoopOver pass. LoopOver is holding this PR for manual review until that pass completes.

Nits — 3 non-blocking
  • Pull request duplicates other open work — Check for an existing pull request or issue covering this change and coordinate or consolidate before continuing.
  • AI review already in progress for this PR head — The gate is held for a human reviewer rather than passed automatically; it re-evaluates once the in-flight review completes or on the next update.
  • Readiness score is below the configured threshold — Use the readiness panel as advisory maintainer context; the score does not block this PR.

Why this is blocked

  • Linked issue overlaps another open PR — Review the related PRs before spending reviewer time on duplicate work.
  • Possible leaked secret in the diff (private_key_block) — Remove the secret from the diff, rotate the exposed credential, then re-run the gate.
📋 Copy for AI agents — paste into your coding agent
Fix the following blocker(s) from this PR review:

1. Linked issue overlaps another open PR — Review the related PRs before spending reviewer time on duplicate work.

2. Possible leaked secret in the diff (private_key_block) — Remove the secret from the diff, rotate the exposed credential, then re-run the gate.

Decision drivers

  • ❌ Code review — 2 blockers (No AI review summary)
  • ❌ Gate result — Blocking (Repo-configured hard blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #7433
Related work ⚠️ Same linked issue: #7499 Another open PR references the same linked issue.
Change scope ❌ 8/20 High review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 105 registered-repo PR(s), 51 merged, 5 issue(s).
Contributor context ✅ Confirmed Gittensor contributor lourincedaging0-commits; Gittensor profile; 105 PR(s), 5 issue(s).
Improvement ✅ Minor risk: low · value: minor
Review context
Contributor next steps
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb

loopover-orb Bot commented Jul 20, 2026

Copy link
Copy Markdown

LoopOver is closing this pull request on the maintainer's behalf (Linked issue overlaps another open PR; Possible leaked secret in the diff (private_key_block); duplicate of open PR #7499). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs may be analyzed later to improve review accuracy, but they are not automatically reopened or re-reviewed.

@loopover-orb loopover-orb Bot closed this Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(scripts): extend the packaged-secret detector (forbidden-content.mjs) with the repo's other known-precise secret formats

1 participant