Skip to content

fix(review): defang impact map prompt context#3958

Merged
JSONbored merged 1 commit into
mainfrom
codex/fix-impact-map-prompt-injection-vulnerability
Jul 7, 2026
Merged

fix(review): defang impact map prompt context#3958
JSONbored merged 1 commit into
mainfrom
codex/fix-impact-map-prompt-injection-vulnerability

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Motivation

  • Close a prompt-injection bypass where contributor-controlled impact-map text was appended raw to the AI reviewer prompt and not covered by the existing defang/safety path.
  • Preserve byte-identical behavior when the safety feature is disabled so default behavior is unchanged.

Description

  • Extend SafetyReviewInput to include impactMapContext and update defangReviewInput to neutralize it via neutralizePromptInjection before it reaches the model (file: src/review/safety.ts).
  • Update the helper doc comment to describe that defanging applies to all untrusted AI prompt inputs, not just title/body/diff.
  • Add regression tests exercising the end-to-end review path and the helper to ensure impactMapContext is redacted when GITTENSORY_REVIEW_SAFETY is enabled and remains byte-identical when the flag is off (file: test/unit/safety-wiring.test.ts).

Testing

  • Ran the unit suite for the modified tests with npx vitest run test/unit/safety-wiring.test.ts and all tests passed.
  • Ran npm run typecheck which completed with no type errors.
  • Verified git diff --check produced no whitespace/conflict issues.

Codex Task

@superagent-security

Copy link
Copy Markdown
Contributor

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

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

loopover-orb Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-07 07:56:46 UTC

2 files · 1 AI reviewer · 2 blockers · readiness 93/100 · CI green · clean

⏸️ Suggested Action - Manual Review

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.

Review summary
This PR closes a real gap: `impactMapContext` was a new untrusted, contributor-influenced field that bypassed the existing prompt-injection defang path in `defangReviewInput`. The fix mirrors the established pattern for `body` (null-safe passthrough, else `neutralizePromptInjection`) and preserves flag-off byte-identical behavior, which is exactly the safety invariant this module requires. Tests cover both FLAG-ON redaction and FLAG-OFF passthrough at both the end-to-end review path and the helper-unit level, and CI is green.

Nits — 4 non-blocking
  • test/unit/safety-wiring.test.ts's new helper test duplicates a pre-existing pattern where `expect(out.impactMapContext).toContain("[external-instruction-redacted]")` is immediately followed by `expect(out.impactMapContext).not.toContain("[external-instruction-redacted]")` on the same string — the second assertion looks like a copy-paste of the sibling `changedFiles` check and probably should instead assert the raw `INJECTION_FILENAME`/injected phrase is absent, not the redaction marker itself.
  • Consider exporting or documenting that `impactMapContext` in `SafetyReviewInput` is expected to be pre-joined text (vs. `changedFiles` which is a list) so future callers know not to pass structured impact-map data directly.
  • src/review/safety.ts: fix the copy-pasted negative assertion noted above to check for the original untrusted text (e.g. `INJECTION_FILENAME` or `ApprovedBackdoor`) rather than repeating the redacted-marker string.
  • Double check (outside this diff) that every caller which builds the AI prompt from `SafetyReviewInput`/`defangReviewInput` output actually consumes the returned `impactMapContext` rather than a separately-held raw impact-map string, since that wiring isn't visible in this diff.

Concerns raised — review before merging

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.
Signal Result Evidence
Code review ❌ 2 blockers 1 reviewer
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (no linked issue context).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 51 registered-repo PR(s), 43 merged, 343 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 51 PR(s), 343 issue(s).
Gate result ❌ Blocking Repo-configured hard blocker found.
Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Python, TypeScript, JavaScript, Ruby, Go, Kotlin, MDX, Shell
  • Official Gittensor activity: 51 PR(s), 343 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Explain no-issue PR.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
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.

🟩 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 Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.66%. Comparing base (1ce4364) to head (d660226).
⚠️ Report is 16 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3958   +/-   ##
=======================================
  Coverage   93.66%   93.66%           
=======================================
  Files         372      372           
  Lines       34856    34857    +1     
  Branches    12743    12744    +1     
=======================================
+ Hits        32649    32650    +1     
  Misses       1588     1588           
  Partials      619      619           
Files with missing lines Coverage Δ
src/review/safety.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 7, 2026
@JSONbored
JSONbored merged commit 6ed503e into main Jul 7, 2026
10 checks passed
@JSONbored
JSONbored deleted the codex/fix-impact-map-prompt-injection-vulnerability branch July 7, 2026 08:02
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. manual-review Gittensor contributor context

Development

Successfully merging this pull request may close these issues.

1 participant