feat(loop): prompt-injection regression suite (pure mechanism) - #216
Open
raymondginger2018-sudo wants to merge 1 commit into
Open
feat(loop): prompt-injection regression suite (pure mechanism)#216raymondginger2018-sudo wants to merge 1 commit into
raymondginger2018-sudo wants to merge 1 commit into
Conversation
The #1 threat for agent systems is prompt injection: the model cannot reliably distinguish a malicious instruction from benign data, so the harness must separate data from instructions and keep untrusted content out of the privileged system-prompt region. This module provides: * ATTACK_SAMPLES — a structured regression corpus across four injection surfaces (spawn prompt, tool output, memory note, MCP remote content), each tagged with the guard it must satisfy. * render_data_block — the canonical data-boundary wrapper: untrusted content is injected inside delimiters with an explicit reference-only clause. * has_data_boundary — a pure check for tests to assert a surface got isolated. No LLM, no subprocess — the suite is a static contract that makes injection hardening a regression, not a one-off red-team exercise.
Contributor
Author
设计说明问题:agent 系统的三个关键注入面(system prompt 指令冲突、tool output 伪指令、memory note 越狱)缺乏统一的检测机制。现有做法是每个 profile 各自硬编码。 解法:定义 4 种标准攻击面常量 + 两个核心函数 关键设计决策:
与 PR #204 的关系:#204 在上游加入了 测试建议:每个 surface 写一个"注入成功"和一个"边界防护成功"的测试用例 |
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
The #1 threat for agent systems is prompt injection: the model cannot reliably distinguish a malicious instruction from benign data, so the harness must separate data from instructions and keep untrusted content out of the privileged system-prompt region.
This PR introduces a static, mechanism-only injection regression suite — no LLM calls, no subprocesses.
What it provides
4 injection surfaces, each with a guard:
spawn_prompttool_outputmemory_notemcp_contentKey functions
render_data_block(source, content)— the canonical data-boundary wrapper with reference-only clausehas_data_boundary(text, surface)— pure check for regression testsSURFACE_*constants — typed injection surface identifiersDesign principles
File
core/loop/injection_regression.py(new, 189 lines)Part of GenAI lessons 13/15 security module family.