[论文解读] Prompt Stealing Attacks Against Large Language Models
论文提出利用参数提取器和提示重构器对LLM进行提示窃取攻击,以推断并从生成的回答中反推出原始提示,并有实验在 ChatGPT 和 LLaMA 上显示出强劲性能。
The increasing reliance on large language models (LLMs) such as ChatGPT in various fields emphasizes the importance of ``prompt engineering,'' a technology to improve the quality of model outputs. With companies investing significantly in expert prompt engineers and educational resources rising to meet market demand, designing high-quality prompts has become an intriguing challenge. In this paper, we propose a novel attack against LLMs, named prompt stealing attacks. Our proposed prompt stealing attack aims to steal these well-designed prompts based on the generated answers. The prompt stealing attack contains two primary modules: the parameter extractor and the prompt reconstruction. The goal of the parameter extractor is to figure out the properties of the original prompts. We first observe that most prompts fall into one of three categories: direct prompt, role-based prompt, and in-context prompt. Our parameter extractor first tries to distinguish the type of prompts based on the generated answers. Then, it can further predict which role or how many contexts are used based on the types of prompts. Following the parameter extractor, the prompt reconstructor can be used to reconstruct the original prompts based on the generated answers and the extracted features. The final goal of the prompt reconstructor is to generate the reversed prompts, which are similar to the original prompts. Our experimental results show the remarkable performance of our proposed attacks. Our proposed attacks add a new dimension to the study of prompt engineering and call for more attention to the security issues on LLMs.
研究动机与目标
- 突出提示工程在 LLM 使用中的经济与安全影响。
- 提出一个两模块框架(参数提取器和提示重构器)以逆向工程原始提示。
- 在多个数据集和模型上评估攻击效果并与基线进行比较。
- 讨论防御策略及其局限性,同时强调 LLM 系统的安全性考虑。
提出的方法
- 使用一个主分类器和两个子分类器对提示类型进行分类(直接、基于角色、上下文内)。
- 在生成的回答上训练分类器以预测提示类别,并且对于基于角色的提示,预测具体角色,或者对上下文内提示,预测上下文数量。
- 使用 ChatGPT 根据提取的参数和上下文信息生成反向提示以重构提示。
- 使用 sentence-transformer 嵌入评估提示相似性(PS)和回答相似性(AS)。
- 在两个数据集(RetrievalQA 和 Alpaca-GPT4)以及两个 LLM(ChatGPT 和 LLaMA)上评估攻击。
- 提出两种防御以降低攻击效果并衡量其影响。

实验结果
研究问题
- RQ1是否可以从生成的回答中准确推断原始提示的类型?
- RQ2在推断出类型和参数后,原始提示的重构程度如何?
- RQ3防御策略是否显著降低提示窃取攻击的有效性,并且是否在不同模型/数据集上具有鲁棒性?
主要发现
- 主分类器在 RetrievalQA 上使用 ChatGPT 达到 0.833 的准确率,在 Alpaca-GPT4 上达到 0.811。
- 基于 LLaMA 的主分类器在 RetrievalQA 上达到 0.884,在 Alpaca-GPT4 上达到 0.855。
- 基于角色的子分类器在 RetrievalQA 上使用 ChatGPT 达到 0.732 的准确率(15 类任务)。
- 上下文内子分类器在上下文数量预测上达到 0.614 的准确率(4 类)。
- 提示重构达到较高的提示相似性(PS)和回答相似性(AS);对于直接提示使用 ChatGPT,PS=0.832,AS=0.768。
- 结合参数提取器引导可提升重构效果(例如,使用 RetrievalQA 的基于角色的提示,PS=0.803,AS=0.703)。
- 基线(无参数提取)表现显著较差,显示出分层预测的必要性。
- 防御策略降低相似性指标,但未能消除攻击有效性,表明鲁棒性。

阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。