AI security
Defending against prompt injection, data leakage and over-permissioned agents.
Bookmark
Bookmarks are kept in your free account, so you can find this page again on any device.
Sign in to bookmarkOn this page
Overview
AI security deals with the new ways AI systems can be attacked or misused. The central problem is prompt injection: instructions hidden in a web page, email, document or tool result that the model follows as if they came from you. Combined with access to private data and the ability to send data out, it can lead to real leaks.
Defences are layered: give agents the least privilege they need, keep untrusted content away from powerful tools, require approval for sensitive actions, sandbox code execution, review third-party skills and MCP servers before installing them, and red-team your own application. The OWASP Top 10 for LLM Applications is a useful checklist.
What you will practise
- Recognise direct and indirect prompt injection
- Remove one leg of the lethal trifecta from risky agents
- Apply least privilege to tools, tokens and data
- Red-team your own application and keep the findings as tests
Learning paths
- Agent Skills essentials
A free Agent Skills course: learn what SKILL.md packages are, write and share your own, port it across agents and review third-party skills before installing.
- Agents and MCP
An AI agents and MCP course for developers: build a tool-using agent with a clear stop condition, then expose your own data and actions with an MCP server.
- AI foundations
A free AI foundations course: the working vocabulary of modern AI, from prompting and structured output to retrieval, MCP, Agent Skills and prompt injection.
- AI governance for team leads
An AI governance course for team leads: what the EU AI Act expects, the main LLM security risks, a team AI usage policy and a review of third-party skills.
- Evals and safety for LLM features
Learn LLM evals and safety: catch regressions and attacks before users do, with error analysis, code-based evals, calibrated judges and prompt-injection tests.
- MCP in production
An MCP course for production use: connect clients, build and test servers for a team, secure remote servers and keep up with changes to the MCP specification.
- Production AI agents: approval, multi-agent and evals
For engineers moving past single-agent demos: add code-level approval gates, context isolation, multi-agent patterns and automated evals you can trust in CI.
- Rolling out coding agents to a team
Roll out coding agents to a team: shared instruction files, permissions and hooks, spec-first work, agent review in CI and vetted Agent Skills for everyone.
Tutorials
- Add input and output guardrails to an LLM app
Length, topic and PII checks on input, schema and policy checks on output, then measure false positives and latency on a test set.
- Run AI-generated code in a sandbox
Run model-written Python in a throwaway Docker container, then in an E2B sandbox, with time, memory, network and file limits, and a test suite of hostile code.
- Add human approval to agent actions
Pause risky tool calls, show the exact arguments, resume on approve or reject, then log and test it.
- Claude Code hooks: run checks around every tool call
Write Claude Code PreToolUse and PostToolUse hooks that block destructive shell commands, format every file Claude edits and log each command for later audit.
- Permissions and sandboxing for coding agents
Set up Claude Code permission modes and rules, the Codex sandbox and approvals, and a dev container, so an agent can work without free rein.
- Run coding agents headless in CI
Run claude -p and codex exec in GitHub Actions with pinned versions, narrow permissions, scoped secrets and separate jobs for writing back to the pull request.
- Secure a remote MCP server with OAuth
Protect a Streamable HTTP MCP server with OAuth 2.1 as the 2026-07-28 spec requires: resource metadata, audience checks, per-tool scopes and Inspector tests.
- Prompt injection basics for builders
How direct and indirect prompt injection work, why agents with tools raise the stakes, and the design choices that limit the damage when no complete fix exists.
Workflow recipes
- Schedule a recurring task for a coding agent
Schedule Claude Code tasks and Codex runs: write a self-contained prompt, cut connectors and network to the minimum, test with Run now, and know how to stop it.
- Triage production errors with an agent
AI error triage with a coding agent: read errors over a read-only Sentry MCP connection, write a triage note, reproduce in a failing test, then fix behind it.
- Audit and upgrade risky dependencies with an agent
Audit project dependencies with Trail of Bits' supply-chain-risk-auditor skill, group upgrades by risk, update one batch on a branch and prove tests pass.
- Security-review a pull request with an agent
Run an AI security code review of one pull request with Trail of Bits' differential-review skill, then test each finding with fp-check before anyone acts on it.
- Set up guardrail hooks for your coding agent
Block dangerous commands in Claude Code with PreToolUse hooks and deny rules, so the agent cannot force-push, wipe files or edit secrets. Test them first.
- Triage GitHub issues automatically with an agent
Label new issues, post a short summary, flag likely duplicates and suggest an owner, with narrow permissions.
- Write a team AI usage policy in an afternoon
Data rules, approved tools, review duties and training, with pointers to the EU AI Act and NIST AI RMF.
- Scan a third-party Agent Skill before you install it
Read every file, grep scripts for risky patterns, run a skill scanner, then record a yes or no and pin it.
- Red-team your chatbot for prompt injection
Generate attacks for its purpose, confirm each failure by hand, apply mitigations and re-run.
Articles
- AI browsers and agent mode: what they can do and how to use them safely
What AI browsers such as Comet, Gemini in Chrome and Claude in Chrome can reach, why prompt injection is still open, and a setup that limits the damage.
- Claude Code auto mode: what the classifier allows and when to turn it off
How Claude Code auto mode decides which tool calls run without a prompt, how CLAUDE.md, ask and deny rules steer it, and when plan mode or a sandbox is safer.
- Code Mode: when an agent writes code to call its tools
Claude Code's experimental Code Mode has Claude write JavaScript that calls its tools. How it works and what it changes for permissions, hooks and sandboxing.
- What is OpenClaw, and should you let it run your computer?
OpenClaw is an open-source personal AI agent you message from chat apps. What it can reach, why ClawHub skills are the big risk, and a safer way to try it.
- MCP servers worth installing, checked
A short list of MCP servers worth installing for browsers, GitHub, docs and databases, with the access each one needs and the security settings to turn on.
- What happens to your data when you use AI tools at work
Where your prompts go in ChatGPT, Claude, Copilot and Gemini: training opt-outs, retention, human review and work plans, checked against vendor policy pages.
- What is vibe coding, and when it bites
Vibe coding means building software by prompting an AI and accepting its code without reading it. Where that works, where it fails, and a test before you try.
- MCP security: tool poisoning, token scope and the lethal trifecta
The real attacks on MCP setups, from tool poisoning and rug pulls to token passthrough and the lethal trifecta, what hosts do about them, and a checklist.
- OWASP Top 10 for LLM applications, explained with examples
The 2026 OWASP Top 10 for LLM applications in plain language, with an agent-era example and a practical fix for each risk, plus what changed from 2025.
Tools for this skill
9 of 11 tools tagged with this skill.
Cisco Skill Scanner
Open-source Agent Skills scanner using rules, dataflow analysis and an LLM judge.
E2B
Open-source cloud sandboxes for code that agents run.
garak
Scanner that probes LLMs for vulnerabilities such as prompt injection.
Guardrails AI
Python framework of validators that check and correct LLM inputs and outputs.
Inspect
The UK AI Security Institute's open-source framework for LLM and agent evals.
Lakera
Runtime protection against prompt injection and data leakage, now part of Check Point.
NeMo Guardrails
NVIDIA's toolkit for programmable input, output and dialogue rails in LLM apps.
OpenClaw
Open-source personal agent you message from chat apps.
promptfoo
CLI for YAML-defined prompt and model evals, plus red-team scans for injection.
Show 2 more
Key terms
Words you will meet while learning this, defined in the glossary.
- AI alignment
The work of making AI systems pursue the goals and values their developers and users intend, and avoid harmful behaviour nobody asked for.
- Data poisoning
Tampering with the data used to train a model or build its retrieval index, so that it learns false, biased or hidden behaviour.
- Deepfake
AI-generated or altered image, audio or video that shows real people, places or events in a way that could be mistaken for authentic.
- Dev container
A container defined by a devcontainer.json file that gives a project a reproducible environment, often used to sandbox agents.
- Excessive agency
The risk that an AI system has more permissions, tools or autonomy than is safe, so a mistake or manipulation causes real harm.
- Jailbreak
A prompt crafted to get a model to bypass its safety training and produce content it would normally refuse to write, often by role-play.
- Least privilege
Granting an agent or tool only the permissions and data access its task requires, and nothing more, so a mistake does less damage.
- Lethal trifecta
Access to private data, exposure to untrusted content and a way to send data out: together they make data theft by prompt injection possible.
- OWASP Top 10 for LLM Applications
OWASP's list of the most critical security risks in LLM applications, such as prompt injection and excessive agency.
- Permission mode
A setting in a coding agent that decides which actions it may take on its own, such as edits or shell commands, and which need approval.
- Prompt injection
Input that overrides or subverts a model's instructions, either typed in directly or hidden in content the model reads while it works.
- Red-teaming
Deliberately attacking an AI system to find harmful, insecure or embarrassing behaviour before real users or attackers can find it.
- Sandbox
An isolated environment that limits what an agent or its code can read, write or reach on the network, so any mistakes stay contained.
- System prompt leakage
Exposure of the hidden instructions an app gives its model, usually because a user coaxes the model into repeating them.
- Tool poisoning
Malicious instructions hidden in a tool's description, parameters or output that manipulate the agent using it without the user seeing them.
- Zero data retention
An arrangement where a model provider does not store your prompts and outputs after responding, apart from contractual exceptions.