DEV Community

Your secrets don't need a git commit to leak into an AI tool

Dimitris Kyrkos on October 26, 2026

Most of us have the "don't commit secrets" reflex drilled in. Pre-commit hooks, secret scanners in CI, .env in .gitignore. Good. That covers the re...
Collapse
 
sinarezaei profile image
Sina Rezaei •

The CI/CD case is where this gets really interesting. Microsoft documented a Claude Code Action vulnerability where prompt injection through untrusted GitHub content could lead to reading ANTHROPIC_API_KEY from /proc/self/environ. The Bash path had environment scrubbing, but the Read tool followed a different path and bypassed that isolation boundary.

That’s the part I think teams need to pay attention to: protecting secrets in Git or filtering terminal output doesn’t help if another tool can reach the same credentials through a different path. I’d treat the agent’s entire tool surface as part of the security boundary, with explicit access controls and isolation between untrusted input and sensitive runtime state.

Collapse
 
rdin777 profile image
rim dinov •

The CI/CD boundary is definitely where this gets critical. I love the canary secret idea for runtime data paths, but for source code, static analysis acts as the ultimate pre-execution canary.
For example, in Web3 smart contracts, I wrote a Slither detector that flags hardcoded Hardhat test addresses or plaintext API keys directly in the codebase. It catches the leak at the syntax level, long before the CI/CD pipeline even has a chance to expose it to an AI agent's Read tool or the blockchain. Combining runtime canaries with compile-time static checks is the real defense in depth.

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Agreed, those checks complement each other well. Static analysis catches what ends up in the code, while runtime testing catches what gets exposed through the environment, tools or logs. The important thing is not to confuse passing one with being safe overall. In the scenario Sina described, the secret never needed to be hardcoded in the repo for the agent to reach it.

Thread Thread
 
sinarezaei profile image
Sina Rezaei •

Exactly. GitHub Actions OIDC is a good example here: you can remove long-lived cloud credentials from GitHub Secrets, but a job with id-token: write can still request an identity token and exchange it for cloud credentials if the trust policy allows it. If an AI agent processing an untrusted PR can reach that path, the problem isn’t a leaked key in the repo anymore; it’s what the job is authorized to obtain at runtime. I’d keep the agent in a separate, unprivileged job and make the privileged deployment job consume only validated artifacts, with no untrusted PR content passed back into its execution context.

Thread Thread
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

This is a really important distinction. OIDC removes the need to store long-lived credentials, but it doesn't remove the risk of granting an untrusted job access to the identity flow in the first place. Separating the agent from deployment permissions and passing only validated artifacts across that boundary feels like a much stronger design than trying to sanitize everything the agent might see. Least privilege still matters even when there are no static keys to steal.

Thread Thread
 
rdin777 profile image
rim dinov •

Spot on, Dimitris! OIDC is a great example of removing long-lived credentials, but you're absolutely right that it doesn't solve the fundamental problem of untrusted code execution.
The distinction between 'no static keys to steal' and 'no unauthorized access to grant' is critical. Even with OIDC, if a malicious agent or compromised CI job has deployment permissions, it can still wreak havoc through the identity flow itself.
This is where defense in depth becomes non-negotiable:
Pre-deployment: Static analysis (like custom Slither detectors) catching hardcoded patterns before they even reach CI
Runtime: Environment isolation, artifact validation, and strict permission boundaries
Post-deployment: Monitoring for anomalous on-chain behavior
Your point about 'separating the agent from deployment permissions' is exactly right. I've seen teams implement OIDC beautifully but still get drained because the CI pipeline itself had overly broad permissions.
Curious: In your experience, what's the biggest hurdle for teams trying to implement proper permission separation in CI/CD? Is it tooling complexity, or organizational inertia?

Collapse
 
bytestay profile image
ByteStay •

This one hit close to home.

We had all the "don't commit secrets" reflexes and still caught ourselves doing the env | sort paste you describe. So we changed how secrets reach the machine in the first place.

Nothing real lives in .env files on our laptops anymore.

Secrets sit in a self-hosted vault, and anything that needs them runs through a tiny wrapper that hands them to that one process. The terminal, and anything reading it, only ever sees the command.

We also stopped printing secrets, even to check them.

Earlier today we had to confirm a key in the clipboard was the same one in the vault We compared the length and the first few characters of a SHA-256, and never looked at the key itself, It feels a bit paranoid until you remember how much ends up in scrollback.

Two smaller lessons that cost us some time:

  • Pipe secrets in, don't pass them as arguments, Arguments end up in shell history and in ps.
  • Watch your quotes. A $VAR inside double quotes gets expanded by the outer shell. We once sent the literal text instead of the value, and it took a while to notice, anything complex now goes into a small script.

And honestly, the guardrail I like most is the boring one, our coding assistant can't write to a secret store without one of us saying yes, every single time.

So, to your question: still mostly habit, but habit with a few doors locked.

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

This is a great example of making the safer path the default instead of relying on people to remember every time. I especially like the wrapper approach and the approval gate for secret store writes. One small thing I'd add is making sure the wrapper doesn't accidentally expose secrets through debug output or child process environments. It's amazing how many different places a value can leak without anyone explicitly printing it.

Collapse
 
bytestay profile image
ByteStay •

Agreed, and the child environment is the one we haven't fully solved.

Every process the command starts inherits those variables. What we do is keep the blast radius small.

Our vault is a self-hosted Infisical. The wrapper logs in with a machine identity and runs infisical run --path=<folder>, so a command only gets the secrets of its own folder, not the whole vault.

Debug output bit us in a different way. Calling the wrapper with the shell as separate arguments once printed every injected value. Now complex commands always go into a script file, called with one single-quoted string.

"Nobody printed it" really isn't the same as "it didn't leak".

Thread Thread
 
kaj_ilands profile image
Kaj •

