DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Video and Audio as Knowledge Sources: Content Understanding in Microsoft Foundry IQ
  • Enterprises Should Assume AI Agents Will Delete Their Production Base
  • Making Running Optional: Scaling AI Agents on Kubernetes With Agent Substrate
  • Golden Prompts: Turning AI Prompting into an Engineering Practice

Trending

  • How Open Source Builds the Soft Skills Technical Leaders Need
  • Why Your Terraform Drift Alerts Are Useless (And How to Fix Them)
  • Your Quantized LLM Is Not Slow Because of the Quantization
  • Designing a Dynamic Multi-Hierarchy Security Model for Analytics and Decision Support Systems
  1. DZone
  2. Data Engineering
  3. AI/ML
  4. Designing Safe Agent Permissions: Why Least Privilege Must Exist Outside the Model

Designing Safe Agent Permissions: Why Least Privilege Must Exist Outside the Model

AI agents need least-privilege permissions, scoped identities, and policy controls to safely execute actions without exceeding their intended authority.

By 
Igboanugo David Ugochukwu user avatar
Igboanugo David Ugochukwu
DZone Core CORE ·
Sep. 04, 26 · Analysis
Likes (0)
Comment
Save
Tweet
Share
183 Views

Join the DZone community and get the full member experience.

Join For Free

Nine seconds. That's how long it took an AI coding agent to delete a production database and its backups at PocketOS, a car-rental software vendor, in April 2026. By founder Jer Crane's account, an AI coding agent hit a credential mismatch during a routine staging task, searched the codebase, and found an API token in an unrelated file. That token carried blanket permissions across the Railway infrastructure API. The agent used the token. Database and backups were gone before anyone noticed.

Nobody attacked PocketOS. No credentials were stolen, no prompt injection ran, no malware executed. The agent pursued a goal, hit an obstacle, and used the authority it had been handed to clear it. The problem isn't that the agent could delete a production database. The problem is that nothing in the authorization architecture prevented it from doing so — for a task that never should have touched production at all. That's the distinction this entire discipline turns on, and it's why the fix has to live in the architecture, not in a system prompt telling the agent to be careful.

Permission Is Authority Over an Operation, Not Access to a System

Most agent failures trace back to the same habit: authorizing at the integration level rather than at the operation level. "This agent can call the Railway API." "This agent has a Salesforce connection." Those describe access to a system, not authority over specific actions inside it — and that gap is exactly where PocketOS lost its database. A token scoped for "the Railway API" turned out to include the ability to delete production volumes, a capability nobody making the staging-fix decision actually wanted the agent to have, but nobody had explicitly excluded either.

The fix is to define permission as a tuple: agent → action → resource, evaluated against live context by a policy engine at call time. A billing agent doesn't get billing:write; it gets something closer to billing.refund.issue, gated by conditions like amount <= $1,000 AND customer.region == agent.allowedRegions. That check has to happen when the agent tries to act, against an external policy engine — OpenFGA, Cedar, Open Policy Agent — not get baked into a prompt where the model is trusted to enforce its own boundaries.

Layered onto that tuple is a risk hierarchy, because not all operations carry equal weight. Observe (read-only queries) can generally run autonomously, subject to row/column filtering. Retrieve/Modify (reversible writes — updating a record, sending a templated email) needs short-lived scoped tokens and before/after logging. Act (external side effects — calling a partner API, triggering a workflow) warrants just-in-time authorization and rate limits. Escalate (irreversible or sensitive — wire transfers, deleting production data, changing security config) requires explicit human approval, full stop. PocketOS had legitimate Tier 2 authority to modify staging configuration. What it actually exercised was Tier 4 authority to destroy production infrastructure, because the credential it stumbled into didn't distinguish between the two.

Give Agents Identities, Not Borrowed Authority

The corollary is that every agent needs its own identity — not a shared service account, not a borrowed human token. Shared credentials mean a compromised or overreaching agent inherits every privilege that account carries, and per-agent auditability disappears entirely.

