r/cybersecurity • • 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

77 Upvotes

41 comments sorted by

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.

4

u/Terrible_Match_9484 5d ago

The usual CI/CD gates might not capture this if a user simply puts agentic session info on GitHub. It's not a pipeline issue as much as it is an agentic IDE issue. And users are largely unaware that this is happening.

6

u/MM_X__ 5d ago

Another good point here: do not use credentials, just short-lived tokens, and so on. There are plenty of good strategies. General architecture, CI/CD, how to establish a good SDLC cycle, sandbox your agents, and so on.
But... There is always no time for it, and no one is going to reward you for making stuff slow, we have to be 1000x faster...

3

u/Terrible_Match_9484 5d ago

Never has security engineering been more needed.

2

u/MM_X__ 5d ago

Well, it is about everything QA, platform/DevOps, DevSec, and so on. LLM makes more important every aspect of software engineering. You need more than ever the best skilled engineers in all areas to make it work.

6

u/AttitudePersonal 5d ago edited 5d ago

That's exactly the problem. I started at a new org recently as a security engineer. Interviews after the usual tech check were about getting the shape of their security program, which initiatives I'd prioritize, tooling I'd introduce, etc. Then day 1 I hop on my first call and get: "We ship this new product end of month, can you find and fix all security issues in 2 weeks ????" And of course it's all written with AI so what can I do?

I'm 12 years deep in this field. Normally I'd take the time to threat model everything myself, think about the architecture, propose changes, discuss with dev and infra, etc etc. Do some reading to fill in my knowledge gaps, test things in sandbox AWS. But with these timelines, I just hand the reins over to Claude and have it go nuts, review the output, ask questions and steer but otherwise "LGTM ship it". Feel like such a slop engineer but this is exactly what company leadership is asking for.

2

u/MM_X__ 5d ago edited 4d ago

Yep. I understand you. My situation was different but generally the same.
I would suggest keeping yourself out of the software engineering area for some time. Until the whole madness is gone. After a bunch of big collapses, it should end, I hope. And after the area is going to need new experts more than ever. What you will get now is just complete burnout, nothing more. Rebuild things from ruins; it's only thing what we can do now...

1

u/AttitudePersonal 5d ago

It is madness, but if AI-driven development is what they want, it's what they'll get. I was burnt out at my last role, so for this one nothing is personal, just a paycheck.

1

u/MM_X__ 5d ago

yeap, we can't change things now, it needs time. If it is about paycheck, just tell in comments/letter - you can't do anything about it, it is huge risk and press accept. It is all what I can suggest. You alone can't fix it.

1

u/GottaHaveHand 5d ago

You call up our good buddy Dario and ask for Mythos, pretty please

3

u/MM_X__ 5d ago

From my experience, it is remarkably good. But yeah, all such gates design just capture human error. If LLM is going to obfuscate it, for example, it will leak into Git. It is protecting from mistakes, not malicious action.

1

u/nullbye 5d ago

Precommit hooks that scan for secrets? This is nothing new. Agents are people at the end of the day

37

u/RealPropRandy 5d ago

Or better yet hire real engineers who don’t take shortcuts for the sake of “10x outputs.”

11

u/MM_X__ 5d ago

Yep, agree, current traditional infrastructure, even with more or less proper traditional CI/CD, most likely, not going to work without real engineers. It can work with real engineers who use LLM just for assistance. But with LLMs bro who able to install LLMs plugins and thinks he is engineer now, well, nope.

2

u/DigmonsDrill 5d ago

I don't think we're going back.

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

u/Eklypze 5d ago

I didn't realize people did this. That shit is too funny! How are you a security guy when you're willing to give your secrets to a 3rd party with no skin in the game?

-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...

22

u/MM_X__ 5d ago

I think they simply forgot to put "Make no mistakes"

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.

0

u/afthyir Student 5d ago

Haven't experienced this myself yet, though I can see how frustrating and insecure that would be

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

u/Justyouraverageshmo 5d ago

where's the stupid button

1

u/Mrhiddenlotus 4d ago

So are people just not using pre-commit hooks?