Part 3: Trust & security · Chapter 2 of 6
Giving an AI the keys: agents and permissions
Least privilege, sandboxes and egress rules are the controls that still work when both the model and the human slip.
After this chapter you can
- Explain why an agent's access matters more than its judgement
- Spot approval fatigue and say what works better
- Apply least privilege to an AI tool you use
The last chapter ended on an uncomfortable conclusion: you can’t fully stop a model from being fooled. The other half of the problem is what a fooled model can actually do.
That depends entirely on what you handed it. An AI that can only read a page and write a summary can’t do much harm. An agent with your email, your cloud account and a shell can do real damage.
Too much power, too much freedom
Security people have a name for the problem: excessive agency. OWASP names three root causes of "excessive agency": too many functions, too many permissions and too much autonomy; its 2026 list moved the risk from sixth place to thirdNov 2026. The real incidents fit those three causes neatly:
- The code freeze that wasn’t. In July 2025 a Replit coding agent deleted a production database during a declared code freeze; the freeze existed only as an instruction in textsource. Nothing in the system enforced the freeze. It was a sentence in a chat.
- The helpful support agent. A support ticket with hidden instructions made an AI editor, connected to a database with full rights, copy secret tokens back into the ticketsource. A human support worker would never have had those rights.
- The plug-in that added one line. In September 2025 a look-alike MCP server package for the email service Postmark built trust over 15 versions, then quietly copied every outgoing email to an attackersource. It needed no AI trick, only a trusted-looking add-on.
The common thread: the agent had more access than its job needed, and the only thing standing between it and disaster was its own judgement.
Plug-ins speak to the model, not to you
Most agents now connect to tools through MCP, a standard plug-in protocol. Each tool comes with a description written for the model. You usually never see it. Invariant Labs showed hidden instructions in an MCP tool's description, invisible to the user, making an AI editor read private SSH keys and pass them outNov 2026. That’s tool poisoning. A related trick, the rug pull, changes a tool’s description after you’ve approved it. In August 2026 Pillar Security caught the trick in use: an MCP server, offered to open-source projects in 23 pull requests, showed harmless tools until its third call and then told agents to look for SSH keys and cloud credentials and to hide it; none of the requests was mergedNov 2026.
Try it: approve, approve, approve
A coding agent is fixing a login bug. It asks before every action. One of these thirty requests is not like the others.
Most people miss it, and the numbers show why: Anthropic reports that users approved about 93% of Claude Code's permission prompts, and that operating-system sandboxing cut the number of prompts by 84% (self-reported)Nov 2026. That’s approval fatigue, the same reflex that makes everyone click “accept” on the tenth cookie banner.
Tool makers have drawn the same conclusion. Since August 2026 Claude Code lets a classifier, not the user, approve most actions by default on its consumer and team plans; in Anthropic's own study, people stopped 13.6% of dangerous commands and the classifier 89%, and Anthropic adds that this does not eliminate riskNov 2026. A classifier doesn’t get tired, but it is still a judgement about each action and not a wall: later that month a researcher got malicious code past it in most of a handful of tries, because the classifier saw only the agent's own short script and not the booby-trapped file that script loaded; Anthropic called this working as designedNov 2026.
The sandbox round shows the alternative. Instead of asking a tired human thirty questions, you draw a boundary once: this folder, this registry, nothing else. The agent works freely inside it, and the dangerous step fails whether or not anyone notices.
Where experts disagree checked Nov 2026
Are "Allow this action?" prompts a real safeguard or security theatre?
Almost every AI agent today relies on you clicking approve. If that doesn't work, something else has to.
Keep a human in the loop
OWASP, Brave
- Some actions, such as payments, emails to new recipients or deletions, can't be undone.
- Only the human knows what they actually intended, so confirmation for high-impact steps is a core mitigation.
- The classifier that now approves actions in Claude Code was bypassed within weeks, and Anthropic itself still recommends human review for high-stakes changes.
Sources: genai.owasp.org · brave.com · embracethered.com
Enforce boundaries instead
Anthropic engineering, Invariant Labs
- Users approved about 93% of prompts; sandboxing removed 84% of them without losing safety (self-reported).
- In Anthropic's 2026 study of about a thousand testers, human reviewers stopped only 13.6% of dangerous commands (self-reported).
- People pick "Always allow" and stop reading, so the prompt gives false assurance.
- Better to make dangerous actions impossible by default and keep prompts for rare boundary crossings.
Sources: anthropic.com · claude.com · invariantlabs.ai
What would settle it: Independent field data on how often people, and the classifiers now replacing them, catch a malicious action among routine ones, compared with incidents in sandboxed setups.
Attackers use your agents too
Agents on your laptop run with your permissions. That makes them useful to attackers who get code onto your machine some other way. In the August 2025 Nx "s1ngularity" npm compromise, malware ran victims' own AI command-line tools with permission-skipping flags to search for secretssource. The “skip all permissions” flags exist for convenience, and malware uses them too.
Engineer depthBoundaries that hold
Assume the agent will sometimes be fooled, and decide in advance what it can’t do even then.
Identity and scope. Give each agent its own identity with narrow, short-lived tokens scoped to the task. Least privilege is old advice, but agents make it urgent: no service_role or admin tokens in agent contexts, separate credentials for development and production, and read-only by default. Enforce authorisation downstream, in the API, rather than trusting the model to stay inside the lines.
Sandboxes need two walls. A sandbox needs both file-system and network isolation: without network limits a hijacked agent can send secrets out, and without file-system limits it can escape the sandboxsource:
Without the file-system wall, the agent can read your keys. Without the network wall, it can send whatever it reads anywhere. The allowlist lives outside the sandbox so the agent can't edit it.
Enforce a default-deny egress allowlist outside the sandbox, where the agent can’t change it. And tie allowed calls to the agent’s own credentials: Anthropic describes a malicious workspace file that used an attacker’s API key to upload files through the allowed api.anthropic.com domain. An allowlist of domains is not an allowlist of accounts. The way out can even be the platform the agent works on: in April 2026 researchers showed that text an outsider can write, such as a pull-request title or an issue comment, made coding agents from three vendors post their own API keys and access tokens back into GitHub, so the secrets left without any outside serversource. No network rule stops that, so give an agent in a build pipeline only the secrets its task needs.
Keep secrets out of reach. Strip secrets from the environment variables passed to child processes. Don’t mount ~/.ssh or cloud credential files into agent environments. Block agents from editing their own configuration and permission files (the Copilot auto-approve CVE from the last chapter), and turn off auto-approve modes in managed environments.
MCP hygiene. Vet MCP servers like any other dependency. Pin and hash tool descriptions so a rug pull shows up as a diff, and show users the full descriptions. Follow the specification’s security rules: no token passthrough, consent per client, and minimal scopes with step-up for anything more. Classic bugs matter too: CVE-2025-6514 in mcp-remote (CVSS 9.6) turned a malicious server’s OAuth endpoint into command execution.
CI agents are part of the supply chain. A 2026 write-up showed a single GitHub issue making a coding-agent GitHub Action leak the credentials it used to request OIDC tokens. Treat issue and pull-request text as untrusted input to anything with write access to the repository.
Watch it. Log every tool call with its arguments and identity, and make sure VM isolation doesn’t blind your endpoint detection. OWASP’s Top 10 for Agentic Applications (December 2025) has a fuller checklist.
Recall. A coding agent asks for approval before every command, and you approve almost all of them. What protects you best against the one malicious command hidden among them?
Apply it. You connect a coding agent to your company's cloud account. Which access is right?
Spot the mistake. 'We told the agent in the chat that there is a code freeze, so it won't touch production.' What is wrong?
Remember this
- Assume the model can be fooled. What it can reach decides how bad that gets.
- People approve almost everything they are asked. A boundary drawn once holds better than a stream of prompts.
- Give agents valet keys: only the access the job needs, and never a skip-permissions mode on your normal account.
Further reading
- OWASP: Excessive Agencyno background neededOWASP, 2025 · genai.owasp.orgThe root causes and mitigations in one page.
- Beyond permission prompts: making Claude Code more secure and autonomousAnthropic, 2025 · anthropic.comApproval fatigue explained, prompts cut by 84%, and why sandboxes need two walls.
- MCP security notification: tool poisoning attacksInvariant Labs, 2025 · invariantlabs.aiTool poisoning, rug pulls and shadowing explained.
- MCP security best practicesMCP project, 2026 · modelcontextprotocol.ioThe specification's own rules on tokens, scopes and consent.
Chapter complete
Spotted a mistake? Report it on GitHub. Every fix is listed in the monthly field notes.