Defend Copilot against prompt injection#354
Conversation
Wrap user-supplied issue titles and bodies in <user_content> delimiters in Copilot instructions to prevent prompt injection. Sanitize and truncate issue titles before passing to Copilot. Always include a requirement prohibiting dependency changes. Add tests to verify structural separation, sanitization, and dependency constraints. In escalation logic, prevent re-escalation of already escalated issues and surface them in reports.
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Snapshot WarningsEnsure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice. Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
This PR hardens the AutoTriage → Copilot instruction pipeline against prompt injection by structurally separating user-supplied issue content, sanitizing/truncating issue titles before they reach Copilot, enforcing a “no dependency changes” constraint in every Copilot invocation, and improving SLA escalation reporting by avoiding repeated escalations.
Changes:
- Wrap issue title/body in
<user_content>delimiters in Copilot instructions and add an explicit “treat as data” warning plus a dependency-change prohibition. - Sanitize + truncate issue titles (in addition to bodies) before generating Copilot instructions; add tests for sanitization and delimiter structure.
- Update escalation logic to detect already-escalated issues, avoid re-escalation, and surface them separately in escalation results.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| autoTriage/services/copilot_service.py | Adds <user_content> structural separation and a universal dependency-change prohibition in instructions. |
| autoTriage/services/intake_service.py | Sanitizes/truncates issue titles before passing them into Copilot instructions. |
| autoTriage/services/escalation_service.py | Adds “already escalated” detection and includes those issues in results without re-escalating. |
| autoTriage/tests/services/test_copilot_service.py | Adds tests asserting <user_content> delimiting and dependency constraint presence. |
| autoTriage/tests/services/test_intake_service.py | Adds tests asserting issue title sanitization occurs before calling Copilot. |
Clarify that both user-supplied and LLM-derived fix suggestions are untrusted and must be structurally separated from trusted Copilot instructions; update <user_content> block to wrap both. Add tests to ensure fix_suggestions are inside <user_content>. In EscalationService, round hours_open for already-escalated issues and add comprehensive tests for already-escalated detection, label handling, and reporting. Ensure already-escalated issues are counted separately from new breaches in escalation checks.
MSRC Case 112249 — Suggested Security FixesAnalyzed against MSRC security requirements. The following corrections are recommended: Security requirements addressed
|
Wrap user-supplied issue titles and bodies in <user_content> delimiters in Copilot instructions to prevent prompt injection. Sanitize and truncate issue titles before passing to Copilot. Always include a requirement prohibiting dependency changes. Add tests to verify structural separation, sanitization, and dependency constraints. In escalation logic, prevent re-escalation of already escalated issues and surface them in reports.