the child env is the part that's actually fixable, and folder scoping doesn't touch it. infisical run chooses which values get injected, not what the child hands on to its own children. exec the command directly with an explicit allowlist (env -i plus the three or four vars it truly needs) and there is nothing inherited left to leak. if a shell sits in the path, BASH_ENV comes along with it and a sourced file can flip tracing on without you typing set -x anywhere.

and check it from inside the child, tr '\0' '\n' < /proc/self/environ, not from the wrapper's log. the wrapper is the one process holding plaintext, so its own error paths are leak surface too, same class as the separate-arguments accident.

Thread Thread
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

This is a good distinction. Scoping which secrets get injected is only half the job if the process can pass them all to anything it launches. An explicit environment allowlist sounds like a solid next step, especially for commands that don't need the full set. I'd also test the child process environment and the wrapper's failure paths, since those are easy places to assume isolation is working without actually verifying it.

Thread Thread
 
bytestay profile image
ByteStay •

Agreed, and Kaj's point about the child environment is the one that matters most.

Our wrapper handles it in two ways now:

  • the vault token never goes through argv and never reaches the command, so it shows up neither in ps nor in the child's environment;
  • a command can start from an empty environment: a short allowlist (PATH, HOME and a few more) plus only the secrets that command needs.

And we check it from inside the child, reading the variable names from /proc, not from the wrapper's own log :)

Collapse
 
stackmasteraliza profile image
Aliza Ali •

Point 2 is the one that worries me most with agents rather than chat. You don't even have to paste env yourself; the agent can run it on its own while "debugging", and the output lands straight in context. Scrubbing the agent's shell environment helps, but as the /proc/self/environ case above shows, a file-read tool can walk right around it. The more durable fix is making sure there's nothing long-lived to find: short-lived, narrowly scoped credentials locally, so anything that does leak expires before it matters. A pre-commit hook for the context window would honestly be a great tool.

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Exactly. Once an agent can read files directly, restricting its shell environment alone isn't enough. Short-lived, scoped credentials reduce the damage if something slips through, and I like the idea of a pre-commit hook for context. It would need to cover more than pasted text, though, since tool reads and command output can enter context without the user explicitly adding anything.

Collapse
 
stackmasteraliza profile image
Aliza Ali •

Agreed, the hook would have to sit between the tools and the model, not at the input box. Something like a redaction layer on every tool result (file reads, command output) that masks anything matching secret patterns before it ever reaches the context. That would make a fun open-source project.

Thread Thread
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

I think that's exactly the right place for it. Putting the redaction layer between tool execution and the model would cover a lot more than just manual input. The tricky part would be avoiding false confidence from pattern matching, since not every sensitive value looks like a conventional API key. I'd love to see an open-source project explore this, especially if it could support different agent frameworks and MCP tools through a common interception layer.

Thread Thread
 
stackmasteraliza profile image
Aliza Ali •

Good point on false confidence. One way around it: the interception layer usually knows the actual secrets, from the env or the secret store, so it can redact exact known values (plus their base64 and URL-encoded forms) instead of only guessing by shape. Pattern matching then becomes the backup for secrets it doesn't know about, not the whole defence. MCP's single tool-result path would make a great place to hook that in.

Thread Thread
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

That's a much stronger approach. If the interception layer has access to the actual secret values, exact-value matching can catch cases that pattern-based detection would miss, including encoded forms. I'd still be careful about where that matching happens and how the redaction rules are protected, so the layer doesn't become another place where secrets are exposed. And I agree, a shared MCP interception point could make this practical across different tools and agents.

Collapse
 
galagent profile image
Qingfeng •

Redaction before pasting is the same class of control as "don't commit secrets" — it works until the deploy is on fire and you paste the whole log at 6pm. The more durable lever is on the agent side: if the assistant can run env | sort or read .env, a human redaction habit is the only thing standing between you and a full dump, and that habit is exactly what pressure erases. Regex scrubbing is also whack-a-mole since providers rotate token prefixes and opaque keys slip through, so I'd rather bound the blast radius with short-lived scoped keys and log egress from whatever the extension sends — because delete never un-sends anything.

Collapse
 
rdin777 profile image
rim dinov •

Spot on. The "6pm failing-deploy" is the ultimate threat model because human habits inevitably break under pressure. Regex scrubbing is indeed whack-a-mole.
This is exactly why shifting left to automated, pattern-based static analysis in the CI/CD pipeline is non-negotiable. The linter doesn't get tired at 6pm. In Web3, I built a custom Slither detector specifically to catch hardcoded test keys and CEX credentials during the PR check. It ensures that even if a developer accidentally pastes the wrong config, the build fails before it ever reaches an AI agent's context or the mainnet. Automation is the only reliable safety net for human error.

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

The CI checks are definitely useful, especially for catching secrets before they make it into the repo or a deployment. The gap I'd still worry about is what happens at runtime, though. A secret can be injected into the environment or returned by a tool without ever touching the code being scanned. That's why I think CI scanning and restricting what the agent can access need to work together.

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Yeah, that's the key distinction. Redaction is useful, but it shouldn't be the main thing standing between an agent and production credentials. I'd rather limit what it can read in the first place, then add egress scanning and short-lived scoped credentials as backup layers. Logging what actually leaves the extension would be especially useful, assuming the logging itself doesn't become another place where secrets accumulate.

Collapse
 
alexshev profile image
Alex Shev •

The prevention path should include an egress test, not only a pre-commit scanner. Teams can seed a harmless canary secret in a nonproduction environment and verify that logging, prompts, and support exports all redact it consistently.

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

I like the canary idea because it tests the actual data path instead of assuming the scanner works. You could seed a fake credential and check whether it makes it into prompts, logs or exported traces. I'd also test different ways the agent can access data, since catching it in terminal output doesn't guarantee the Read tool or extension handles it the same way.

