arXiv:2511.16209cs.CRcs.CL2025-11中稿 · AAAI被引 1

用AI优化生成防护层,让大模型提示词更难被窃取。

PSM: Prompt Sensitivity Minimization via LLM-Guided Black-Box Optimization

  • 通过大模型搜索最优防护文本,自动加固系统提示词
  • 在保持任务效果的前提下,显著降低提示信息泄露风险
  • 无需源码,仅需API调用,适合实际部署场景

系统提示词对大型语言模型的行为至关重要,但常包含敏感或专有逻辑,易受提取攻击。现有防御方法多依赖启发式规则,计算开销大,或不适用于黑盒API访问的模型。本文提出一种轻量级框架——通过在原始提示词后添加防护层(SHIELD)来增强安全性。核心是将提示词加固建模为效用约束下的优化问题:利用大模型作为优化器,在候选防护文本空间中搜索,以最小化基于多种对抗性攻击的泄漏度量,同时确保任务效用不低于阈值(通过与基线输出的语义保真度衡量)。该方法完全黑盒,仅需目标模型和优化器大模型的API访问权限。实验表明,优化后的防护层能有效抵御多种提取攻击,优于已有基准防御,且不影响模型正常功能。本工作为应对日益严峻的大模型安全威胁提供了实用、可扩展的防御范式。代码已开源:https://github.com/psm-defense/psm

原文摘要 · Abstract (English)

System prompts are critical for guiding the behavior of Large Language Models (LLMs), yet they often contain proprietary logic or sensitive information, making them a prime target for extraction attacks. Adversarial queries can successfully elicit these hidden instructions, posing significant security and privacy risks. Existing defense mechanisms frequently rely on heuristics, incur substantial computational overhead, or are inapplicable to models accessed via black-box APIs. This paper introduces a novel framework for hardening system prompts through shield appending, a lightweight approach that adds a protective textual layer to the original prompt. Our core contribution is the formalization of prompt hardening as a utility-constrained optimization problem. We leverage an LLM-as-optimizer to search the space of possible SHIELDs, seeking to minimize a leakage metric derived from a suite of adversarial attacks, while simultaneously preserving task utility above a specified threshold, measured by semantic fidelity to baseline outputs. This black-box, optimization-driven methodology is lightweight and practical, requiring only API access to the target and optimizer LLMs. We demonstrate empirically that our optimized SHIELDs significantly reduce prompt leakage against a comprehensive set of extraction attacks, outperforming established baseline defenses without compromising the model's intended functionality. Our work presents a paradigm for developing robust, utility-aware defenses in the escalating landscape of LLM security. The code is made public on the following link: https://github.com/psm-defense/psm

LLM安全提示词防御黑盒优化

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