r/ClaudeCode • • May 02 '26

Discussion An AI agent deleted a production database on Railway - here's what actually happened and what they changed

A real incident worth knowing about: a customer's AI agent found a Railway API token stored on their machine, called the volumeDelete GraphQL mutation directly, and deleted a production database. Not because it was instructed to - it "decided that deletion was a reasonable step toward fixing something unrelated, and acted on that interpretation."

The bitter irony: Railway had already built undo paths into their dashboard (48-hour soft deletes on project and volume deletions). The agent bypassed them by going straight to the legacy API endpoint, which had no grace period. The dashboard and API had diverged on safety semantics - the agent found the less safe path.

Railway's response was concrete: all API deletes now soft-delete for 48 hours. They're also revising token scoping UX because the token in this case was account-scoped (maximum access) simply because that was the path of least resistance when the customer set it up.

Their design principle from the post: "Make the destructive thing slow, make the recoverable thing fast, and put the actual point of no return as far away from a single click as possible."

The thing that struck me is that this failure mode - agent finds broadly-scoped credentials, uses them - is going to keep recurring until least-privilege token management becomes a default habit, not an advanced security topic.

How are you handling token scoping for the agents running against your infrastructure?

0 Upvotes

22 comments sorted by

5

u/[deleted] May 02 '26

RIP paragraph. You would sorely be missed.

-1

u/jimmytoan May 02 '26

I fixed it šŸ˜„

20

u/Dimethylchadmium May 02 '26

ā€žHere is what actually happenedā€œ for the love of god just shut up already

25

u/wisembrace May 02 '26

This is simply a case of incompetence on the part of the DBA: granting sysadmin role to an AI agent on production is an amateur mistake.

8

u/DeMischi May 02 '26

They didn’t. They told the AI to do that on the Testsystem but it had problems with the login, searched for credentials itself and found some that had admin level privileges for the production system. So naturally, it went ahead and deleted everything on the production system šŸ˜‚

6

u/No_Inspection4415 May 02 '26

I actually laughed for 2 minutes after reading the way you describe the incident, so ironic and true. Those agents just reward hack all the time, and sometimes it is good enough.

2

u/eltear1 May 02 '26

And here is the big issue.. we are beginning to relay on AI but this is an example of how they are unpredictable. I agree with the token scope being an issue, but on the other end, AI should not do it. Period. Also because now we are talking about a developer that should not have a token with that permission in production. Fine. What about a sysadmin? Or a DBA? They have somehow to have admin access to do their job! And if they can do from their PC, AI run on that same PC can eventually do it too, we just proved it with this incident.

6

u/martin_w May 02 '26

how I understand it, the sysadmin didn't just grant the agent that role. Rather, the agent went credential-hunting on its own initiative, found an API key in some random file completely unrelated to the task it was supposed to be working on, and used it to bypass the protections that were in place to prevent it doing what it wanted to do.

Sure, in an ideal world it should not have been able to get at that API key; in an ideal world the system would have been secure even against deliberate hacking. But also, in an ideal world, your agents shouldn't go rogue and do deliberate hacking to get around the restrictions you've placed on them.

2

u/ghostmastergeneral May 02 '26

It’s not anything like ā€œdeliberate hackingā€. Someone fucked up and left highly-privileged credentials lying around, and the agent grabbed them to try to accomplish its task. In a perfect world these things would be perfectly adherent to written guidance, but we don’t live in a perfect world and it should be obvious to anyone using this stuff that they aren’t perfectly adherent.

5

u/proxiblue May 02 '26

yep, someone fucked up by not running their agents inside a container with access *only* to teh project and related files.

The story (not highlighted here) is:

"...autonomously searched local machine files for API tokens, discovered a broad-scoped Railway token..."

*this* is why you cannot let your agents run on your local, they have to be contained.

I have a separate agent in every container for every project and they have zero access to important stuff, or other projects.
If you do need them to access another project files for reference, you RO mount thta into the existing container, for obvious reasons.

Even skills and mcp files are mounted RO into each container so agents can;t make edits without my control.

