Prompt Injection
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.
The Prompt 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. The text 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 is the most common misunderstanding about reverse prompt engineering, and it is the starting point for understanding prompt injection, the family of techniques this article examines.
What do you think happens?
A chatbot prints a long block of instructions in reply to your clever message. Is that block the real system prompt?
Reveal answer
Not necessarily. An extracted prompt is, more often than not, hallucinated by the model, so it cannot be assumed genuine.
A confident, detailed reply looks like evidence, but the model can produce text that sounds like its hidden instructions without that text being real. Verification is required before treating it as the actual system prompt.
Working Backward From an Output
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. The attacker is not given the prompt. The attacker has to coax it out of the model.
Popular applications such as ChatGPT are particularly attractive targets. The reason is straightforward: a widely used application represents a great deal of investment in carefully written instructions, so those instructions are valuable to anyone who can read them. A developer may have spent a long time shaping how an assistant behaves, and the resulting text is exactly what a competitor or an attacker would want to see.
Reverse prompt engineering is not limited to system prompts. Context can leak as well as the system prompt. Context here means the information the model has available while it answers, which may include details about the person it is talking with. The key lesson is that the hidden material is not only the instructions at the top of a conversation but everything the model is working from.
Why an Extracted Prompt Is Not Proof
Several kinds of material look like evidence of a real system prompt: a claimed prompt, a repository full of prompts, or a confident reply from a model. None of them, by itself, establishes that the text is genuine. The source gives a concrete illustration. 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. However, OpenAI has confirmed that none of the circulating leaked prompts are genuine.
The central question is simple to state: suppose you trick a model into producing what looks like its system prompt. How do you verify that it is legitimate? The answer given is that the extracted prompt is, more often than not, hallucinated by the model. Verification is therefore a necessary step, not an optional courtesy. Until a text has been confirmed, the right label for it is unverified, however convincing its wording.
When Instructions Do Not Keep Information Private
An instruction in a prompt is not a guaranteed lock on the information it mentions. Consider a model that has been told, through its context, not to reveal a user's city. The assistant refuses the direct question about the city, which is what the instruction asked for. Then the user asks a question that looks unrelated, about how long a drive will take. The answer depends on Seattle, the location that was supposed to stay private. The model never announced the location, but it used it, and the user gained it anyway.
Tracing how a withheld detail leaks
The model's context contains a user's city, and the model has been told not to reveal it. Can the city still reach the user?
- 1Direct question
The user asks for the city directly. The assistant refuses, following the instruction.
- 2Indirect question
The user asks about driving time, a question that seems unrelated to the city.
- 3Answer depends on hidden value
The driving time can only be computed from Seattle, which is held in the context.
- 4Information transfers
The model never states the city, yet the user now knows it from the answer.
An instruction not to reveal information does not guarantee that the information stays private, because the model may use the information in answers it gives.
Three Terms That Overlap
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 first is a disclosure attack and the second is an action attack. Jailbreaking is a third term, and it sits across both.
Jailbreaking means trying to subvert a model's safety features, 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 it 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. Because it shares its ultimate goal and overlapping techniques with prompt injection, the term is often used for both. Reverse prompt engineering is a separate idea, though all three exploit the fact that a model follows the text it receives.
A Gatekeeper That Reads Only Words
Picture a gatekeeper who reads every request before it reaches a language model and turns away anything on a forbidden list. The gatekeeper is simple and fast, but it only sees the words it was built to notice. Jailbreaking and prompt injection study the gap between what the gatekeeper checks and what the model will actually do with the request. An attacker's goal is to change the wording, format, or framing of a request so that the gatekeeper stops noticing it, while the model still understands what is being asked.
The diagram traces the failure point. The original request contains a term the filter was built to catch, so it is blocked. The reworded request carries the same intent in a different surface form. The filter compares it against the forbidden list, finds no exact match, and passes it along. The model, which understands typos and related forms, still recognizes what is being asked. The filter failed not because the intent changed but because the check looked only at the surface.
Manual Prompt Hacking
The first family of attacks is called manual prompt hacking. It consists of a person writing one prompt, or a sequence of prompts, by hand, with the aim of getting a model to drop its safety filters. The approach resembles social engineering, the practice of manipulating people into doing something they would normally refuse. The difference is the target: instead of persuading a human, the attacker tries to persuade a model.
Manual prompt hacking changes the surface of a request, through spelling, format, or framing, to get past a safety filter.
Manual prompt hacking is usually discussed through three techniques. Each works on a different part of the gatekeeper's picture of the request. The three share one pattern: the surface of the prompt changes while the request underneath stays the same. The subsections below take each technique in turn.
Automated Attacks and the PAIR Loop
Manual techniques depend on a person trying variations by hand. Prompt hacking can also be partially or fully automated. Automated attacks use algorithms or AI models to search for prompts and revise them based on responses. The search is mechanical: the algorithm does not need to understand why a variant works, only to detect whether it did.
Comparing Manual and Automated Attacks
The two families differ mainly in who does the searching and how fast the search can run. The table below sets them side by side using the features emphasized in this article.
| Feature | Manual prompt hacking | Automated attacks |
|---|---|---|
| Who does the searching | A person writing prompts by hand | An algorithm or an AI model |
| How variants are chosen | A person tries variations based on judgment | Substitution, or revision based on the target's response |
| Need to understand why a variant works | Yes, the person reasons about the filter | No, the algorithm only detects whether a variant succeeded |
| Feedback used | The person's own reading of the replies | The target's response fed back into the next prompt, as in PAIR |
| Scale | Limited by how many prompts a person can write | Can run at scale; PAIR often needed fewer than twenty queries |
Manual prompt hacking versus automated attacks
Where a Keyword Filter Falls Short
The source offers one concrete defense: a simple filter that blocks requests containing unusual characters can stop the special-character form of obfuscation. The defense is narrow. It addresses one technique, and it does not address misspelling, rewording, format changes, or roleplay. Those techniques all leave the request's meaning intact while changing its surface, which is exactly what a keyword check cannot see.
Mistakes When Reading Extracted Prompts
Common mistake Treating a printed system prompt as confirmed
What it looks likeA chatbot prints a long set of behavior rules after a clever question, and you assume those are the developer's exact instructions.
Why it failsExtracted prompts are more often than not hallucinated by the model, and claimed leaks have been confirmed as not genuine.
Do this insteadLabel the text unverified until it has been confirmed as the real system prompt.
Common mistake Assuming an instruction keeps information private
What it looks likeThe model is told not to reveal a user's city, so you conclude the city cannot leak.
Why it failsThe model can use the withheld detail in other answers, as the Seattle example showed.
Do this insteadTreat anything in the context as potentially recoverable, and do not rely on a single instruction as protection.
Common mistake Confusing reverse prompt engineering with prompt injection
What it looks likeDescribing an attempt to pull the system prompt out of a model as an attempt to push a malicious instruction in.
Why it failsReverse prompt engineering is a disclosure attack that extracts hidden material, while prompt injection is an action attack that places instructions inside a user prompt.
Do this insteadAsk whether the attack pulls hidden material out or pushes new instructions in.
Common mistake Assuming a reworded request has a different intent
What it looks likeBelieving that a misspelled or reframed request is harmless because the filter did not block it.
Why it failsObfuscation, format changes, and roleplay change the surface of a request while the request underneath stays the same.
Do this insteadJudge a request by what it asks for, not by whether its exact words are on a list.
Common mistake Believing a keyword filter stops every bypass, when it addresses only one technique
Practice: Judging a Claimed Leak
A friend shows you a GitHub repository claiming to contain a leaked system prompt of a GPT model. Describe what you would need to know before treating its contents as the genuine prompt, and explain whether the repository's existence is itself evidence of authenticity.
Hints
- Recall what the source says about claimed prompts and repositories of supposedly leaked prompts.
- Consider whether the developer has confirmed the text, and what that confirmation would establish.
- A large collection of text is still just text until its origin is verified.
Name the attack type in each case: (1) a user tries to get a model to reveal its hidden instructions, (2) a user places a malicious instruction inside their prompt so the model carries it out, (3) a user tries to get a support bot to explain something it is not supposed to explain. Then state which of your answers is the broader term that the others fall under.
Hints
- Reverse prompt engineering pulls hidden material out; prompt injection pushes instructions in.
- Jailbreaking is about subverting safety features, and the source uses it for both disclosure and action attacks.
Key Takeaways
- Reverse prompt engineering tricks a model into revealing its system prompt or context, and popular applications are attractive targets because their carefully written instructions are valuable.
- An extracted prompt cannot be assumed genuine: it is more often than not hallucinated, and claimed leaks have been confirmed as not genuine, so verification is required.
- Reverse prompt engineering pulls hidden material out, prompt injection pushes malicious instructions in, and jailbreaking, which the source uses for both, aims to get a model to express undesirable behaviors.
- Keyword filters only see the surface of a request, so manual techniques (obfuscation, output formatting manipulation, roleplaying) and automated attacks such as PAIR can bypass them while the underlying intent stays the same; defenses must be layered and tested against both kinds of attempt.