Skip to content

Playbook · for Engineering, Security

Prompt injection defense in layers

Assume the model can be talked into anything. Limit what an injected instruction can reach, and check outputs before they act.

By Mr.DLast reviewed 3 min read

The uncomfortable truth

Prompt injection is first on the OWASP Top 10 for LLM applications (LLM01) because it has no clean fix. A language model reads instructions and data as the same stream of text, so any content it processes can try to steer it: an email it summarises, a web page it browses, a ticket, a PDF, a code comment, a tool's output. Filters catch the obvious cases. Research and real incidents keep showing that determined attackers get past them.

So the goal is not a model that cannot be fooled. It is a system where a fooled model cannot do much harm.

Direct and indirect injection

  • Direct: a user types instructions meant to override your system prompt. Annoying, sometimes embarrassing, usually limited to what that user could already see.
  • Indirect: instructions arrive inside content the model processes on someone else's behalf. This is the dangerous one, because the attacker never talks to your application and the victim never sees the payload.

Design for indirect injection and you cover direct injection too.

Layer 1: decide what the model may reach

Write down, for each LLM feature, which data it can read and which actions it can trigger. Then cut both lists to the minimum.

  • Retrieval should respect the user's own permissions. A RAG pipeline that searches all documents for every user is a data-leak engine.
  • Do not put secrets, credentials or other users' data in the context window. Assume anything in context can be repeated back.
  • Split features: a summariser does not need tools; an agent that files tickets does not need email.

Layer 2: treat model output as untrusted input

OWASP calls this improper output handling (LLM05). Every place model output goes needs the same checks you would apply to user input:

  • Never pass output straight to a shell, eval, SQL or a template engine. Use parameterised calls and allowlists.
  • Render output as text, or sanitise HTML and strip active content. Markdown images and links can carry data out in their URLs, so restrict which domains they may load from.
  • Validate structured output against a schema before acting on it.

Layer 3: control tools and actions

When the model can call tools, the tool layer is your real security boundary.

  • Give each tool the narrowest permissions and inputs it needs, and check authorisation in the tool, not in the prompt.
  • Require human confirmation for anything irreversible or outward-facing: payments, deletes, deploys, sending email or data outside the company.
  • Show the user exactly what will happen before they confirm, using the real parameters.

Layer 4: mark and filter untrusted content

These measures lower the success rate; they are not a boundary.

  • Separate trusted instructions from retrieved content with clear delimiters and tell the model the retrieved part is data.
  • Use a prompt-attack classifier or guardrail on inputs, and a sensitive-data filter on outputs.
  • Keep the system prompt free of anything you would mind leaking (OWASP LLM07).

Layer 5: log, test and respond

  • Log prompts, retrieved sources, tool calls and outputs with enough context to reconstruct an incident, and protect those logs like the data in them.
  • Red-team each feature before release with injected content in every input channel.
  • Have a kill switch per feature, and an incident playbook entry for "the AI did something it should not have".

A quick test for your design

Imagine the model is fully controlled by whoever wrote the last document it read. If that person could read data they should not, or make your system act on their behalf, add a boundary at the tool or data layer. If the worst case is a wrong answer, you are in good shape.

What WardBee checks for this playbook

  • Amazon Bedrock guardrail has prompt attack filter strength set to HIGHbedrock_guardrail_prompt_attack_filter_enabled
  • Amazon Bedrock agent uses a guardrail to protect agent sessionsbedrock_agent_guardrail_enabled
  • Amazon Bedrock model invocation logging is enabledbedrock_model_invocation_logging_enabled

Runs on each AWS sync while a framework it maps to, such as ISO 27001, is enabled. Run it on your account

Related standards: OWASP Top 10 for LLM Applications · NIST AI RMF

More playbooks

Check this playbook against your own AWS account.

WardBee connects read-only to AWS and, if you choose, to GitHub or GitLab, and shows which of these controls pass, fail or still need a person, as ISO 27001 and SOC 2 evidence.

What's new · v1.0.0

ScanComb and WardBee 1.0: compliance checks, TISAX and SOC 2 readiness, and a new public site

This is the first release of ScanComb and WardBee. WardBee brings automated compliance checks, framework workspaces, reports and task tracking for engineering, security and compliance teams. scancomb.com adds free checks and a TISAX readiness check, plus guides and news.

Highlights

  • TISAX readiness check Answer a public questionnaire and get a free readiness score by email. A paid report adds findings, an action plan for each chapter, a roadmap and a PDF. You can import the gaps into a WardBee workspace as tasks.
  • Dedicated TISAX section in WardBee Manage TISAX in one place. Set the scope, keep a self-assessment register, follow an action plan with tasks, track audits and labels, and manage suppliers and exports.
  • SOC 2 readiness Work through a readiness questionnaire, criterion guidance, a policy pack and reviews. Criteria are explained in plain words and questions can be answered in the side drawer. You can download a SOC 2 readiness report as a PDF.
  • Sovereignty Profile free check Run the free Sovereignty Profile check and get a report. The scores are explained in plain words.
  • Projects with a shared scan pool Run several projects or clients in separate workspaces that share one pool of scans. A For consultants page explains the setup.

Improvements

  • Resource inventory See an inventory of your resources with filters, saved views and notifications.
  • EU Cyber Resilience Act support Prepare for the EU Cyber Resilience Act with product classification and a continuous technical file.
  • NIS2 Supplier Check Assess suppliers against NIS2 with the NIS2 Supplier Check.
  • Free AI security check and AI Shield playbooks Take a free AI security check and read practical playbooks on AI agent permissions, prompt injection, shadow AI and more.
  • Manual control verification Verify controls that cannot be checked automatically, using a clearer drawer for manual controls.
  • Clearer controls and findings Findings and resource names are easier to read, you can filter to checks-only scans, and you can compare one scan with the previous one.
  • Faster control and dashboard pages Controls, the dashboard and risks load faster. App pages show a loading state right away.
  • Better start for new workspaces New workspaces start with ISO 27001 and SOC 2, with an explanation of what scans do. If no frameworks are chosen, a Choose frameworks step guides you.
  • Support tickets, announcements and notification bell Open support tickets inside WardBee and get email updates. Announcements appear in a header bell.
  • New site design, menu and guides scancomb.com has a new look and a grouped menu with News, Free checks and Guides. WardBee uses the same visual style, and the in-app docs are task-focused guides.
  • What's New and Framework Watch A What's New dialog shows release notes on scancomb.com. A weekly Framework Watch news issue is also published.
  • Team invitations and two-factor sign-in Invite teammates by email with consistent role names. Two-factor setup includes a QR code.

Fixes

  • Security improvements to sign-up and sign-in Sign-up and sign-in are now better protected.
  • More accurate AWS multi-factor authentication checks All MFA device types are now recognized, and users who only use programmatic access are no longer flagged.
  • Confirmed failures are shown correctly A confirmed failure now outranks an error in a control's status.
  • One critical-control email per scan You now get a single critical-control email per control for each scan.
  • Smoother onboarding and failed checks Workspaces without frameworks are sent to setup. Checks that fail are refunded, and queued checks show as Queued.
  • Correct access errors Signed-out or unauthorized requests now get a proper access error instead of a server error.