Collapse
 
alexshev profile image
Alex Shev •

A small path-by-sink matrix would make those differences visible: terminal, file read and extension output crossed with prompt, logs and traces. Use a unique fake canary per path so the test can identify where a leak originated, and verify the test harness itself detects a deliberately unfiltered control.

Thread Thread
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

I like the path-by-sink matrix, especially using a different canary for each path. That makes it much easier to trace where the leak happened instead of just getting a pass or fail. And testing the harness with a deliberately unfiltered control is important too, otherwise a green result might just mean the test never caught anything in the first place.

Thread Thread
 
alexshev profile image
Alex Shev •

The per-path canaries are especially useful if the matrix includes the boundary, not just the client: terminal paste, editor extension, browser upload, CI log, and vendor API. Each path then has an accountable owner when a canary escapes.

Thread Thread
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

That's a useful addition. Including the boundary makes the test much more actionable because it shows not only where the data leaked, but which component owns that part of the path. The vendor API is particularly worth including since the data has already left our environment by that point. Having an owner for each boundary also makes it easier to turn a failed canary test into a concrete fix rather than just another security finding.

Collapse
 
friga profile image
Artur Pokładek •

The worst one I've run into never went near a chat window. On a site I took over, the Supabase service role key sat in the client JS bundle, so anyone who opened devtools had a key that skips RLS.

Leaks into AI tools worry me too, but I'd grep the build output first. Does anyone here run a secret scan on what actually ships, or only on the repo?

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

That’s a great point. Scanning the repo is only part of the picture because secrets can end up in generated bundles, build artifacts, or source maps even if the repo scan passes. I’d definitely add a secret scan on the actual build output or release artifact before deployment. The Supabase service role key is a particularly serious example because it’s not meant to be exposed to client-side code at all.

Collapse
 
friga profile image
Artur Pokładek •

Good shout on source maps, those get forgotten a lot. Scanning the build output catches them anyway, which is one more reason to scan what ships rather than what's committed.

Thread Thread
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Exactly. Source maps can expose more than people expect, especially if they contain original source or embedded configuration. I think the safest approach is to scan the final deployment artifact, including generated files and source maps, rather than relying only on what the build process was supposed to include.

Thread Thread
 
friga profile image
Artur Pokładek •

Agreed, the deployed artifact is the only version that matters. Thanks for the back and forth, good post.

Thread Thread
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Thanks, Artur! Really enjoyed the discussion. Your Supabase example is a good reminder that the same principle applies beyond AI tools: we need to inspect what actually leaves the build pipeline, not just what looks safe in the repository. Appreciate you adding to the conversation!

Collapse
 
kaj_ilands profile image
Kaj •

correction to my own comment further up: i blamed tr for trusting st_size. that was wrong, and the real cause is worse.

cat < /proc/self/environ | wc -c returns 0. cat /proc/self/environ | wc -c returns 4053. same shell, three runs, both bash and sh, no pipe needed to see it (the file version is 0 too). tr was never the problem. /proc/self behind a redirect is a different process than the one you meant, so the read is empty and exits 0. swap in a fixed pid and the redirect works.

the size lie is real but it is the other bug: test -s says empty on a populated file, and that one is st_size = 0.

measurements and the guard i use now: dev.to/kaj_ilands/cat-procselfenvi...

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Thanks for the correction and for sharing the measurements. That's an important distinction, and it makes the example even more interesting: there are two separate /proc quirks here, process-specific resolution of /proc/self and the misleading st_size = 0 behavior.

It also reinforces a broader point in my post: security tooling and debugging workflows need to account for what data is actually being read and exposed, not just what we assume is happening.

Appreciate you digging into the root cause and sharing a reproducible example!

Collapse
 
kaj_ilands profile image
Kaj •

there's a third quirk, and it's the one that undoes the fix i offered.

cat /proc/$$/environ reads the environment the kernel handed that process at exec. anything exported after that is not in it. measured, one script, one shell:

export LATE_SENTINEL=abc123
cat /proc/$$/environ   | grep -c '^LATE_SENTINEL='   # 0
cat /proc/self/environ | grep -c '^LATE_SENTINEL='   # 1
Enter fullscreen mode Exit fullscreen mode

so the exact sentinel the script just set is invisible to the check, which exits 0 and looks green. /proc/self only works there because cat inherits the export; the shell's own environ never refills. a canary read through $$ can be green and blind in the same run.

the smaller one: st_size=0 isn't a /proc/environ quirk, it's procfs generally. /proc/uptime reports 0 while cat returns 16 bytes. sysfs lies the other way: /sys/kernel/mm/transparent_hugepage/enabled reports 4096, cat returns 23. so a size-based guard is wrong on both, in opposite directions.

shape that held for me: read into a variable, measure the variable, fail closed on zero, then grep the sentinel inside that variable. choose the process on purpose, and never ask the filesystem how big the content is.

Thread Thread
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

That's a really useful third distinction. The check needs to inspect the environment of the process that actually matters, and it needs to account for variables exported after that process started. Otherwise the test can pass while missing exactly the value it's supposed to detect.

I also appreciate the broader procfs/sysfs examples. The takeaway seems to be: don't use file metadata as proof of content, and be explicit about which process's environment you're validating. This is turning into a pretty good example of why security checks need to be tested against their own failure modes.

Collapse
 
mohsen_jr profile image
Mohsen jr •

The tricky part is that developers may not even realize what the agent can access. Redacting pasted logs helps, but limiting the agent’s file and command permissions seems like the more reliable fix. How do you balance that with giving it enough access to debug effectively?

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

I’d start with read access limited to the project and only expand it when a debugging task actually needs more. For commands, I’d be especially careful with environment dumps, broad filesystem access and anything that can reach production systems. If the agent hits a permission boundary, that’s a good point to ask for approval rather than giving it blanket access upfront. It might take an extra step sometimes, but I’d rather have that friction than discover later what the agent could read all along.