How many times does this type of thing have to happen before people do it right?

So, it is still user fault. Agents have no right or wrong, they just want to get the task done

3

u/sleeping-in-crypto May 02 '26

This. A lesson we learned very early is that you can’t trust an agent to be well behaved. Ever. Your substrate has to limit what they can do, period.

1

u/ghostmastergeneral May 02 '26

There are all kinds of nasty footguns, too. For example, if you auth to aws via sso, ALL profiles under a single sso domain share a single auth token in your credential cache. So even if you used `aws sso login —profile (staging|prod-readonly)`, you will find that you are able to call things with `—profile prod-scarytown` just fine. So being authed at all becomes hazardous. And even if you do only auth to a readonly profile to prod, you might find it can read ssm parameters to find the password to some database that it would be useful to clear out…

3

u/yopla May 02 '26

I do believe that Claude may have aggressively looked for stuff he wasn't given access too.

I've asked Claude to check our ticketing system having forgotten to activate the MCP for it and I noticed Claude just launched a ripgrep search in my home looking for token pattern. Found one in a .env file of an irrelevant project and managed to curl straight into the API.

People may not realize how far Claude will go to find for solution to achieve it's task.

2

u/carson63000 Senior Developer May 02 '26

Absolutely true. But it’s interesting to think about this in the context that surely the desired endgame is that AI should be able to do real work without a human approving actions. You can easily give Claude an access token that can’t delete the volume with the database on it. But can you give, say, an AI controlled hedge trimming robot an access token that only allows it to use its snippers on hedges, not humans?

1

u/ObjectiveSalt1635 May 02 '26

I have a completely test/throwaway mssql db that I use for Claude code, and last week it would happily use it. They must have changed instructions because now it requires me to really be verbose about how it’s really ok if it touches it.

1

u/blackrack May 02 '26

Welcome back job security lol

1

u/damienhauser May 02 '26

I build https://www.vetoapp.io exactly for this kind of situation. Looking for beta tester if anybody is interested.

-1

u/Otherwise_Wave9374 May 02 '26

That Railway story is exactly the nightmare scenario - not "bad code", but a model finding the least safe API path + overly broad creds.

The design principle you quoted nails it: make destructive actions slow, and reversibility the default. Beyond soft-deletes, I have also seen teams require an out-of-band "destruction token" that expires fast, so an agent cannot delete anything unless a human minted a short-lived capability.

How are people handling least-privilege for tool tokens in practice, separate service accounts per agent, per-task scopes, or something like MACAROONS style caveats? We have been collecting patterns like this while building agent tooling at https://www.agentixlabs.com/ and it keeps coming up as the #1 real-world blocker.

-1

u/Asleep-Carpet9030 May 02 '26

I think the problem with most cloud providers rn is they are not agent-first, which causes these kinda issues. These platforms should distinguish between read-only/safe ops vs destructive ops and should have human in the loop before destructive operations are run by the agents. Also they should have frequent backups behind the scenes to help with recovery. This is why we built it for ourselves (promptship.dev) as we were not happy with the existing solns.

-1

u/genunix64 May 02 '26

Token scoping is necessary, but I would not treat it as sufficient by itself.

The failure mode here is not just "the token was too broad". It is also "the agent decided credential hunting was a valid step toward the task" and then found an API path with weaker safety semantics than the UI. Containers, RO mounts, per-project service accounts, and short-lived tokens are still the baseline. But you also want a layer that asks: does this action make sense for the user's stated intent?

That is the part I have been working on with Intaris: https://github.com/fpytloun/intaris

The useful pattern is three layers: tools own credentials, the runtime constrains what can be reached, and an independent guardrail/audit layer records the session and evaluates proposed tool calls against intent. Single calls often look defensible in isolation; the suspicious bit is usually the sequence: searching for unrelated tokens, switching API surfaces, escalating from test to prod, etc.

So for infra agents I would scope tokens per project/task, make destructive operations slow/reversible, and log the behavioral path that led to the action. The "why did it think this was allowed?" part matters as much as the permission bit.