Feature request for product/service
– Other –
Describe the request
We run a multi-bot team on Grok Bot. During routine testing, one bot ran a command that listed the box environment, and two of our saved secrets came out in plain text in a tool output file, while the others were masked. We caught it, deleted the file and rotated the secrets.
What we did on our side: replaced env/printenv with versions that mask values, and added a nightly secret scan of working files.
Request: could the platform mask secret values everywhere by default (env listings, tool output files, logs), the same way it already does for some of them? A per-secret ‘never print’ flag would also help.
For anyone who wants the workaround in the meantime, this is what we added to ~/.bashrc on the box. env lists names with values masked, and printenv NAME refuses:
_masked_env() { command env "$@" | sed -E 's/^([A-Za-z_][A-Za-z0-9_]*)=.*/\1=****/'; }
env() { if [ $# -eq 0 ]; then _masked_env; else command env "$@"; fi; }
printenv() { if [ $# -eq 0 ]; then _masked_env; else echo "printenv NAME blocked: values are secret" >&2; return 1; fi; }
export -f env printenv _masked_env
It only covers the shell. Code that reads the environment directly can still leak values, which is why default masking at the platform level would help.
There’s a shell-only way through the wrapper too. I tried env TEST=1 with a dummy secret and it printed the value unmasked. Since that call has an argument, it goes straight to command env "$@" and never reaches the masking.
The same branch also handles things like env TEST=1 some-command, so it needs to distinguish between launching a program and just printing the environment. Your caveat about programs reading secrets directly still applies, but this one happens inside the shell workaround itself.
Great catch, Kam, thank you! You’re right: env with arguments but no program skipped the masking. It’s fixed now. env masks values whenever it would only list the environment, including calls like env TEST=1, -u, -i and --, and it masks multi-line values too. It only runs unmasked when it actually starts a program. Known gaps remain for set, declare -x and code that reads a variable on purpose, so a platform-level fix would still be the real answer.
On the remaining gaps, a few more ways around a shell-function wrapper, so I would treat it as best-effort:
- command env skips the function. The bash manual says the command builtin “runs COMMAND with ARGUMENTS ignoring any shell function named COMMAND”. Calling /usr/bin/env by its full path does the same.
- If the agent’s shell tool runs bash -c non-interactively, ~/.bashrc is not read at all unless BASH_ENV points to a file. So the wrapper may not even be loaded for agent commands. I haven’t checked how this tool starts its shell.
- On Linux, cat /proc/self/environ and export -p also print the environment.
So I agree it needs a platform fix: masking known secret values in tool output before it’s written to files or logs. Until then, I think keeping secrets out of the agent’s environment and loading them only in the process that needs them is the safer option.
Thanks @sattyamjjain, you were right. Non-interactive bot shells never read .bashrc, so my wrapper wasn’t covering them. We’ve since put masking env/printenv wrappers first on PATH for every bot command, and set a team rule against dumping the environment. We’re also moving each secret out of the always-on environment into a locked file that only the script needing it reads, as you suggested. A built-in masking option would still be the real fix, so +1 to the request.