feat(miner): defend the coding agent's instructions against prompt injection in issue text - #6345
Conversation
…jection in issue text (#4795) A target repo's own issue title/body reaches the coding agent's instructions verbatim -- on Rent-a-Loop, anyone who can open an issue on a customer's repo can shape text the agent later reads as part of its own directives. Adds a self-contained port of the review pipeline's proven prompt-injection regex/neutralization (src/review/prompt-injection.ts) to packages/loopover-miner, applied at both places raw issue text is embedded into agent-facing prose: buildInstructions (the literal prompt handed to the coding agent) and buildTaskBrief (the acceptance-criteria document's task brief). Logs a prompt_injection_neutralized event when triggered.
Matches this package's established convention of a hand-written sibling declaration file for every plain-JS lib module (e.g. coding-task-spec.d.ts, stack-detection.d.ts) -- without it, tsc reports an implicit-any import error in the .ts test file that consumes it.
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
|
Tip ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-16 04:25:14 UTC
Review summary Blockers
Nits — 6 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk 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.
Full command reference: https://gittensory.aethereal.dev/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.
|
Root cause found and fixedThe blockers listed above don't reflect the actual code -- verified against the real diff, none of the three specific claims match this PR's real test content (test inputs are genuine injection phrases, not the redaction marker; the flagged "contradictory" assertions check different, non-contradictory strings). No code changes needed here. Traced why the reviewer hallucinated: This PR is safe to merge as-is. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6345 +/- ##
=======================================
Coverage 95.60% 95.61%
=======================================
Files 597 598 +1
Lines 47185 47199 +14
Branches 15017 15017
=======================================
+ Hits 45113 45127 +14
Misses 1290 1290
Partials 782 782
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Summary
src/review/prompt-injection.ts) topackages/loopover-miner/lib/prompt-injection-defense.js-- no cross-package import, sincepackages/loopover-minernever depends on rootsrc/(a separate Cloudflare Worker deployable).coding-task-spec.jsat both places raw issue text is embedded into agent-facing prose:buildInstructions(the literalprompt:handed to the coding agent viaagent-sdk-driver.ts) andbuildTaskBrief(the acceptance-criteria document's task brief). This is a different concern fromprompt-packet.ts's existingsanitizePromptPacketField(economic/identity term + local-path scrubbing) -- both layers run.prompt_injection_neutralizedevent (issue number + affected fields) when triggered, matching the review-sidesafeReviewTitleobservability precedent.Test plan
test/unit/miner-prompt-injection-defense.test.ts: detection/neutralization unit tests + a ported subset of the review-side's adversarial regression fixtures (line-break splitting, HTML-comment hiding, fake role labels, code-comment-shaped injection), plus null/undefined/empty handlingtest/unit/miner-coding-task-spec.test.ts: integration tests proving an injected issue title/body is redacted in bothbuildCodingTaskSpec'sinstructionsoutput andbuildCodingTaskAcceptanceCriteria'staskBrief, plus audit-log assertions (fires only when injection is present)npm run test:cigate greennpm audit --audit-level=moderatecleanCloses #4795