arXiv:2511.19727cs.CRcs.AI2025-11被引 2

用密码学方法在提示词中加安全边界,防注入攻击

Prompt Fencing: A Cryptographic Approach to Establishing Security Boundaries in Large Language Model Prompts

  • 给提示词段落添加带签名的可信度和类型元数据
  • 实验中将攻击成功率从86.7%降至0%
  • 适合关注LLM安全的开发者和系统架构师

大型语言模型(LLMs)仍易受提示注入攻击,是生产部署中最大的安全威胁。我们提出Prompt Fencing,一种新型架构方法,运用密码学认证与数据架构原理,在提示词中建立明确的安全边界。该方法为提示词片段添加加密签名的元数据,包括可信度评分和内容类型,使LLM能区分可信指令与不可信内容。尽管当前LLM缺乏原生的边界感知能力,我们通过提示指令模拟感知,在300个测试用例中实现完全防御,将攻击成功率从86.7%(260/300)降至0%(0/300),覆盖两家主流LLM提供商。我们实现了一个概念验证的围栏生成与验证流水线,100个样本总开销为0.224秒(生成0.130秒,验证0.094秒)。该方法平台无关,可作为安全层逐步部署于现有LLM基础设施之上,未来模型若具备原生围栏感知能力,将实现更优安全效果。

原文摘要 · Abstract (English)

Large Language Models (LLMs) remain vulnerable to prompt injection attacks, representing the most significant security threat in production deployments. We present Prompt Fencing, a novel architectural approach that applies cryptographic authentication and data architecture principles to establish explicit security boundaries within LLM prompts. Our approach decorates prompt segments with cryptographically signed metadata including trust ratings and content types, enabling LLMs to distinguish between trusted instructions and untrusted content. While current LLMs lack native fence awareness, we demonstrate that simulated awareness through prompt instructions achieved complete prevention of injection attacks in our experiments, reducing success rates from 86.7% (260/300 successful attacks) to 0% (0/300 successful attacks) across 300 test cases with two leading LLM providers. We implement a proof-of-concept fence generation and verification pipeline with a total overhead of 0.224 seconds (0.130s for fence generation, 0.094s for validation) across 100 samples. Our approach is platform-agnostic and can be incrementally deployed as a security layer above existing LLM infrastructure, with the expectation that future models will be trained with native fence awareness for optimal security.

LLM安全提示注入密码学

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。