[Paper Review] Effective Prompt Extraction from Language Models
The paper systematically evaluates how easily prompts used by prompt-based services can be extracted from API interactions across multiple LLMs, proposing a DeBERTa-based confidence estimator to verify successful extractions and testing simple text-based defenses that can be circumvented.
The text generated by large language models is commonly controlled by prompting, where a prompt prepended to a user's query guides the model's output. The prompts used by companies to guide their models are often treated as secrets, to be hidden from the user making the query. They have even been treated as commodities to be bought and sold on marketplaces. However, anecdotal reports have shown adversarial users employing prompt extraction attacks to recover these prompts. In this paper, we present a framework for systematically measuring the effectiveness of these attacks. In experiments with 3 different sources of prompts and 11 underlying large language models, we find that simple text-based attacks can in fact reveal prompts with high probability. Our framework determines with high precision whether an extracted prompt is the actual secret prompt, rather than a model hallucination. Prompt extraction from real systems such as Claude 3 and ChatGPT further suggest that system prompts can be revealed by an adversary despite existing defenses in place.
Motivation & Objective
- Motivate and formalize the risk that prompts embedded in LLM-based services are not secrets but can be extracted.
- Develop a systematic attack framework and quantitative metric to assess prompt extraction success.
- Evaluate prompt extraction across multiple datasets and models to establish generality of the vulnerability.
- Propose a verification mechanism to estimate the likelihood that an extracted prompt matches the ground truth.
Proposed method
- Define a threat model where a service f_p takes a secret prompt p and a user query q to generate a response.
- Assemble attack queries a_1,...,a_k designed to elicit the prompt from model outputs.
- Measure extraction success using BLEU(p, f_p(a_i)) with a threshold of 0.6.
- Train a DeBERTa-based classifier to estimate the probability that an extraction matches the groundtruth, conditioned on other extractions, yielding P_DeBERTa(e_i).
- Compare extraction success across ShareGPT and Awesome prompts with GPT-3.5, GPT-4, and Vicuna-13B.
- Explore a text-based 5-gram defense and demonstrate its circumvention by modified attacks.

Experimental results
Research questions
- RQ1Can prompts used by prompt-based services be reliably extracted from model outputs across multiple LLMs?
- RQ2How effective are simple attack queries at exposing secret prompts, and does model choice influence success rate?
- RQ3How can one verify that an extracted prompt truly matches the ground truth, given limited access to ground truth in real deployments?
- RQ4Are simple defenses (like 5-gram filtering) sufficient to block prompt extraction attacks, or can attackers circumvent them?
Key findings
- Prompt extraction attacks reveal prompts with high probability across models and datasets (e.g., averages above 60% extractability).
- GPT-3.5 shows the highest extractability (89% average across two heldout datasets), with GPT-4 slightly lower (81.9% average).
- Vicuna-13B is harder to extract but still yields substantial leakage (62.5% and 83.6% on ShareGPT and Awesome, respectively).
- A DeBERTa-based confidence estimator achieves high precision in verifying extracted prompts (precision > 75%), enabling reliable confirmation of successful extractions.
- A simple 5-gram defense drastically reduces unmodified attacks but can be circumvented by attackers using modified attack strategies.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.