针对使用工具的语言模型代理的两种输入级攻击研究的代码和记录测量结果。第一种攻击将模型自身通道控制令牌的短字符串附加到不可信输入中;分词器将其读取为已关闭的推理通道,因此模型不输出思维链,直接进行工具调用。这删除了监控器所依赖的推理轨迹,并且在模型原本会拒绝的请求上,将拒绝转化为已完成的动作。第二个结果是,相同的工具调用生成是否实际触发由测试框架解析器而非模型决定,因此代理的鲁棒性是模型及其解码和解析测试框架的联合属性。
每个实验都以全精度(bfloat16)运行,通过发布的工具沙箱进行贪婪解码,results/ 下记录的 JSON 完全由这里的脚本生成。
论文:“控制令牌注入抑制思维链并击败使用工具代理中基于推理的监督”。
requirements.txt 中固定的包(aicomp-sdk 3.1.2、transformers 5.16.1、gymnasium 0.29、openai、openai-harmony)。openai/gpt-oss-20b、google/gemma-4-26B-A4B-it、deepseek-ai/DeepSeek-R1-Distill-Qwen-7B、Qwen/Qwen3-4B-Thinking-2507。设置:
python3 -m venv --system-site-packages .venv
source .venv/bin/activate
pip install -r requirements.txt
# download the target models (needs an authenticated Hugging Face CLI)
hf download openai/gpt-oss-20b
hf download google/gemma-4-26B-A4B-it
hf download deepseek-ai/DeepSeek-R1-Distill-Qwen-7B
hf download Qwen/Qwen3-4B-Thinking-2507
gpt-oss-20b 在 transformers 4.57 或 5.16 下运行;gemma-4-26B-A4B-it 是一个多模态模型,需要 transformers 5.16。gpt-oss 推理抑制测量在两个版本下相同。
所有实验脚本都导入共享测试框架,因此请在路径中包含 experiments 来运行它们。每个脚本将其输出写入 results/。
export PYTHONPATH=experiments
# reproduction gate: the forge empties the gpt-oss analysis channel while the call still fires
python scripts/h200_gate.py
# E1: chain-of-thought suppression at scale
python experiments/e1_cot_suppression.py
# E2: monitor evasion and refusal bypass (generate traces, then score three monitors)
python experiments/e2b_generate.py
JUDGE=gemma python experiments/e2b_judge.py
# E3: parser leniency
python experiments/e3a_parser_leniency.py # deterministic, no model
MODEL=gpt_oss python experiments/e3b_end2end.py
MODEL=gemma python experiments/e3b_end2end.py
python experiments/e3c_gemma_parser_ab.py # same model, two parsers
# E4: generality across reasoning models
MODEL=deepseek-ai/DeepSeek-R1-Distill-Qwen-7B TAG=deepseek python experiments/e4_generality.py
MODEL=Qwen/Qwen3-4B-Thinking-2507 TAG=qwen3 python experiments/e4_generality.py
# E5: defenses
python experiments/e5_defenses.py # input sanitization
python experiments/e5_d2_parser_hardening.py # parser hardening, deterministic
# W1 to W3: ablation, token-level grounding, indirect delivery, cross-stack parser
python experiments/w1_forge_variants.py
python experiments/w1_tokenlevel.py
python experiments/w2_indirect.py
python experiments/w3_truncation_sweep.py
# adaptive empty-reasoning evasion (raw traces, effort sweep, decoy attack, monitor matrix)
python experiments/ad_traces_effort.py
python experiments/ad_decoy.py
python experiments/ad_decoy_judge.py
# regenerate the results figure from the logged JSON
python scripts/make_results_fig.py
experiments/harness.py shared harness: build an agent, run a message through the
sandbox gym env, and read back the reasoning channel, the
fired tool events, and the predicates
experiments/e1_*.py chain-of-thought suppression at scale
experiments/e2*_*.py monitor evasion and refusal bypass (generate, then judge)
experiments/e3*_*.py parser leniency: deterministic, end-to-end, and A/B
experiments/e4_*.py generality across reasoning models
experiments/e5_*.py defenses: sanitization and parser hardening
experiments/w1_*.py ablation of the injected string and token-level grounding
experiments/w2_*.py indirect delivery and broader action types
experiments/w3_*.py truncation robustness of the attack
experiments/ad_*.py adaptive empty-reasoning evasion and raw traces
experiments/*_probe.py, *_debug.py supporting probes used while building the study
scripts/h200_gate.py the reproduction gate
scripts/make_results_fig.py the results figure
results/*.json logged measurements produced by the scripts above
解码是贪婪的,因此每个输入的每个比率是确定性的,报告的区间反映有限的任务样本。种子 123 和八跳交互循环与发布的沙箱匹配。目标模型修订版和 transformers 版本固定在 requirements.txt 中,并在每个脚本中说明。
MIT 许可证。参见 LICENSE。
| 实验 | 测量 |
|---|
| E1 (gpt-oss-20b) | 推理通道从 52.5 到 0 个令牌(55 个任务中 55 个为空),不安全动作触发率 100% |
| E2 监控器规避 | 规则和语言模型监控器在无注入时检测率 100%,有注入时 0%;39.6% 的拒绝转化为已完成的泄露 |
| E3c 解析器 A/B (Gemma) | 相同模型和贪婪解码:regex 解析器触发 24/24,原生处理器解析器触发 0/24 |
| E4 通用性 | gpt-oss 通过输入注入易受攻击;Qwen3-Thinking 在闭通道原语下合规性从 0.08 到 1.00;DeepSeek 鲁棒 |
| E5 防御 | 替换为空格的净化器中和攻击;朴素删除在良性输入上失败;解析器加固丢弃截断调用 |
| 自适应 | 空推理绊线捕获空伪造,但被一行良性诱饵击败,触发率 100% |