用微调方法增强大模型抗提示注入攻击能力,但仍有漏洞。
Securing Large Language Models (LLMs) from Prompt Injection Attacks
- 通过任务特化微调让模型专注单一功能,降低被误导风险。
- 实验显示防御仍可被多语言和代码类攻击绕过,成功率未归零。
- 性能越好越易受攻击,需多层防护策略应对复杂威胁。
大型语言模型(LLMs)在实际应用中日益普及,但其灵活性使其面临提示注入攻击的威胁。这类攻击利用模型遵循指令的能力,诱导其执行恶意任务。近期工作提出JATMO方法,通过微调非指令训练的基础模型以执行单一功能,从而降低对对抗性指令的敏感性。本研究评估了JATMO在面对HOUYI——一种系统性变异并优化对抗性提示的遗传攻击框架——时的鲁棒性。我们改进了HOUYI,引入自定义评分机制、修改突变逻辑,并设计本地模型测试新框架,以更准确评估防御效果。在LLaMA 2-7B、Qwen1.5-4B和Qwen1.5-0.5B模型上采用JATMO方法进行微调,并与微调后的GPT-3.5-Turbo基线对比。结果表明,尽管相比指令微调模型,JATMO降低了攻击成功率,但未能完全防止注入;攻击者仍可通过多语言线索或代码相关干扰绕过防御。同时观察到生成质量与注入脆弱性之间存在权衡,即任务表现越好,越容易受到攻击。研究揭示了基于微调防御的潜力与局限,强调需要多层次、对抗性驱动的缓解策略。
原文摘要 · Abstract (English)
Large Language Models (LLMs) are increasingly being deployed in real-world applications, but their flexibility exposes them to prompt injection attacks. These attacks leverage the model's instruction-following ability to make it perform malicious tasks. Recent work has proposed JATMO, a task-specific fine-tuning approach that trains non-instruction-tuned base models to perform a single function, thereby reducing susceptibility to adversarial instructions. In this study, we evaluate the robustness of JATMO against HOUYI, a genetic attack framework that systematically mutates and optimizes adversarial prompts. We adapt HOUYI by introducing custom fitness scoring, modified mutation logic, and a new harness for local model testing, enabling a more accurate assessment of defense effectiveness. We fine-tuned LLaMA 2-7B, Qwen1.5-4B, and Qwen1.5-0.5B models under the JATMO methodology and compared them with a fine-tuned GPT-3.5-Turbo baseline. Results show that while JATMO reduces attack success rates relative to instruction-tuned models, it does not fully prevent injections; adversaries exploiting multilingual cues or code-related disruptors still bypass defenses. We also observe a trade-off between generation quality and injection vulnerability, suggesting that better task performance often correlates with increased susceptibility. Our results highlight both the promise and limitations of fine-tuning-based defenses and point toward the need for layered, adversarially informed mitigation strategies.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。