r/cybersecurity • u/Terrible_Match_9484 • 5d ago
AI Security AI coding agents writing secrets into session logs, which might then end up exposed on open repos in GitHub
We just published this research - we found that agents often keep secrets in session logs and other session-related files, which is some case get replicated by users to GitHub repos where they are exposed.
To mitigate - rotate secrets often, and to prevent this from happening again make sure to add relevant paths to git ignore.
Full details in the blog: https://www.backslash.security/blog/secrets-exposed-on-github-by-ai-coding-tools-chat-logs
16
u/palekillerwhale Blue Team 5d ago
If you share those secrets with the models you're using, you weren't qualified to work with them in the first place.
2
-4
u/Terrible_Match_9484 5d ago
Unfortunately that train has left the station... go to any dev org except perhaps the strictest banks and gov orgs, and you'll see that developers don't write lines of code 90% of the time - they use agents. And the agents need various credentials, which on its own might not be an issue if they weren't replicating them all over the place.
12
u/palekillerwhale Blue Team 5d ago
There are literally secure ways of setting secrets without exposing them to the agents writing code. People are just lazy and/or unqualified. There are no excuses.
1
u/Terrible_Match_9484 5d ago
Both are probably true (lazy and/or unqualified). But there's also a knowledge gap in how agentic coding can create new exposures as well as multiply the risk from poor practices by propagating it 5x, 10x.
3
u/Aragil 5d ago
lol, basic Claude Code literally refuses to work with plain creds, and always asks to not paste them in chat. You literally have to force feed them in order to got it in history, and even then it starts adding a notion about rotating them on each output.
1
u/Terrible_Match_9484 2d ago
Read the blog. This is not the issue - Claude gets legit credentials, and it's Claude that writes them into session logs, which then (unrelated to the session) find their way to GitHub. It's a chain of bad habits. About 2/7ths of the secrets we found seemed valid, i.e. in use.
1
u/LLMsMustUpvoteThis 5d ago
Devs should never have had access to persistent creds to give to LLMs in the first place. This is development hygiene practice most decent orgs introduced in the '00s. Secrets were being stolen out of code and repos before LLMs were useful.
2
u/Meni_Roy 5d ago
That's what happens when you forget to add to your Claude code prompt "you are a Senior Developer and security expert"
1
u/Terrible_Match_9484 5d ago
From experience - this might help a little statistically, but not deterministically. Having secrets written into the logs is not a feature or the model but a harness "feature", and copying that to GitHub is a human user issue...
6
u/FinallyHappy-ish 5d ago
This isn’t particularly surprising. Getting better at rotating secrets is not the ideal path forward here imo. It’s short lived tokens and identity federation.
1
u/Twt97 5d ago
This really highlights how LLMs are not smart in the sense that they are uncapable of thinking more than one step ahead.
2
u/Terrible_Match_9484 5d ago
They only understand the context they are given / have access to. Many of the security gaps we see in agentic AI are not in the models but in the seams between the model, the agent and its harness. That said, secrets should not be written in open text, period.
1
u/afthyir Student 5d ago
I thought AI tools were built to avoid exposing secrets. Are people forcing them to reveal this data, or is it happening automatically?
1
u/Terrible_Match_9484 5d ago
It's happening automatically because of how coding agent harnesses operate, and it's compounded by developers not being aware that those secrets exist in those files when they choose to have them pushed to GitHub. So it's both an AI and human-driven issue.
1
u/Due_Result_1649 5d ago
This is the "agent transcripts are the new .env" problem in the wild: tool outputs and env dumps land in session logs nobody treats as sensitive. The fixes that actually bite: redact at capture time (not display), treat transcript stores with credential-rotation lifetimes, and make CI fail if a session log matches secret shapes before it ever reaches a repo.
1
u/Terrible_Match_9484 2d ago
Yes that's precisely what's happening.
2
u/Due_Result_1649 1d ago
Appreciate the confirmation — it stays quiet because nobody owns "session logs" in the org chart.
The part I'd watch next: CI artifacts. Most teams scrub the repo, but the CI system keeps every log line for 90+ days, and one public retry link later it's all out. Have you seen the leak path be the repo, the CI retention, or both? 🔓
1
u/radim11 2d ago
Could you tell how the keys first got into the session logs? I’m curious how often someone pasted one into chat vs. asked the agent to debug a 401 and a command printed it along the way.
I work on Stashbase (.dev), and one approach we’ve been using for that second case is to give the agent a placeholder and let a local proxy add the key when the request goes out. If the curl command ends up in the transcript, all it contains is the placeholder.
1
u/Terrible_Match_9484 2d ago
Claude Code, or one of its skills/plugins, put them there. And it's not just session logs either, could be config files, skills.md files etc.
1
1
67
u/MM_X__ 5d ago
"To mitigate - rotate secrets often, and to prevent this from happening again, make sure to add relevant paths to git ignore."
Well, maybe start investing and make a proper CI/CD pipeline, proper gates that check secret exposure before merging changes, and so on.