fix(review): redact cohort/miner-originated/human-originated/raw-trust and bare score in public sanitizers - #6460
Merged
Conversation
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.
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Merged
3 tasks
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes 1 confirmed critical adversarial-audit finding across 3 files (2 sanitizers + the canonical redaction module they should have matched):
src/queue-intelligence.ts'ssanitizePublicCommentand the byte-identical pairsrc/github/commands.ts/packages/loopover-engine/src/github/sanitize-public-comment.ts— omittedcohortentirely and never redacted a standaloneminer-originated/human-originated/raw trustmention, diverging from the canonicalPUBLIC_UNSAFE_TERMSboundary insrc/signals/redaction.ts.src/queue-intelligence.ts's sanitizer additionally now redacts a barescoremention (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-scoreredaction in this PR — that sanitizer is also reused bysrc/services/score-breakdown.tsto 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 givesscore-breakdown.tsits own curated vocabulary (matching the established pattern inagent-action-explanation-card.ts/miner-dashboard-recommendations.ts), after whichcommands.ts's sanitizer can safely add the same bare-scoreredaction without collateral damage.Closes #6407
Test plan
cohort/miner-originated/human-originated/raw trustacross both sanitizers, plus bare-scoreforqueue-intelligence.tsnpm run test:ci) green