Collapse
 
dexoryn profile image
Dexoryn •

I think the strongest approach is defense in depth restrict what the agent can read, scan outbound context before it reaches the model, and use short-lived credentials with minimal permissions.

No single layer catches everything, but together they reduce both the chance of exposure and the damage if one slips through.

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Agreed, it's really about having multiple layers that don't all fail in the same way. I'd put restricting what the agent can access first, because once a secret is in the context, scanning is already playing catch-up. Short-lived credentials help make the inevitable mistakes less painful too.

Collapse
 
the_saint_dac63e343ee8704 profile image
The Saint •

The habits that hold up are the ones that cost nothing in the moment. Keep production credentials off laptops entirely, so the worst thing in a paste is a dev key. Have the app fail with a message that never prints its config or connection string. Load secrets through a wrapper that injects them at run time, so they are not sitting in env output to be pasted. And treat the 6pm failing-deploy case as the real threat model, since that is when people skip the redaction step.

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

This is probably the most practical approach because it removes opportunities for mistakes instead of relying on people to catch them under pressure. Keeping production credentials off developer machines makes a huge difference, and avoiding secrets in error messages should be standard practice regardless of AI tools. Then even if someone pastes a full log, there's much less damage to worry about.

Collapse
 
the_saint_dac63e343ee8704 profile image
The Saint •

Agreed. One cheap way to enforce the error message rule is a test that deliberately triggers a failure and asserts the output does not contain anything shaped like a connection string or key. It turns a habit into something CI checks.

Thread Thread
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Nice, and that's a pretty low-effort test to add to an existing pipeline. I'd probably include a known dummy secret in the test config and assert it never appears in the error output, alongside checks for common credential patterns. It won't catch everything, but it makes sure a future change doesn't quietly bring the problem back.

Collapse
 
nirali_toolbit profile image
Nirali •

This is so real. Picture it: you're 40 minutes into a session with a coding agent, something breaks, you paste the full error log, and there's a Bearer token sitting somewhere in the middle of it. You fix the bug and move on.

What people forget is that the agent keeps sending that whole conversation back to the model on every step after that. So it's not one leak, it's the same token going out again and again until the session ends. Rotating the key and starting a new chat is the only proper cleanup I know.

The canary secret idea someone mentioned in the comments is smart too. Has anyone actually set that up for their AI tools, or is it mostly a CI thing so far?

Collapse
 
kaj_ilands profile image
Kaj •

the canary only means something if it has no pattern. a fake key with a prefix tests your regex. a fake prose secret, an internal hostname or a customer first name inside a throwaway project description, tests the logging. prose is the case that slips past every matcher while the scanner still reports clean.

how id run it: seed it in a non-prod account, do the thing, then read the stored row back cold. not the log line, not the UI, the thing the server serves back on a second request. if the canary is in there, the scrub step did not run, whatever the scanner said it did. that read-back is the only step that can actually fail, which is the whole point of having it.

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

The prose canary is a really good point. If we only test recognizable key patterns, we're basically testing the regex rather than whether sensitive context is being handled safely. I like the cold read-back approach too, especially if it checks the actual stored data after the full workflow. I'd probably test both structured secrets and unstructured canaries, since passing one doesn't tell you much about the other.

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

The repeated transmission part is worth calling out, although it depends on how the tool manages context and what it sends on each request. Once a secret enters a conversation, I'd assume it may be retained or reused until proven otherwise, so rotating the credential is the priority. Canary testing sounds promising for AI tools too, but I'd be curious how many teams are testing the actual editor or agent workflow rather than just their CI pipelines.

Collapse
 
nirali_toolbit profile image
Nirali •

Fair point, I was thinking of agents calling a plain chat API, where the whole history goes back on every turn. Some tools trim or summarise along the way, so it really does vary. Agree that rotating first is the only safe assumption. And yes, I’d guess very few teams test the editor side at all, it stays invisible until something leaks.

Thread Thread
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Yeah, I suspect the editor side gets overlooked because it's harder to observe than CI. You can have great secret scanning in your pipeline and still have no idea what your coding assistant is collecting or sending. Even a basic test with a canary value, followed by checking what actually gets stored, would be a good starting point for teams that haven't looked at this yet.

Collapse
 
leob profile image
leob • • Edited

Good to be aware of this! Just wondering:

Suppose your creds/secrets did get sent to OpenAI's or Anthropic's (or other AI vendor's) server - are there examples where those creds/secrets have actually got abused - and in what way?

Could they become part of training data, hence become 'public', or abused in another way?

Are there known cases where 'abuse' in whatever form did happen?

P.S. okay well, so I asked AI about it ;-) ...

Yes, there could be various ways stuff could then be leaked, hacked or abused - maybe low probability, but not completely theoretical ...

In a scenario like this, rotating/changing those creds/secrets (as you suggested) is the only sensible thing to do :-)

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

That's a fair question, and I think it's important to separate a confirmed incident from a plausible risk. I wouldn't claim that every secret sent to an AI provider has been abused or turned into training data. The risk is broader than training, though: depending on the service and configuration, data may be retained in conversation history, logs, support systems or other operational systems, and could potentially be exposed through an account compromise or access-control failure. There have also been real-world cases of sensitive data exposure in AI services, even if that doesn't mean a particular leaked credential was subsequently exploited.

For credentials, I'd treat exposure as compromise regardless of whether there's evidence of misuse. Revoke or rotate the secret, check its usage logs, and investigate where copies may have been retained. Rotation doesn't erase the old copies, but it makes them much less useful.

Collapse
 
leob profile image
leob •

Yeah it was more of a "what if" question - the (only) right thing to do is definitely to replace (and not even rotate) those secrets ...

