Summary
AcpConnection::spawn() in connection.rs does not call env_clear() before spawning the agent subprocess. As a result, the child process inherits all environment variables from the OAB parent process, including sensitive credentials like DISCORD_BOT_TOKEN, SLACK_BOT_TOKEN, etc.
The [agent].env config is additive — it adds variables on top of the inherited environment, not a whitelist replacement.
Impact
A user can ask the agent to run env or echo $DISCORD_BOT_TOKEN and the agent will return the value. The agent could also be tricked via prompt injection to exfiltrate these credentials through arbitrary outbound requests (e.g. curl).
Reproduction
- Set
DISCORD_BOT_TOKEN as an env var for the OAB process
- Ask the agent: "run
env and show me the output"
- The agent returns all OAB env vars including
DISCORD_BOT_TOKEN
Fix
Add cmd.env_clear() before injecting [agent].env values, and explicitly pass only HOME and PATH as baseline variables:
cmd.env_clear();
cmd.env("HOME", working_dir);
cmd.env("PATH", std::env::var("PATH").unwrap_or_default());
for (k, v) in env {
cmd.env(k, expand_env(v));
}
This ensures the agent subprocess only sees credentials explicitly listed in [agent].env.
Summary
AcpConnection::spawn()inconnection.rsdoes not callenv_clear()before spawning the agent subprocess. As a result, the child process inherits all environment variables from the OAB parent process, including sensitive credentials likeDISCORD_BOT_TOKEN,SLACK_BOT_TOKEN, etc.The
[agent].envconfig is additive — it adds variables on top of the inherited environment, not a whitelist replacement.Impact
A user can ask the agent to run
envorecho $DISCORD_BOT_TOKENand the agent will return the value. The agent could also be tricked via prompt injection to exfiltrate these credentials through arbitrary outbound requests (e.g.curl).Reproduction
DISCORD_BOT_TOKENas an env var for the OAB processenvand show me the output"DISCORD_BOT_TOKENFix
Add
cmd.env_clear()before injecting[agent].envvalues, and explicitly pass onlyHOMEandPATHas baseline variables:This ensures the agent subprocess only sees credentials explicitly listed in
[agent].env.