Appeng 5697 - #322
Merged
Merged
Conversation
Collaborator
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Collaborator
Author
|
/test-heavy |
3 similar comments
Collaborator
Author
|
/test-heavy |
Collaborator
Author
|
/test-heavy |
Collaborator
Author
|
/test-heavy |
… routing prompts Closes the Phase 4 gap in the prompt injection defense plan by adding the shared security instructions block to the dispatcher routing, reachability classification, package filter, and comprehension prompts.
tmihalac
approved these changes
Aug 5, 2026
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
[APPENG-5697] [T-005] LLM Prompt Injection via Attacker-Controlled CVE Intelligence and Repository Content (Severity: Important, R-003, CTRL-010).
ExploitIQ feeds untrusted content into LLM prompts — CVE intel (NVD/GHSA/Ubuntu), SERP results, target-repo tool output, and patch diffs — with no boundary between data and instructions. An attacker who controls those sources can try to override the agent’s task and manipulate structured outputs / tool inputs (OWASP LLM Top 10 #1).
This PR implements a narrow, execution-route defense: separate untrusted data from instructions, escape delimiter breakouts, and rely on existing Pydantic/
with_structured_outputschema enforcement. It does not add a large prompt-injection signature database.READ ONLY DATAwraps.SECURITY_INSTRUCTIONS_BLOCKacross agent and scoring prompts.Problem
CVE intel enters prompts via
build_critical_context/ agentpre_process; SERP and source tools inject observations directly; there was no sanitization or boundary enforcement on untrusted blobs before LLM calls.Approach
--- READ ONLY DATA START/END [UUID] ---(UUID per call)```and</>before wrapping<SECURITY_INSTRUCTIONS>so the model treats wrapped text as analysis data only.format(...)Changes
1.
sanitization.py— shared utilitysanitize_untrusted_input()— neutralize markdown fences and angle bracketswrap_untrusted_data()— sanitize + UUID boundary markersSECURITY_INSTRUCTIONS_BLOCK— imported by prompt sites2. Intel pipeline & SERP (Phase 3)
[wrapped]in agent state3. Prompt hardening (Phases 2 / 4)
SECURITY_INSTRUCTIONS_BLOCKadded to reachability/CU system prompts, dispatcher routing, classification, package filter, comprehension, intel scoring, checklist, and RPM checker prompts.4. Code & agent observations — Narrow scope (Phases 5–6)
Wrap at LLM prompt assembly only:
{tool_output}{raw_patch_diff}Left plain (by design):
ToolMessage.content, observation memory/results, thought-node KNOWLEDGE (already distilled; prefix logic needs plain strings).Deferred / Out of Scope
runtime_promptFILE_CHANGES / vulnerability-intel wrap (full scope)Testing
src/vuln_analysis/utils/tests/test_sanitization.py— sanitize + wrap boundariessrc/vuln_analysis/functions/tests/test_react_internals_pattern_match.py— security block presencesrc/vuln_analysis/utils/tests/test_patch_analysis_prompt.py— wrap / fence escape / truncation still wrapstests/test_base_graph_agent.py— comprehension wraps; deterministic post-observation paths stay plainREAD ONLY DATAwrap; package filter / Go OSV enrichment still work; structured output unaffectedFiles Changed
utils/sanitization.pyutils/tests/test_sanitization.pyutils/checklist_prompt_generator.py,intel_source_score.py,serp_api_wrapper.py,rpm_checker_prompts.pyfunctions/reachability_agent.py,code_understanding_agent.py,cve_agent.py,dispatcher.py,react_internals.pyfunctions/base_graph_agent.py,cve_package_code_agent.py,cve_build_agent.py,code_agent_graph_defs.pytests/test_base_graph_agent.py,utils/tests/test_patch_analysis_prompt.py,functions/tests/test_react_internals_pattern_match.pyTest plan
READ ONLY DATA START/END [UUID]around critical context and tool output; security instructions in system/comprehension promptswith_structured_output)