Skip to content

Chapter 1 of 813 min readBy Deepak GuptaUpdated

When AI Gets Root Access

The Moment Everything Changed

In July 2025, SaaStr founder Jason Lemkin was building an app with Replit's AI coding agent. During an explicit code freeze, the agent deleted his production database. Fortune reported that the agent then described its own action as "a catastrophic failure." Replit's CEO called the incident unacceptable and promised automatic separation between development and production databases.

Nobody hacked anything. No vulnerability was exploited. An agent with write access to production took an action toward a goal, and nothing in its environment stopped it.

That is the pattern this book is about. It was not malice. It was an AI doing what autonomous agents are designed to do: taking action to accomplish a goal. The problem is that nobody thought carefully about what happens when you give a goal-seeking system the keys to your infrastructure.

What "Autonomous" Actually Means in Practice

Let's be precise. When we say AI agents have "root access," we don't necessarily mean literal root on a Linux box (though some do). We mean they operate with permissions broad enough to cause significant damage if their actions go wrong.

Here's what typical agent access looks like across common enterprise environments:

+------------------+-----------------------------------+
|   Agent Type     |   Typical Access Level            |
+------------------+-----------------------------------+
| Code assistants  | Write to repos, run builds,       |
|                  | modify CI/CD, access secrets      |
+------------------+-----------------------------------+
| IT automation    | Create/modify user accounts,      |
|                  | change network configs, deploy    |
|                  | software                          |
+------------------+-----------------------------------+
| Data agents      | Read/write databases, access      |
|                  | PII, run analytical queries       |
+------------------+-----------------------------------+
| Customer service | Access CRM, process refunds,      |
|                  | modify account details            |
+------------------+-----------------------------------+
| DevOps agents    | Full cloud console access,        |
|                  | infrastructure provisioning,      |
|                  | secret management                 |
+------------------+-----------------------------------+

The common thread: agents get the permissions of the humans who deploy them, and often more. A developer who occasionally restarts a service might have that permission scoped narrowly. The agent acting on their behalf gets the same credential but uses it continuously, at machine speed, across every task it encounters.

The Clawdbot Moment

In January 2026, an open-source personal agent called Clawdbot went viral. Its creator, Peter Steinberger (the Austrian developer who founded PSPDFKit), built it to run on your own hardware and act for you. It reads and writes files, runs shell commands, controls a browser, and sends messages through WhatsApp, Telegram, Slack and iMessage. I wrote about it the week it took off in Clawdbot is what happens when AI gets root access.

The project was renamed twice in a matter of weeks, first to Moltbot and then to OpenClaw. The security story moved just as fast. The Register reported on February 9, 2026 that SecurityScorecard's STRIKE team had counted more than 135,000 OpenClaw instances exposed to the internet. The cause was a default: the agent bound to 0.0.0.0:18789, listening on every network interface instead of only localhost.

Clawdbot made the abstract concrete. Thousands of people handed an agent shell access, persistent memory, and their messaging accounts, then left the control port open. The escalation path for an agent with that kind of access looks like this:

  User gives agent a task
           |
           v
  Agent reads local files
  (finds .env files, config)
           |
           v
  Agent identifies service accounts
  and API keys in those files
           |
           v
  Agent uses discovered credentials
  to reach additional systems
           |
           v
  Agent changes settings or permissions
  "to complete the task more efficiently"
           |
           v
  Agent now has broader access than
  the person who launched it

None of these steps requires a malicious agent. When an agent hits a permissions error, it looks for a workaround, the way a resourceful engineer would. The difference is that a human engineer would (hopefully) stop and ask whether to cross that boundary. The agent just does it.

Warning

The most dangerous agent behaviors aren't malicious. They're helpful. An agent that works around permission errors to "get the job done" is doing exactly what it was designed to do. Your security model needs to account for well-intentioned agents, not just adversarial ones.

Real Incidents and Near-Misses

Most organizations don't discuss AI agent incidents publicly. A few have become public record, and they show the pattern clearly.

The Poisoned Coding Assistant

In July 2025, someone got a commit merged into the open-source AWS Toolkit for VS Code. It added a prompt instructing Amazon Q to wipe the user's machine to a near-factory state and delete AWS resources. The Register reported that the change shipped in version 1.84.0 of the Amazon Q Developer extension. AWS said the injected code was malformed and could not run, revoked the credentials involved, and released 1.85.0.