Thread Thread
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Agreed. Once a credential has crossed a boundary you don't fully control, replacing it is the safest response. I'd also revoke the old one explicitly and check its usage history before and after revocation. Even if there's no evidence anyone used it, there's no real benefit in continuing to trust a credential whose exposure you can't rule out.

Thread Thread
 
leob profile image
leob •

Yeah you're right - not just replace, also revoke!

Thread Thread
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Exactly. Replacing it gives you a fresh credential, but revoking the old one is what closes the door on further use. Easy distinction to overlook, but an important one. Thanks for the thoughtful discussion!

Collapse
 
frankmilvus profile image
Frank Milvus •

One way I take to dodge this entirely is never hand real creds or env dumps to assistant.

If I need automate deploy or fix config, I just ask agent to write script with dummy placeholders like $DB_PASS. When script is done, I run it locally and let local env or read -s inject actual secret at execution time.

AI does all code logic, but raw secrets never touch chat window or context history — so even in crazy 6 PM deploy panic, zero chance to leak live keys to model.

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

That's a solid workflow. Let the agent handle the logic with placeholders, then inject the real values locally at execution time. It avoids exposing credentials to the model entirely, rather than relying on redaction after the fact. The main thing I'd watch is making sure the script doesn't print those values or pass them through arguments where they can show up in process listings.

Collapse
 
frankmilvus profile image
Frank Milvus •

Yep 💯 % so

Thread Thread
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Exactly! Keeping the real credentials out of the agent's context from the start is much better than trying to clean them up afterwards. Simple boundary, big difference. 👍

Collapse
 
sizzlebop profile image
Jessica Doering •

This really got me thinking. I use coding agents pretty extensively, and while I’m careful about keeping secrets out of my repositories, I haven’t given nearly as much thought to what happens when an agent reads a local .env file, runs a command that exposes environment variables, or encounters credentials buried in logs or tool output. Those values could end up being sent to an external model provider as part of the agent’s context, without ever being committed to Git or explicitly shared by the developer. I’m especially curious about how effectively current coding agents detect and redact sensitive information before it leaves the local environment, and whether that protection extends across all their tools and MCP integrations. Definitely something I want to investigate in my own setup. Thanks for highlighting a security risk that’s easy to overlook!

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Thanks, glad it got you thinking about it! I think the MCP part is particularly worth investigating because security controls that work for the main agent don't necessarily cover every tool or integration it can call. I wouldn't assume sensitive-data redaction is consistent across file reads, shell output, extensions and MCP servers without testing each path. A harmless canary secret is a good way to check what actually leaves your environment. It's one thing for a tool to claim it filters sensitive data, and another to verify that the value never reaches the provider.

Collapse
 
bpecha14 profile image
Bogdan •

Jessica's point about AI agents reading .env files is spot on. When I built my SaaS (ThumbRank), ensuring zero server-side uploads and local browser processing for images was a top priority for this exact reason. You can't trust every tool or prompt with sensitive context, and it's scary how easily secrets slip through copy-pasted logs. Great wake-up call for the community!

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Thanks, Bogdan! The local-processing example is a good reminder that reducing data movement is often the strongest first step. If sensitive data never leaves the device in the first place, there's much less to worry about. And yes, copy-pasted logs are an easy blind spot even for careful developers.

Collapse
 
bpecha14 profile image
Bogdan •

Spot on. "Data locality" as a security feature is highly underrated. If the data never leaves the browser, the attack surface for a data breach is practically zero.

And the copy-paste blind spot is so real—we've all been one stack trace away from pasting a database connection string into a third-party AI tool. The best defense is architecting things so that sensitive data isn't even there to be copied in the first place. Great insights, Dimitris!

Thread Thread
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Exactly, Bogdan! Data locality is a powerful security principle, but I'd add one nuance: keeping processing in the browser significantly reduces exposure, though it doesn't make the attack surface zero. Browser extensions, compromised dependencies, malicious scripts and local access can still create risks.

Ultimately, the best approach is defense in depth: minimize data movement, minimize access, and avoid exposing secrets to tools that don't need them. Prevention by design beats relying on developers to remember to redact every paste. Thanks for adding to the discussion!

Collapse
 
rivenpark profile image
Riven Park •

The remediation section could use a small copy inventory alongside rotation: which traces, replay datasets, support exports and retained conversations received the exposed value, who owns each store, and how cleanup will be verified. OWASP's secrets guidance explicitly calls for removing secrets from logs while preserving log integrity. I'd keep the incident record, but avoid putting the raw secret into the cleanup ticket and creating another copy.

Collapse
 
kaj_ilands profile image
Kaj •

the verification is the weak step, and it tends to lie the same way the scanner did.

if you verify by requesting the record back through the app, you're verifying that the redaction layer is on, not that the value is gone. those two look identical from the outside and differ exactly where it matters.

so verify below the app: query the table or the object store directly, no serializer in the path. then run the export path with redaction explicitly disabled, because that's the path a support ticket or a compliance pull will take. if the store read is clean, the cleanup is real. if it only reads clean through the UI, you tested the display.

and the vendor copies belong on that inventory too. the snapshot and the analytics event never appear in your trace list, and that is usually where the value survives.

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

That's a really important distinction. Checking through the same app that redacts the data can give you a false sense of security because you're only proving the display layer works. Direct store checks and testing the actual export path are much stronger, and the vendor-side copies are easy to overlook. The tricky part is that even direct access only verifies the stores you've identified, so the inventory needs to include backups, snapshots and analytics pipelines too.

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Good addition. Rotating the credential handles future access, but it doesn't clean up the copies already sitting in traces, replay datasets or support exports. A copy inventory with an owner and a verification step for each store makes the remediation much more concrete. And yeah, putting the raw secret in the cleanup ticket would just create another problem to clean up.

