Cybersecurity 4 min read

Prompt Injection: Security Risks When AI Reads Untrusted Data

Understand direct and indirect prompt injection, why AI agents are vulnerable, and practical layered defences for applications that read untrusted content.

Tangkapan layar contoh instruksi prompt injection yang mencoba memengaruhi keluaran model bahasa.

Prompt injection is a security risk that appears when an AI application treats untrusted content as instructions. Imagine asking an assistant to summarise a document, only for hidden text inside that document to tell the assistant to disclose private information. The model may follow that instruction if the application does not clearly separate trusted directions from external data.

Unlike a conventional exploit, prompt injection does not necessarily break into an operating system or database. It targets the way a language model interprets a combined stream of system instructions, user messages, retrieved web pages, emails, PDFs, and tool outputs. The risk becomes more serious when an AI agent can send messages, call APIs, or access internal files.

Why Prompt Injection Happens

Traditional software can keep executable code separate from user data. Large language models do not enforce the same boundary by default: instructions and quoted content are processed as tokens in one context. A sentence embedded in a web page can therefore resemble a new instruction to the model, even when it should be treated only as data.

Direct and Indirect Attacks

Direct prompt injection occurs when a user explicitly asks the model to ignore its rules or reveal protected information. Indirect prompt injection hides instructions in material the model is asked to read, such as a web page, support ticket, image, email, or uploaded document. Indirect attacks are especially concerning when the assistant has access to tools and private data.

A Realistic Agent Scenario

Consider an internal assistant that searches company documents and can email summaries. An attacker submits a support ticket containing instructions to find confidential contracts and send them to an external address. If the agent treats the ticket as trusted direction and has unrestricted email and file access, a seemingly harmless summarisation task can become a data-exfiltration path.

Why a Single Filter Is Not Enough

Keyword filters can be bypassed through paraphrasing, encoding, other languages, or instructions hidden in images. Model training can improve resistance, but it cannot guarantee that every malicious instruction will be ignored. A safer design assumes that some injections may get through and limits what the model can do when they do.

Practical Defence in Layers

  • Apply least privilege. Give an agent only the read or write access required for its task. A summarisation assistant should not receive permission to send email or modify records unless that is essential.
  • Mark external content as untrusted. Delimit retrieved text and explicitly tell the model to analyse it as data, not obey instructions contained inside it. This is helpful but should not be treated as a complete security boundary.
  • Require human approval for consequential actions. Sending messages, deleting files, making payments, or changing account settings should require a clear confirmation that shows the intended action and its parameters.
  • Validate tool inputs and outputs. Enforce schemas, allowlist destination domains, restrict file paths, and check model-generated parameters before passing them to another system.
  • Log and monitor agent behaviour. Record tool calls and detect unusual access patterns, unexpected API spikes, or attempts to reach data outside the agent’s normal scope.
  • Minimise sensitive context. Mask personal data and secrets that the model does not need. Less sensitive information in the prompt means less information that can be exposed.

What Everyday Users Should Know

Be cautious when uploading documents from unknown sources to AI assistants, especially assistants connected to email, cloud storage, or business accounts. Review the permissions granted to an AI application. If an assistant unexpectedly asks you to perform an unrelated action, stop and verify the request through an independent channel.

Conclusion

Prompt injection is an architectural challenge created by mixing instructions with untrusted data. The most reliable response is layered protection: least-privilege access, clear trust boundaries, human approval for high-impact actions, strict validation, monitoring, and data minimisation. For further guidance, see the OWASP Prompt Injection Prevention Cheat Sheet and our guide to cybersecurity and digital privacy.

Bagikan artikel ini

No comments yet

    Leave a comment

    Your email address will not be published. Required fields are marked *