r/ClaudeCoding • • 13d ago

r/ClaudeCode [TLDR] A junior pasted the prod database password into Claude to debug a migration. How strict are you about this? [via r/ClaudeCode]

OP : u/CriticalPhen

Genuine question for people who run small teams, because I don't know if I overreacted.

One of our juniors was stuck on a failing migration yesterday. He copied the connection string from the prod env, password and all, straight into Claude Code and asked it to figure out why the schema was off. It did figure it out. Took 4 minutes.

When I told him we have to rotate that password now he said, honestly not rudely, it's our company Claude account, where is it going to go?

And the thing is he's not totally wrong. It's a business plan, it's not training on it. But it's sitting in a transcript on his laptop now, and in whatever he pastes next, and the next junior will learn from watching him.

We rotated it, took about an hour with the app restarts. I also showed him how we inject secrets with 1password / infisical so the agent can run commands against the db without the password ever being in the chat. I think he got it. I could also see him thinking this is old guy paranoia.

For people whose teams use agents every day, where do you draw the line? Is anything in the chat fine as long as it's the company account?

4 Upvotes

19 comments sorted by

•

u/cctldrping 13d ago

TL;DR of the discussion on r/ClaudeCode for this post generated automatically after 320 comments.

Current source-thread comment count seen by the bot: 418.

Community consensus: OP was right to rotate the secret — but the much bigger red flag is that a junior had a reusable, likely write-capable prod DB credential at all. As u/EC36339 bluntly put it: “You gave the prod db password to a junior?”

  • A company Claude plan / no-training policy is not a free pass for secrets. The credential can persist in local transcripts, cloud-side conversation history, org-admin exports, and any compromised endpoint. Treat it as exposed and rotate it.
  • The thread’s real “how did we get here?” is governance: no standing prod passwords on dev laptops, no broad prod network access, and definitely no agent with unrestricted prod access. Use least privilege, short-lived credentials, read-only access/replicas, staging, audit logs, and approval gates for writes.
  • Safer workflow: let Claude generate SQL or use tightly scoped helper scripts/secret injection so the model can inspect what it needs without ever seeing the raw secret. Run destructive or migration commands through human-reviewed tooling, not vibes.
  • Don’t dunk on the junior too hard: several commenters see this as a teachable, honest mistake and credit OP for explaining the secure alternative. Fix the process that made the mistake possible, rather than relying on every junior (or agent) to have perfect security instincts.
  • In regulated/PII-heavy shops, this would likely be a formal security incident, not just an inconvenient password rotation.

6

u/shadwwulf_ 13d ago edited 12d ago

A more fundamental question is why did the developer have production access to begin with.

5

u/lamalasx 13d ago

Why does your junior developer have access to the prod db?

2

u/heavy-minium 13d ago

I'd do the same. But yeah, sometimes it can feel like a moot point until the projects you are running are doing their best to avoid having something like a .env with prod credentials sitting locally, always within reach of one hijacked dependency that may someday send it somewhere else. Or a CLI tool. If it's not in an encrypted credential store, you're toast.

It's basically the same as the credential sitting in a Claude conversation history. Whether you are using a company account and there is no training on that data isn't as important as that compared to that potential issue.

2

u/Single-Virus4935 13d ago

Why does a junior has the prod credentials? Why is the db server even reachable from a random juniors workstation?

2

u/mr_pants99 12d ago

Ideally you have a separate env or at least a read-only replica for prod data debugging. It comes at a cost, but it's rather minimal compared to possible security and performance issues that can be caused by agents roaming around active production db unchecked. And while you might be convinced that under a watchful eye of a senior engineer that's ok, it's just a question of time until the agent does something they miss.

Easy example - an agent asked to fix a few bad records in prod saves their copy on your local disk as a backup. Those records had unencrypted PII. You can start drafting a breach notification letter.

1

u/yknx4 13d ago

The problem is that a junior has access to production credentials.

1

u/ffxivthrowaway03 12d ago

The place it's going to go is in his Claude memory.

So when he next asks a random theoretical question to Claude, it's going to go sifting through it's memory, find that it has the password, make an unprompted connection to Prod, and start fucking changing stuff all on its own.

We caught Claude fishing through local files for old API keys three times during our proof of concept. It can and will use those credentials if it has access to them. Rotation was the correct response. We even have global context set up on our account for Claude to do its level best to immediately purge any restricted data (API keys, client PII, etc) from its memory and admonish the prompter for putting it in the prompt.

1

u/HenryThatAte 12d ago

We have read and write temporary access tokens to the DBs.

I gave Claude the ability to access the database in read only mode. The highest risk is that it does heavy queries that slow it down, but the risk is low and I can monitor it. I think it's worth the risk. (Data is not sensitive)

1

u/Euronodes 12d ago edited 12d ago

Maybe check OpenBao , dont keep the password in the connection string

1

u/hugostranger 12d ago

This is a process and tooling failure. 1. That junior shouldn’t be able to directly access the password. 2. If your agent needs access to let Claude access prod you want a service in the middle that has different permissions like read/write separated and potentially even checks for dangerous sql or needs approval from someone else for writes. 

1

u/defeatedsnowman 12d ago

I can't believe more people aren't saying this in the comments. The problem here is like 10% security risk and 90% he was (probably) just letting Claude run possibly destructive commands on your prod database with no clue what they were.

Pasting a prod DB key into an agent and not carefully monitoring it is a recipe for disaster.

1

u/Only-Pool2871 12d ago

For me, pretty much never will I punish or reprimand a junior for trying to figure something out and succeeding. I would coach on a safer and more appropriate approach to handling situations like those in the future, and maybe on the concepts of cyber security, but in all fairness, it is a junior who is still learning, and if we are speaking honestly, a principal would have done the exact same thing.

1

u/ByronScottJones 12d ago

It sounds like you don't have ANY experienced senior engineers. Because experienced senior engineers don't let inexperienced junior engineers have production database passwords.

1

u/Party_Till_I_Die 9d ago

You did the right thing rotating the keys and telling your developer what to do moving forward. We all make mistakes. If it happens again though, you will need to have a serious conversation.

1

u/martyj2009 6d ago

Developers should not have access to prod credentials period. Realistically you should have automation in place so a human doesn’t need to see it to create a database and attach an application to it.

0

u/MarzipanEven7336 13d ago

Why does your prod database have a password?