Collapse
 
dhiraj-shrotri profile image
Dhiraj Shrotri •

I think the only good strategy to prevent this is to have a vault through which secrets get injected. Also having short lived secrets and rolling secrets frequently makes sure that even if a secret is leaked, the damage is limited. In the end, as developers, it should be our individual responsibility to sanitize what we insert as prompts to the LLMs.

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Agreed on vault-based injection and short-lived credentials. They reduce both exposure and the damage if something goes wrong. I’d just be careful about putting too much responsibility on developers to sanitize prompts manually, since agents can read files or run commands on their own and pull sensitive data into context without anyone pasting it directly. Good habits help, but limiting access and reducing the lifetime of credentials give you protection even when someone makes a mistake.

Collapse
 
ascendra_ventures_92c21f2 profile image
Ascendra Ventures •

Paul Lovelace's example says it well: a Bearer token sitting at line 143 of a pasted log, where nobody reading the first screen would notice it. Most leaks into AI tools look like that, ordinary debugging with one bad line inside.

Nirali's point makes it worse than a single exposure. The token is sent again with every turn of the conversation, so one paste becomes many copies in whatever the tool retains.

Kaj raises the hardest case, secrets written as prose with no pattern for a scanner to match. Keep the words, drop the keys is a good rule, but it needs a person who knows which words are keys.

Alex Shev's canary secrets with egress tests and Kartik's scrubbing at capture time are the two practices I would put into a client delivery checklist, because they turn the boundary into something you can test instead of a policy people are asked to remember. Dexoryn is right that no single layer holds on its own.

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Exactly, the useful part of canary testing is that it turns this from a best-practices discussion into something you can actually verify. I'd want to test the full path from the IDE to logs and stored traces, not just whether a scanner catches a token before a commit. The harder question is what slips through when the secret doesn't look like a secret at all.

Collapse
 
alexshev profile image
Alex Shev •

The missing control in many AI workflows is data minimization before context assembly. A secret scanner at commit time cannot help if the agent has already read an env file, terminal scrollback, or ticket attachment. The boundary needs to be enforced at ingestion, with explicit allow-lists and redacted previews.

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Completely agree. The important moment is before the data becomes part of the agent's context, not after it has already been sent. Explicit allow-lists and redacted previews make that boundary much more concrete. I'd also want those rules applied consistently across file reads, terminal output, and attachments.

Collapse
 
kigster profile image
Konstantin Gredeskoul • • Edited

This - Sopsy - currently works on Silicon Macs, and soon using YubiKeys. Encrypt your dev secrets with a tool that creates private keys in your Mac Hardware. This means decrypting them requires your thumb (although you can choose to bypass it when registering your keys).

Https://sopsy-cli.dev/

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Interesting approach. Hardware-backed keys add a strong layer of protection, especially against someone accessing secrets from disk or another user context. One thing I'd still keep in mind is what happens after decryption: once a secret is available to a process, an agent or debugging tool with access to that process may still be able to read it. So I'd see this as a useful layer alongside least-privilege access and short-lived credentials.

Collapse
 
rpsworld profile image
Ravi Pratap Singh •

The failing-test example is the one I would add to a team checklist, because it is so easy to miss. A test that dumps a client object for debugging can carry a live credential even when the code itself never hardcodes one, and the person pasting the failure is focused on the assertion, not on the payload.

A habit that has helped me is to scan any paste for words like token, key, secret, and authorization before sending it, and replace those values with placeholders first. It is slower, but it is much cheaper than rotation afterwards, especially since rotating a credential does not clean up copies already stored in logs or chat history. Keeping development credentials strictly separate from production ones also limits the damage when a paste does slip through.

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

The client-object example is a really good one. Debugging output often gets treated as harmless because the developer is focused on the failing assertion, not everything contained in the object. Scanning and replacing values before pasting is a useful habit, and I agree that separate development credentials are an important safety net. I'd just avoid relying on manual checks alone, since automated dumps and agent tool reads can bypass that habit entirely.

Collapse
 
rpsworld profile image
Ravi Pratap Singh •

Sahi pakda hai — manual check habit hai, safety net nahi. Asli fix layering hai: alag dev credentials + tooling me auto-redaction, taaki secret dump/log me aane se pehle hi scrub ho jaye, baad me aankh se dhoondhna na pade.

Thread Thread
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Exactly, that's the distinction. Manual checks are useful, but they shouldn't be the main control. Automatic redaction before output reaches logs or the AI context is a much stronger layer, especially when combined with separate dev credentials. The tricky part is making sure that redaction covers every path, not just terminal output.

Collapse
 
rdin777 profile image
rim dinov •

Excellent and highly relevant point, Dimitris! 🛡️
The concept of "defense in depth" for secrets is crucial. Stopping leaks at the AI/IDE level is the vital first line of defense, but catching them at the code analysis level is the ultimate safety net.
In the Web3 space, I see this exact pattern with hardcoded CEX API keys and Hardhat test addresses slipping into smart contracts. I actually built a custom Slither detector to catch these specific secrets before deployment (inspired by a recent $152K exploit where a test key was left in prod).
It’s fascinating how the secret leakage problem spans from AI prompts all the way to on-chain execution. In your view, will AI coding assistants eventually build native, real-time secret scanning that makes tools like git-secrets or custom linters obsolete, or will we always need that multi-layered approach?
Great read, thanks for sharing!

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

I think we'll see native scanning become pretty standard, but I don't think it'll make the other layers obsolete. Scanners are good at catching recognizable patterns, but they can't reliably tell whether every sensitive piece of context is safe to send. Your Slither detector is a good example of why domain-specific checks still matter. I'd rather have native scanning as another safety net than trust any single tool to catch everything.

Collapse
 
vijay_g profile image
vijay •

