Skip to content

fix(review): redact cohort/miner-originated/human-originated/raw-trust and bare score in public sanitizers - #6460

Merged
JSONbored merged 1 commit into
mainfrom
fix/public-sanitizer-cohort-score-gaps
Jul 16, 2026
Merged

fix(review): redact cohort/miner-originated/human-originated/raw-trust and bare score in public sanitizers#6460
JSONbored merged 1 commit into
mainfrom
fix/public-sanitizer-cohort-score-gaps

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

Fixes 1 confirmed critical adversarial-audit finding across 3 files (2 sanitizers + the canonical redaction module they should have matched):

  • Two production sanitizers that gate AI-generated/echoed public text — src/queue-intelligence.ts's sanitizePublicComment and the byte-identical pair src/github/commands.ts/packages/loopover-engine/src/github/sanitize-public-comment.ts — omitted cohort entirely and never redacted a standalone miner-originated/human-originated/raw trust mention, diverging from the canonical PUBLIC_UNSAFE_TERMS boundary in src/signals/redaction.ts.

src/queue-intelligence.ts's sanitizer additionally now redacts a bare score mention (via a dedicated word-boundary check, not folded into the substring wordlist, since a plain substring match would false-positive on ordinary English words like "underscore"/"outscore").

src/github/commands.ts's sanitizer deliberately does not add bare-score redaction in this PR — that sanitizer is also reused by src/services/score-breakdown.ts to render its own authenticated, per-contributor "explain my score" copy, which legitimately says "score" throughout by design; redacting it there would gut that feature's own output, not close a leak. A follow-up PR gives score-breakdown.ts its own curated vocabulary (matching the established pattern in agent-action-explanation-card.ts/miner-dashboard-recommendations.ts), after which commands.ts's sanitizer can safely add the same bare-score redaction without collateral damage.

Closes #6407

Test plan

  • New regression tests for cohort/miner-originated/human-originated/raw trust across both sanitizers, plus bare-score for queue-intelligence.ts
  • Full local gate (npm run test:ci) green

The two production public/private boundary sanitizers gating AI-generated
and echoed free text before it reaches a real GitHub comment omitted
"cohort" entirely and never redacted a bare "score", diverging from the
canonical PUBLIC_UNSAFE_TERMS boundary in src/signals/redaction.ts.

- src/queue-intelligence.ts: add "cohort", "miner-originated",
  "human-originated", and "raw trust" to FORBIDDEN_PUBLIC_COMMENT_WORDS,
  and add a separate word-boundary check for a bare "score" (kept out of
  the substring wordlist so it can't false-positive on words like
  "underscore"). This sanitizer gates ai-review/ai-summaries/ai-chat-qa/
  enrichment-wire output before it is ever posted.
- src/github/commands.ts and packages/loopover-engine/src/github/
  sanitize-public-comment.ts (kept byte-identical): add the same bare
  "cohort"/miner-originated/human-originated/raw-trust redaction. A bare
  "score" is intentionally left alone here since this sanitizer is also
  reused by score-breakdown.ts's own "explain my score" copy, which
  legitimately says "score" throughout by design.

Adds regression tests reproducing the audited leak sentence and an
over-blocking guard proving ordinary words like "underscore" survive.
@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.59%. Comparing base (b09f262) to head (b2c66d7).
⚠️ Report is 11 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6460   +/-   ##
=======================================
  Coverage   95.59%   95.59%           
=======================================
  Files         589      589           
  Lines       47025    47029    +4     
  Branches    14951    14952    +1     
=======================================
+ Hits        44952    44956    +4     
  Misses       1291     1291           
  Partials      782      782           
Flag Coverage Δ
shard-1 44.14% <50.00%> (-0.11%) ⬇️
shard-2 36.85% <50.00%> (+0.20%) ⬆️
shard-3 32.51% <50.00%> (+0.14%) ⬆️
shard-4 34.69% <100.00%> (-0.62%) ⬇️
shard-5 31.02% <50.00%> (+<0.01%) ⬆️
shard-6 45.42% <50.00%> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
...pover-engine/src/github/sanitize-public-comment.ts 100.00% <ø> (ø)
src/github/commands.ts 98.28% <ø> (ø)
src/queue-intelligence.ts 100.00% <100.00%> (ø)

@JSONbored JSONbored self-assigned this Jul 16, 2026
@JSONbored
JSONbored merged commit 77fd09e into main Jul 16, 2026
18 checks passed
@JSONbored
JSONbored deleted the fix/public-sanitizer-cohort-score-gaps branch July 16, 2026 09:29
@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 16, 2026
nghetienhiep pushed a commit to nghetienhiep/gittensory that referenced this pull request Jul 16, 2026
explainScoreBreakdown() piped its own contributor-facing "explain my score"
copy through sanitizePublicComment (src/github/commands.ts), the shared
sanitizer for genuinely public GitHub comment surfaces. This endpoint
(POST /v1/scoring/explain-breakdown, gated by requireContributorAccess) is
authenticated and scoped to the requesting contributor's OWN score, not a
public GitHub comment -- so "score" and "credibility" are its legitimate
core vocabulary, not a leak. The shared sanitizer was mangling both terms
into "private context" throughout this feature's own output.

Mirrors the established, documented pattern in
agent-action-explanation-card.ts / miner-dashboard-recommendations.ts (see
src/signals/redaction.ts's note above PUBLIC_UNSAFE_TERMS): this endpoint's
output is entirely computed, structured score data, so the only genuine
residual risk is an accidentally-embedded token or local filesystem path --
keep just that minimal safety net instead of the full gittensor-economic-
vocabulary substitution.

Unblocks a planned follow-up: once this file no longer depends on
sanitizePublicComment, that shared sanitizer can safely add bare-"score"
redaction (already added to queue-intelligence.ts's sanitizer in JSONbored#6460)
without breaking this feature.
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

1 participant