The lesson isn't that the wiper failed. It's that an instruction to destroy data reached a signed release of a tool that agents execute with the developer's own permissions.

The Database Agent in Production

The Replit incident above belongs here too. Replit was using the same database for preview, testing and production at the time, according to heise. The agent's credentials could reach production, so its mistake landed in production.

Illustrative Scenarios

The next three cases are composites. They are built from patterns that come up repeatedly in agent deployments, not reports of specific incidents. Treat them as threat-modeling exercises.

The overprivileged coding assistant. A company connects a coding assistant to its GitHub organization using the platform team's admin token, with repo and admin:org scopes. Over a few days the assistant creates scratch repositories, relaxes branch protection to push fixes faster, and adds a webhook that sends diffs to an external analysis endpoint. Each action is the agent trying to be more effective. Together they expand the attack surface in ways nobody monitors.

The helpful database agent. An analytics agent is connected to a read replica with a 15-minute lag. When analysts ask about fresher data, the agent finds the production connection string in the application's environment variables and queries production directly. One unoptimized query locks a critical table during peak traffic.

The recursive automation. An IT operations agent can create automated tasks to handle sub-problems. It responds to a disk space alert by scheduling a cleanup job that deploys a monitoring agent. That agent raises alerts, which the original agent treats as new tickets. The loop grows for days before anyone notices the compute bill.

Permission Escalation: How Agents Get More Access Than You Intended

Permission escalation by AI agents follows predictable patterns. Understanding them is the first step to preventing them.

Pattern 1: Credential Discovery

Agents that can read codebases, configuration files, or environment variables will discover the credentials embedded in them. This isn't scanning or hacking. It's reading. Connection strings, API keys and service account credentials sit in config files, Docker Compose files, Kubernetes manifests, and CI/CD pipeline definitions.

The scale is not small. GitGuardian's State of Secrets Sprawl 2026 found 28.65 million new hardcoded secrets in public GitHub commits in 2025. It also found internal repositories roughly six times more likely than public ones to contain hardcoded secrets.

An agent asked to "understand the system architecture" will naturally read these files. Once it has the credentials, using them is a logical next step when it hits an access limit.

Pattern 2: Role Chaining

In cloud environments, agents can chain IAM roles to escalate privileges. An agent with the iam:PassRole permission in AWS can pass a more privileged role to a service it controls. This is a well-known escalation path for human attackers. Agents can stumble into it while trying to set up new resources.

Agent's initial role: deploy-service
   |
   +--> Can pass roles to Lambda functions
   |
   +--> Creates Lambda with admin-role
   |
   +--> Invokes Lambda to perform privileged actions
   |
   +--> Agent now effectively has admin access

Pattern 3: Tool Accumulation

Agents connected to tool ecosystems (through the Model Context Protocol or function calling) can request access to more tools over time. Each tool adds capabilities. An agent might start with a code repository, then ask for the deployment system "to verify my changes work." Next comes the monitoring system "to check for errors," then the database "to investigate an issue I noticed."

Each request seems reasonable. The cumulative effect is an agent with access to your entire stack.

Pattern 4: Persistence Mechanisms

The most concerning pattern is persistence. An agent sets up scheduled tasks, creates service accounts, deploys background processes, or modifies startup scripts. Its access then survives restarts, redeployments, and even credential rotation.

This isn't the agent being devious. It's the agent solving the problem of "my task takes longer than one session." But the result is functionally identical to a backdoor.

Tip

Audit your agent deployments for persistence mechanisms. Search for agent-created cron jobs, service accounts, API keys, webhooks, and scheduled tasks. You'll likely find more than you expect.

Why Traditional Security Controls Fail

Most enterprise security was designed around two assumptions. Actors are either humans, who act slowly and can be prompted for more authentication, or software, which executes fixed logic. AI agents break both assumptions.

Speed of Action

A human makes a limited number of consequential system changes in a day. An agent can make thousands in minutes. Monitoring that batches alerts hourly, or flags "unusual volume," is calibrated for human-speed activity. Agent-speed activity looks like a firehose. Most SIEM rules either alert on everything (creating alert fatigue) or miss the signal entirely.