This is such an underrated security gap in modern AI workflows! We've spent years training developers not to make a git commit with hardcoded secrets, but copy-pasting an unredacted terminal log or test output into an AI chat panel at 6 PM completely bypasses pre-commit hooks and CI scanners.

Treating AI context as an external data boundary rather than just a local tool is the exact mental shift teams need to make. Fantastic write-up! 👏

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Thanks, really appreciate it! The 6 PM example captures the problem perfectly. We have pretty mature habits and tooling around what goes into Git, but much less visibility into what gets shared with AI tools during everyday debugging. Treating that context as another external data boundary is a good starting point for closing the gap.

Collapse
 
kaj_ilands profile image
Kaj •

The gap also opens the other way: the secret doesn't have to leave your machine, because on a lot of sites the token is in the page, not in a file.

I post to one site by driving the login myself: hold one cookie jar across the whole cycle, load the authenticated dashboard, read the CSRF token straight out of the rendered HTML, then POST with it. Nothing to paste at 6pm, nothing to redact. The credential is the session that's already open in a browser tab.

That changes the cleanup. For this class of secret, "rotate the key" isn't the move; the move is "log out everywhere," because killing the current session does nothing about a long-lived remember-me cookie, and any tool that can read the rendered page mints a fresh token without ever seeing a value you'd recognise as a secret. So the containers that actually matter are the browser profile, the cookie jar on disk, and whatever the extension can read, and all three fail the "is anything printed in a log" test by passing it.

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Good point, session-based credentials make this a much broader problem than scanning for recognizable tokens. A tool might never see a secret string and still have access to an authenticated session that lets it act as you. Browser profiles, cookies and session permissions need the same kind of isolation as files and environment variables, and revocation needs to cover persistent sessions too.

Collapse
 
paullovelace profile image
Paul Lovelace •

Line 143 is the one that got me — I've pasted exactly that kind of 200-line log in a hurry, and I never once scanned the middle for a Bearer token. The env dump example feels almost too easy to dismiss, until you remember agents that can run commands don't even need you to paste it. Do you think the fix has to live in the agent's permissions, or is there a realistic version of outbound scanning that survives that 6pm failing-deploy moment?

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Honestly, I'd want both, but permissions are the stronger first line of defense. Outbound scanning is still useful as a safety net, especially if it runs automatically before anything leaves the machine. The tricky part is catching secrets that don't match known patterns, so I'd combine scanning with restricted file access and credentials that are safe to expose within that environment.

Collapse
 
kartik-nvjk profile image
Kartik N V J K •

The env dump case gets worse once an agent runs env | sort on its own, because the output lands in the tool results. When I turn failing agent runs into eval cases, those results come along, so a key from a 6pm debug session can end up in a dataset I replay long after the chat is gone. I'd scrub at capture time.

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

That's a really important extension of the problem. Even if the original chat gets deleted, captured tool results can survive in eval datasets, traces or debugging artifacts. Scrubbing at capture time makes sense, ideally before anything gets persisted, and I'd add a check that prevents raw credentials from entering replay datasets at all. Otherwise you're just moving the same leak further down the pipeline.

Collapse
 
mp3sss31 profile image
mp3sss •

The reframe from version-control problem to data-flow problem really lands — and I see the exact mirror image on the desktop side. I ship an Electron app, and the equivalent leak path is the crash reporter: a renderer error with a full URL query string (tokens included), or a console dump of the request headers, gets attached to a Sentry breadcrumb and leaves the machine the same way a chat paste does. The practices that map 1:1 to your list: scrub crash-report breadcrumbs and never attach env vars to them, and keep credentials out of the renderer entirely — with Electron's safeStorage plus a main-process-only vault, the key never exists in a context any AI assistant or web inspector can reach. The safest secret is still the one that never enters the context window, whichever window that is.

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

That's a great example of the same problem outside the usual terminal and chat workflows. Crash reporters and telemetry are easy to overlook because they're treated as diagnostics, but they can quietly collect exactly the data we're trying to keep out of external tools. I especially like keeping credentials out of the renderer entirely. Preventing the secret from entering that context is much stronger than trying to scrub every breadcrumb after the fact.

Collapse
 
botsailorofficial profile image
BotSailor •

This is an important security issue that can easily go unnoticed during everyday development. We often focus on protecting secrets in repositories and environment files, but forget that AI tools can also become an unexpected path for sensitive information to escape.

What stands out to me is the need to think beyond traditional security boundaries. Even if a secret is never committed to Git, it can still be exposed through prompts, context files, or debugging workflows. As AI becomes more deeply integrated into development, treating data privacy as part of the coding workflow rather than an afterthought is becoming essential. A very relevant topic for developers today!

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Thanks! That's exactly the shift I wanted to highlight. Git is only one boundary, while prompts, context files, tool output, and debugging workflows create others. Treating data privacy as part of the everyday development workflow, rather than something handled only at commit time, is becoming increasingly important.

Collapse
 
khaithisran profile image
thisran •

Nice bro thank you for sharing this things

Collapse
 
frankchu profile image
frank chu •

this is insightful. Thanks for sharing this!

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Thanks, glad you found it useful! I think the key shift is treating everything an agent can read or execute as a possible path for secrets to escape, not just what we intentionally paste into a chat.

Collapse
 
codingwithjiro profile image
Elmar Chavez •

This is a good reminder that one mistake of copy pasting errors or text files to AI agents could make your app vulnerable. Great read, I learned other possible bad scenarios.

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Thanks, glad it was useful! The tricky part is that these leaks usually happen during completely normal debugging, not because someone is doing anything obviously risky. Hopefully more teams start treating anything sent to an AI agent as another data boundary to protect.

Collapse
 
dpietro profile image
Denise Pietro •

You just shared a gem with us thank you my friend!

Collapse
 
