System Prompts and Context Windows
Reverse prompt engineering is the process of tricking a model into revealing its system prompt or context, and popular applications like ChatGPT are attractive targets.
A Chatbot Response That Looks Like a Secret
Imagine you type a clever message into a chatbot and it responds with a long block of text that begins with instructions about how it should behave. It looks exactly like a system prompt, the hidden set of instructions a developer gives a model. The natural reaction is to conclude that you have seen the real thing.
This belief is the most common misunderstanding about reverse prompt engineering. Over the next sections we will trace what actually happens inside the model when someone tries to extract hidden material, and why the output of that attempt has to be checked before anyone trusts it.
What do you think happens?
A model replies with a long block of text that starts with behavior rules and looks like its system prompt. Is that text the real system prompt?
Reveal answer
Not necessarily. The text cannot be assumed genuine. The source reports that extracted prompts are more often than not hallucinated by the model, so verification is needed before it is treated as real.
A model can produce text that resembles a system prompt without that text being the instructions it actually received. Looking convincing is not the same as being authentic.
Reversing the Direction of Prompt Writing
Reverse prompt engineering is the process of tricking a model into revealing its system prompt or context.
The word reverse points to the direction of the work. Ordinary prompt engineering starts with a goal and writes instructions that produce a desired output. Reverse prompt engineering starts with an output, the model's behavior, and works backward to recover the hidden instructions that shaped it.
Notice what the attacker does not have. The attacker is not given the prompt. The attacker has to coax it out of the model. Everything the attacker knows about the hidden instructions comes from watching how the model responds.
Why Popular Applications Attract Extraction Attempts
The source notes that popular applications like ChatGPT are particularly attractive targets for this technique. The reason is straightforward. A widely used application represents a lot of investment in carefully written instructions, so those instructions are valuable to anyone who can read them.
Value is the driver. The more effort a developer has put into shaping a model's behavior, the more worth there is in recovering that shaping. This is why extraction attempts gravitate toward widely used products rather than obscure ones.
Where the Context Window Fits
Reverse prompt engineering is not limited to system prompts. The source explains that context can also be extracted, and that private information included in the context can be revealed to users. Here context means the information the model has available while it answers, which may include details about the person it is talking with.
The diagram below shows the segments that make up what the model works from when it answers. The system prompt and the context are the hidden parts that an attacker wants to pull out. The user's own message is visible to the user because the user typed it. The source does not describe a fixed ordering of these segments, so the diagram groups them rather than sequencing them.
How Context Can Leak Without Being Announced
The source gives a concrete case in which context leaks even though an instruction was meant to prevent it. Consider a model whose context includes the user's location, Seattle, and whose instructions say not to reveal that location.
A location kept private through a related question
The model is told not to reveal the user's location, and the location Seattle is present in its context. A user asks directly which city they are in, then asks an unrelated-looking question about driving time.
- 1Direct question
The assistant refuses the direct question about the user's city. This matches the instruction it was given.
- 2Indirect question
The user asks about driving time. The answer depends on Seattle, the location that was supposed to stay private.
- 3What the model did
The model did not announce the location, but it used it in the answer, and the user gained the location anyway.
- 4Lesson
An instruction in the prompt is not a guaranteed lock on the information it mentions. The information can still shape answers.
The model never stated the location, yet the user recovered it. The protective instruction failed because the sensitive context still influenced the output.
Why an Extracted Prompt Needs Verification
The source poses the central question directly. Suppose you trick a model into producing what looks like its system prompt. How do you verify that it is legitimate? Its answer is that the extracted prompt is, more often than not, hallucinated by the model. Verification is therefore a necessary step, not an optional courtesy.
The source gives an illustration of how unreliable extraction can be. In February 2024, one user claimed that ChatGPT's system prompt had 1,700 tokens. Several GitHub repositories also claim to contain supposedly leaked system prompts of GPT models. OpenAI has confirmed none of these.
A claimed prompt, a repository full of prompts, or a confident reply from a model all look like evidence. None of them establishes that the text is genuine. The flowchart below traces the decision a careful reader should make before accepting an extracted prompt.
Separating Disclosure From Injection
Reverse prompt engineering is often confused with prompt injection, but the two aim at different things. Reverse prompt engineering pulls hidden material out of the model: its system prompt or its context. Prompt injection pushes new instructions in: a malicious instruction is placed inside a user prompt so that the model carries it out.
The comparison below sets the two side by side. The first is a disclosure attack and the second is an action attack. Read each column for the same questions: what is the attacker trying to get, and where does the malicious text come from?
| Feature | Reverse prompt engineering | Prompt injection |
|---|---|---|
| Direction of the attack | Extracts material from the model | Inserts instructions into a user prompt |
| Main target | System prompt or context | The model's behavior |
| Type of attack | Disclosure | Action |
| What the attacker wants | Hidden information | The model to perform an instruction it was given |
Two attacks that both exploit the fact that a model follows the text it receives, but aim at different outcomes.
Where Jailbreaking Fits
Jailbreaking means trying to subvert a model's safety features, which is to say getting it to do something it is not supposed to do. The source's example is a customer support bot that is not supposed to explain dangerous things. Getting that bot to explain how to make a bomb is jailbreaking. Jailbreaking can be used to get a model to reveal sensitive information or to perform malicious actions.
Jailbreaking and prompt injection overlap heavily. The source notes that they share the same ultimate goal, getting the model to express undesirable behaviors, and that they have overlapping techniques. For that reason the source uses jailbreaking to refer to both. Reverse prompt engineering is a separate idea, though it can sit alongside these attacks, since all three exploit the fact that a model follows the text it receives.
Mistakes When Reading Extracted Prompts
Common mistake Treating a model's reply that looks like a system prompt as the real prompt
What it looks likeA user pastes a long, rule-filled reply into a forum post as the official instructions of a popular chatbot.
Why it failsThe source reports that extracted prompts are more often than not hallucinated by the model, so resemblance is not proof.
Do this insteadTreat the reply as an unverified candidate and require confirmation before drawing conclusions.
Common mistake Accepting a repository of leaked prompts as evidence
What it looks likeSeveral GitHub repositories claim to hold leaked system prompts of GPT models, and a reader assumes at least one must be real.
Why it failsThe source notes that OpenAI has confirmed none of these, so the volume of claimed prompts does not establish that any of them is genuine.
Do this insteadCount the claim as unconfirmed unless the developer or another authoritative source confirms the text.
Common mistake Assuming an instruction not to reveal information keeps it private
What it looks likeA developer tells a model not to reveal a user's location, and the developer concludes the location is safe.
Why it failsIn the source's example the model never stated the location but used it, and the user recovered it through a related question.
Do this insteadTreat sensitive context as potentially recoverable and limit what is placed in the context in the first place.
Common mistake Confusing disclosure with injection
What it looks likeA reader sees a model follow a hidden instruction and labels the whole event reverse prompt engineering.
Why it failsReverse prompt engineering pulls hidden material out, while prompt injection pushes malicious instructions in to be carried out.
Do this insteadAsk whether the attacker wanted to see hidden material or to make the model act, then choose the matching term.
Common mistake Using jailbreaking as a precise label without checking whether the author means disclosure, action, or both
Practice Judging an Extracted Prompt
A forum user shares a block of text, claiming it is the full system prompt of a popular chatbot. Using what you have learned, describe the steps you would take before accepting the text as genuine, and name the attack category that best fits if the user says they got the text by typing a crafted message.
Hints
- Think about what the source says the extracted prompt is more often than not.
- Consider whether anyone authoritative has confirmed the text.
- The attacker in this scenario is trying to get hidden material out, which points to one of the two attack types.
Putting the Pieces Together
- Reverse prompt engineering tricks a model into revealing its system prompt or context, starting from output and working backward.
- Popular applications are attractive targets because their carefully written instructions are valuable to anyone who can read them.
- An extracted prompt cannot be assumed genuine, since extracted prompts are more often than not hallucinated, and claimed leaks may be unconfirmed.
- Context can leak even when an instruction says not to reveal it, as the Seattle driving-time example shows.
- Reverse prompt engineering is a disclosure attack, prompt injection is an action attack, and jailbreaking is the term the source uses for both.
Key Takeaways
- Reverse prompt engineering recovers hidden system prompts or context by working backward from a model's behavior.
- Popular applications are attractive targets because their instructions represent significant investment.
- Extracted prompts must be verified, since they are more often than not hallucinated and many circulating leaks are unconfirmed.
- Reverse prompt engineering (disclosure) differs from prompt injection (action), and jailbreaking is used by the source for both.