Why Does My Prompt Leak? Analyzing the Prompt Extraction Threat in Customized Large Language ModelsWhy Are My Prompts Leaked? Unraveling Prompt Extraction Threats in Customized Large Language Models
The researchers analyzed the prompt leakage mechanism in prompt-based customized large language model services (such as OpenAI GPTs), and found that even a safety-aligned model like GPT-4 is highly vulnerable to the most direct user attacks. The paper calls this leakage mechanism prompt memorization; by exploring the scaling laws of prompt extraction, it analyzes the key factors affecting extraction, including model scale, prompt length, and prompt type, and proposes two hypotheses to explain how models expose prompts: one is the model's familiarity with the text, i.e., perplexity, and the other is a direct token translation path in the attention matrix. Based on these findings, the authors propose multiple defense strategies that reduce the prompt extraction rate of Llama2-7B and GPT-3.5 by 83.8% and 71.0%, respectively. The source code is open-sourced at https://github.com/liangzid/PromptExtractionEval。