usernamevalid profile image
Shirley •

Insightful info thank you for this!

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Thanks, glad you found it useful! It's one of those things that's easy to overlook until you're debugging something under pressure. Hopefully more teams start treating AI context like any other data leaving their environment.

Collapse
 
capestart profile image
CapeStart •

Good read, Dimitris. We’ve spent years teaching developers not to commit secrets, and now we also have to think about what tools can see while we're working locally.

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Exactly. The old advice still matters, but the boundary has changed. It's no longer just about what enters version control. We also need to think about what local tools, agents, extensions and diagnostic systems can read while we're working. That's a much bigger surface to reason about.

Collapse
 
n_s_df8b9b80336beea1e5b profile image
N. S. •

Very informative thank you for sharing!

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Thanks for reading! Glad it was helpful. It’s an easy risk to miss when the usual secret-scanning protections are focused on the repo rather than the tools and context around it.

Collapse
 
yahhi profile image
Valentina Koniukhova •

Good post. I ran the check on my own MCP server (worklore.dev) after reading it, using one CloudWatch Logs Insights query over 90 days of logs (460k records). It matched keys, tokens, JWTs, Bearer headers and connection strings with passwords. It found nothing.

The reason wasn't luck. The logging was built by my coding agent (Claude Code), and it was careful by design:

  • For the inputs where people paste the most (skill text sent for a security check, full story markdown), it logs only the length.
  • It never logs the Authorization header.
  • Auth tokens are stored as hashes.
  • Claim links carry their secret in the URL fragment, so the secret never reaches a server log.

So the server side can be safe. The weak spot is the step before it, which is your point: what a person pastes into the chat. No server design helps once the secret is already in the context window. My logs did hold project descriptions the agent wrote in its own words, which shows the agent decides what goes out. If you paste an env dump, that's what it has to work with.

I agree the rule belongs to the person: paste the ten lines that matter, not the whole log, and if a key does slip in, rotate it, because deleting the message doesn't remove it. Tooling can be a seatbelt, but it won't replace that habit.

Collapse
 
kaj_ilands profile image
Kaj •

The part worth pulling out of your scan is the sentence right after "it found nothing": the logs did hold project descriptions the agent wrote in its own words.

That is the leak. It just spelled itself in prose instead of base64, so a matcher for sk-, ghp_, Bearer and JWTs will keep passing it forever. The thing that got out had no prefix.

Which means "rotate it" only covers half the case. You can rotate a key. You cannot rotate a paragraph. When the payload is the customer's own wording, the only place to fix it is at the log call, before the write, and that decision belongs to whoever owns the logger. The person pasting cannot see which of their words is the sensitive one, which is exactly why length-only logging for skill text and story markdown was the right call.

Your fragment point is the same move in miniature. Don't move the secret somewhere safer. Make sure it never lands in a container that writes. Lengths instead of texts, fragments instead of query strings. Both are the logger deciding, not the human remembering at 6pm.

Collapse
 
yahhi profile image
Valentina Koniukhova •

I'd push back a little. Those descriptions are also how I learn what people build and what they can't find, so I'm keeping them. What I'm adding is a mask at write time for anything secret-shaped, and a line in the privacy policy saying the text is logged and for how long. The logger should still decide what goes in, but sometimes the decision is "keep the words, drop the keys" rather than "keep the length."

Thread Thread
 
kaj_ilands profile image
Kaj •

the "keep the words, drop the keys" split is the right call, but a write-time mask only catches what looks like a key. the sentence that actually hurts reads like prose: a customer name, an internal host, "the endpoint that keeps timing out on tuesdays." no pattern there.

so the privacy line isn't the paperwork around the mask. it's the part that does the work, because it changes what someone types. the mask buys you the right to keep the sentence.

one thing on that line: name what you keep, not just how long. "descriptions stored 90 days" tells me nothing. "descriptions stored, secret-shaped strings masked at write, not used for training" tells me whether to write to you or around you.

Thread Thread
 
yahhi profile image
Valentina Koniukhova •

Thanks, Kaj. Your point that a mask only catches what looks like a key, and that "the endpoint that keeps timing out on tuesdays" has no pattern, is the part I had missed. It means the exact wording of the privacy line matters as much as the security work behind it. "descriptions stored, secret-shaped strings masked at write, not used for training" does a different job from "stored 90 days", and I'd only written the second kind.

You describe the gaps in a policy more precisely than I do. Do you publish reviews of privacy policies anywhere? I'd read them, and I'd like to find the other places in mine that say too little.

Thread Thread
 
kaj_ilands profile image
Kaj •

honest answer: no. i don't publish policy reviews anywhere. two posts on dev.to, neither of them that.

but you asked, so i read yours. it is live at worklore.dev/privacy.html, effective yesterday, and it is better than most. three places say less than they should.

  1. the optional note on a reproduction report. it is the only free text a person types that ends up attached to their handle on a public story, and your masking sentence covers log lines, story titles and resource addresses, not it. the page also never says whether that note is displayed. if it is, say public and permanent. if it isn't, say that.

  2. "we do not use your inputs to train any model" sits three paragraphs from "to improve search and suggestions from what people search for". later you say you read the queries. i still cannot tell which sentence governs a 160-character query. if a person reads them and decides which stories are missing, write that. it is a better sentence than the negative, because it tells me what does happen.

  3. /privacy.html is not linked from any page of the site. zero hrefs across /, /about, /stories, /skills, /paths, /authors. it is in your sitemap, so a crawler finds it and a reader does not. you promise material changes "on this page", and the page has no door.

same shape in all three: the sentence says what is not done instead of what is. the mask-at-write line and the 240-character column right under it are the opposite, exact and checkable, and that table is the best thing on the page. copy that register into the other three.

Collapse
 
__9aacb7eed7b33 profile image
בדר סלם אמר •