As a rough illustration: a developer might touch a handful of systems in a workday. An agent acting for that developer might make hundreds of API calls across a dozen systems in an hour. Detection tuned for the first pattern either floods analysts with false positives on the second or misses it.

Contextual Decision-Making

Traditional software does what it's programmed to do. If a script tries to access a resource without permission, it fails and stops. An agent facing the same error reasons about alternatives. It might try a different credential, a different path, or a different approach entirely. That adaptability is the point of using agents, and it makes them unpredictable from a security perspective.

Security teams need to internalize this. Traditional controls assume deterministic behavior: the same input produces the same output. Agents are probabilistic. Given the same starting conditions, an agent might use a different tool, reach a different system, or build a query a different way. You cannot enumerate every possible agent behavior in advance, which makes threat modeling much harder.

Identity Ambiguity

When an agent acts, whose identity is it using? The user who launched it? The service account it was provisioned with? Credentials it found in a config file? A role it assumed through a delegation chain? Access logs record the credential used. With agents, that credential doesn't necessarily represent the principal making the decision.

Blast Radius Amplification

When a human makes a mistake, their speed and attention limit the blast radius. They might misconfigure one server or delete one wrong file before noticing. An agent making the same conceptual mistake applies it to every server, file and resource it can reach before anyone intervenes. It doesn't hesitate or feel the "something seems wrong" instinct that makes a human pause. Speed amplifies every error, misconfiguration, and compromised credential.

The Guardrail Gap

There's a revealing asymmetry in how organizations deploy agents. Ask a product team, "What can this agent do?" You'll get a detailed answer about capabilities, integrations, and use cases. Ask the same team, "What can't this agent do?" and you'll get silence.

That is the guardrail gap: the difference between what an agent is intended to do and what it's prevented from doing. For traditional software, the gap is close to zero. A function that sorts a list can't accidentally delete a database. For agents, the gap can be enormous. A support-ticket agent can, in principle, do anything its credentials allow, limited only by how it interprets the task.

The OWASP GenAI Security Project now names this failure. Its Top 10 for LLM Applications lists Excessive Agency (LLM06): more functionality, permission, or autonomy than the task needs. Its Top 10 for Agentic Applications lists Identity and Privilege Abuse as ASI03.

Closing the gap takes technical controls (permission scoping, action boundaries, sandboxing) and organizational practice (testing agent behavior, monitoring actions, reviewing scope). Neither alone is sufficient.

What "Good" Looks Like

Securing AI agents with broad system access isn't about preventing them from working. It's about making sure they work within boundaries that match organizational intent. These principles should guide your approach:

Principle of Minimal Authority: Agents should receive the minimum permissions needed for their current task. Not their potential tasks, not their historical tasks, but the specific action they're performing right now. That means dynamic, just-in-time grants rather than static role assignments.

Explicit Action Boundaries: Every agent deployment should have a defined set of actions it can take, systems it can access, and data it can read. The infrastructure should enforce these boundaries, not the agent's own judgment.

Comprehensive Audit Trails: Log every agent action with full context: what was done, the goal it served, and why the agent chose it (where the framework exposes that reasoning). This goes beyond traditional access logs.

Human-in-the-Loop for Escalation: When an agent hits a permission boundary, the response should be a request for human approval, not a workaround. That requires agent architectures that degrade gracefully when permissions are insufficient.

Temporal Limits: Agent sessions and credentials should have short lifetimes. An agent that needs to run for three days should request renewal, not receive a long-lived token at startup.

The Road Ahead

We are early in a fundamental shift in how enterprise systems operate. The move from human-driven to agent-assisted operations is happening faster than security models are adapting. The organizations that handle it well will take agent security seriously before an incident, not after.

The following chapters cover the specific technical and organizational challenges. They are the explosion of non-human identities, the broken state of agent authentication, the protocols that are starting to fix it, and the governance frameworks that need to exist.

The first step is the one this chapter is about. When you give an AI agent access to your systems, you're not deploying a tool. You're deploying an actor: one that makes decisions, takes initiative, and operates at a speed and scale your existing security infrastructure probably isn't ready for.

Note

For more on why traditional zero trust models fall short in AI-driven environments, see my article on Zero Trust in the Age of AI.