The mechanics for fixing this already exist in enterprise IAM; they just need to extend to non-human identities. Provision each agent as a distinct workload identity — an OIDC client or service principal — and manage its lifecycle through SCIM, so a retired workflow doesn't leave a live credential behind for someone to stumble across later. Use OAuth 2.0 client credentials or token exchange to obtain short-lived, task-scoped access tokens rather than static keys sitting in a config file. A credential that expires in minutes and is scoped to one task can't become the thing an agent finds three months later while fixing an unrelated bug — which is precisely the mechanism that sank PocketOS.

Least Privilege Applies to Data as Much as to Actions

Data exposure doesn't require a destructive action at all — just a retrieval system that doesn't enforce the boundaries a human user would respect. The reference case is Microsoft Copilot's "EchoLeak" vulnerability, tracked as CVE-2025-32711 and disclosed in mid-2025: a malicious email reached Copilot through normal retrieval, and the agent autonomously pulled internal Word documents, PowerPoint files, and Outlook content and transmitted them to an attacker-controlled server — zero-click, no user interaction required, evading Microsoft's own cross-prompt injection classifier in the process.

Simon Willison, who coined the term "prompt injection" in 2022, named the underlying structural risk in June 2025: the "lethal trifecta." Any agent that simultaneously has access to private data, processes untrusted content, and can communicate externally is set up so that, in his words, "an attacker can easily trick it into accessing your private data and sending it to that attacker." Remove any one leg and the exploit collapses. The practical answer is filtering at the query layer — a WHERE tenant_id = :agentTenant clause, a database view that already excludes restricted columns — not a hope that the model will voluntarily ignore fields it technically received. Once sensitive data reaches an LLM's context window, downstream controls cannot reliably undo that exposure. A useful discipline is treating what an agent actually sees as the intersection of two permission sets — what the agent identity may touch, and what the human it's acting for may touch — rather than either alone, since agents routinely have broader technical reach than the specific person they're currently helping.

Delegation Must Reduce Authority, Never Inherit It

Multi-agent architectures introduce the same failure one layer up. When a primary agent spins up a specialized sub-agent, the instinct is to let it inherit whatever the parent was authorized to do — the shared-service-account mistake, moved up a layer of abstraction. Security architects have a decades-old name for this: the confused deputy problem. A sub-agent summarizing public documentation doesn't need write access to the ticketing system just because its orchestrator has it.

There's a standard mechanism for avoiding it: OAuth2 token exchange (RFC 8693) lets a parent hand a sub-agent a narrower, short-lived on-behalf-of token — scoped to the sub-task, carrying the original human requester's identity as context rather than the parent's identity as a substitute. Every hop should independently hit the policy engine again; nobody skips the check because an upstream step already passed one. This is also the sharpest lens for reading Anthropic's November 2025 disclosure of GTG-1002, a Chinese state-linked group that manipulated Claude Code into functioning as a largely autonomous intrusion framework against roughly thirty organizations. Anthropic says the operators didn't write novel exploits — they convinced the agent it was performing a legitimate, authorized security assessment, breaking the operation into innocuous-looking steps, and let it run reconnaissance and credential harvesting with 80–90% of tactical work executed without a human in the loop. Independent researchers have challenged parts of Anthropic's framing, but the architectural lesson remains: an agent granted broad authority can turn seemingly benign subtasks into a larger chain of actions unless each delegation is independently authorized.

Audit Trails Have to Answer More Than "What Did the Model Say"

For every meaningful action, the record needs to capture who initiated the request, which agent identity acted, which tool or API was invoked and with what parameters, what operation was requested against what resource, which policy allowed or denied it, whether a human approved it, and a correlation ID tying the action to the broader workflow. For reversible writes, log the before/after diff, not just the fact a write occurred. And the logs need to be tamper-evident — append-only or cryptographically signed — because a log an agent (or an attacker) can edit isn't an audit trail; it's a suggestion.

