Recently cloud/background agents have started to edit unrelated lines of code replacing values that match my env var values with [REDACTED]:
I have not requested this in any of my rules. It seems to be a Cursor automation.
Steps to Reproduce
create an env var with a common value, then create a background agent that edits a file that contains that value
Expected Behavior
not to edit nor redact existing code.
I can understand that for real secrets you may not want to write them to the repo, but this should only affect edited lines, not lines that already existed and weren’t edited by the agent. Thus it should not scan whole files but diffed lines only.
This is most likely related to how secrets marked as Redacted work in Cloud Agent settings. When a secret is classified as Redacted, its value gets stripped from everything the model can see, like file contents and tool outputs. So the model sees [REDACTED] instead of the real value and may write that back into the file as-is.
Quick question: are environment variables like AWS_DEFAULT_REGION marked as Redacted in the Cloud Agent settings?
If yes, a temporary workaround is to mark only real secrets as Redacted, like API keys, passwords, and tokens, and keep config values like region, project ID, and similar as normal (not redacted) secrets. Non-redacted secrets are still encrypted and injected as env vars, they just don’t trigger the scanning and replacement behavior.
Either way, I’ve flagged this to the team. Existing code being overwritten with [REDACTED] shouldn’t happen even for Redacted secrets.
Let me know if changing the Redacted classification helps.
Yes, this was a Redacted Secret and that was unnecessary. So changing that should work for this env var.
I understand that it works at read time and that causes the agent to submit it as a diff. Still a bug for existing secrets in the code that can be intentional, but it has less of a surface now, since that’s a bad practice.
Glad the reclassification helped. About the main bug, I’ve passed along to the team that Redacted secrets overwrite existing lines in the code. I can’t promise a specific timeline, but the report is logged.
If you run into this again with real secrets, let me know.