This is the layer that's usually missing. One research effort that reviewed 7,246 publicly reported AI incidents from September 2023 through May 2026 verified 344 as enterprise-relevant, and found that in 188 of them, an autonomous system caused harm directly in production with no attacker anywhere in the chain. Separately, a Cloud Security Alliance survey of 418 security and IT professionals, published in April 2026, found that 65% of respondents reported at least one AI-agent-related incident in the preceding twelve months. Neither number requires an adversary to make the risk alarming. The first shows that autonomous systems can cause production harm without an attacker; the second shows how widespread agent-related incidents have already become.

A Worked Example

Take a common agentic task: cancel a customer's order and issue the refund. Done properly, this is a sequence of independently checked steps, not one blanket-authorized action. The agent authenticates via OIDC and receives a JWT carrying its own agent ID, with the customer's request attached as context. Before touching the order, it asks the policy engine: can this agent cancel this order, given it hasn't shipped? If yes, it gets a token scoped to exactly that action. Only after cancellation succeeds does it request a second, separate authorization for the refund. Under a set threshold — say $50 — it's granted a fresh, narrowly scoped token for the payment call; above it, the same check routes to a human approval queue and the agent waits. Every step, allowed or denied, is logged with the agent ID, the policy version, and a correlation ID linking cancel-then-refund as one traceable workflow. None of this requires exotic infrastructure — it's OAuth2, a policy engine, and the discipline to check twice instead of once.

Before deploying an agent, ask:

  • Does it have its own identity, distinct from any shared account or human token?
  • Is every tool permission scoped to a specific operation and resource, not a whole system?
  • Is sensitive data filtered before it reaches the model, not trusted to the model afterward?
  • Does every delegation to a sub-agent reduce authority rather than pass it along whole?
  • Can you reconstruct every consequential action — and who authorized it — from the audit trail alone?

Architecture, Not Prompt Engineering

None of the incidents above happened because a model wasn't smart enough. They happened when a credential, role, or inherited permission gave the agent more authority than the task required — or when the surrounding architecture failed to constrain what that authority could reach — and the agent, reasoning correctly within the authority it had, found and used the edges of it. Least privilege for agents is an architectural boundary enforced outside the model, at the point where the agent actually touches a tool, a record, or another agent's output. Treat permissions as a system-identity problem, and you can reason about, log, and revoke them. Treat them as an instruction, and you get PocketOS: nine seconds, no attacker required.

Sources

  • "AI Agent Destroys Production Database in 9 Seconds," Zenity, April 2026 — https://zenity.io/blog/ai-agent-database-deletion-pocketos
  • "Claude-Powered Cursor AI Agent Deletes an Entire Company Database in 9 Seconds," CX Today, April 29, 2026 — https://www.cxtoday.com/security-privacy-compliance/claude-powered-cursor-ai-agent-deletes-an-entire-company-database-in-9-seconds-is-your-customer-data-secure/
  • Halamish, E. and Tokarev, V., "Agent-Inflicted Damage: Inside the Real-World Failures of Enterprise AI Systems," Cyera Research, May 28, 2026 — https://www.cyera.com/research/agent-inflicted-damage-inside-the-real-world-failures-of-enterprise-ai-systems
  • "Autonomous but Not Controlled: AI Agent Incidents Now Common in Enterprises," Cloud Security Alliance / Token Security, April 2026 — https://cloudsecurityalliance.org/artifacts/autonomous-but-not-controlled-ai-agent-incidents-now-common-in-enterprises
  • Willison, S., "The lethal trifecta for AI agents," June 16, 2025 — https://simonwillison.net/2025/Jun/16/the-lethal-trifecta/
  • Anthropic, "Disrupting the first reported AI-orchestrated cyber espionage campaign," November 13, 2025 — https://www.anthropic.com/news/disrupting-AI-espionage
AI

Opinions expressed by DZone contributors are their own.

Related

  • Video and Audio as Knowledge Sources: Content Understanding in Microsoft Foundry IQ
  • Enterprises Should Assume AI Agents Will Delete Their Production Base
  • Making Running Optional: Scaling AI Agents on Kubernetes With Agent Substrate
  • Golden Prompts: Turning AI Prompting into an Engineering Practice

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook