Heuristic:AI Shell Team Aish Sandbox Env Allowlist
| Knowledge Sources | |
|---|---|
| Domains | Security, MCP, Sandbox |
| Last Updated | 2026-10-29 00:00 GMT |
Overview
MCP server child processes inherit only a 19-variable allowlist from the parent environment, preventing accidental credential leakage (e.g., `AISH_API_KEY`, cloud keys) to untrusted MCP servers.
Description
When aish spawns an MCP server as a child process, the `ServerSettings::child_env()` method does NOT pass the full parent environment. Instead, it filters the parent environment through a strict allowlist of 19 variables (12 general + 7 XDG), then overlays the server's explicitly configured `env:` block on top. This is a defense-in-depth measure: MCP servers are untrusted by default, and handing them credentials like `AISH_API_KEY`, `SSH_AUTH_SOCK`, or cloud provider keys would violate the trust model. Any variable a server legitimately needs must be declared in its `env:` configuration block.
Usage
Use this heuristic when configuring MCP server environments, debugging missing env vars in MCP servers, or auditing credential exposure. Apply it when an MCP server fails because it cannot find an environment variable, or when reviewing whether a server configuration is safe to deploy.
The Insight (Rule of Thumb)
- Action: Do not pass the full parent environment to MCP child processes. Use the 19-variable allowlist, plus the server's explicit `env:` block.
- Value: Inherited allowlist (19 variables):
- General: `HOME`, `LOGNAME`, `PATH`, `SHELL`, `TERM`, `USER`, `TMPDIR`, `LANG`, `LC_ALL`, `LC_CTYPE`, `SSL_CERT_FILE`, `SSL_CERT_DIR`
- XDG: `XDG_CONFIG_HOME`, `XDG_CONFIG_DIRS`, `XDG_DATA_HOME`, `XDG_DATA_DIRS`, `XDG_STATE_HOME`, `XDG_CACHE_HOME`, `XDG_RUNTIME_DIR`
- Trade-off: Security (no credential leakage) vs. convenience (servers cannot access unlisted vars without explicit config). The server's `env:` block wins over the allowlist, so required vars can be added per-server.
- Compatibility: The allowlist mirrors the reference MCP SDK behavior, ensuring cross-compatibility with standard MCP servers.
Reasoning
MCP servers are external processes that aish launches and communicates with via stdio or HTTP. By default, they are untrusted — their tools may have `unknown` or `write` side effects. If the full parent environment were passed, any MCP server would instantly have access to the user's `AISH_API_KEY`, cloud credentials (`AWS_ACCESS_KEY_ID`, `GOOGLE_APPLICATION_CREDENTIALS`), SSH agent socket (`SSH_AUTH_SOCK`), and other secrets. The allowlist restricts inheritance to only the variables that launchers (`uvx`, `npx`) and locale-aware programs need to function, forcing all other variables to be explicitly declared in the server's `env:` block where they are visible in configuration and can be audited.
Code Evidence
child_env method from `crates/aish-mcp/src/config.rs:134-142`:
pub fn child_env(&self) -> BTreeMap<String, String> {
let mut env: BTreeMap<String, String> = std::env::vars()
.filter(|(key, _)| is_inherited_env(key))
.collect();
for (key, value) in &self.env {
env.insert(key.clone(), value.clone());
}
env
}
Allowlist constants from `crates/aish-mcp/src/config.rs:152-177`:
const INHERITED_ENV_VARS: [&str; 12] = [
"HOME", "LOGNAME", "PATH", "SHELL", "TERM", "USER",
"TMPDIR", "LANG", "LC_ALL", "LC_CTYPE",
"SSL_CERT_FILE", "SSL_CERT_DIR",
];
const INHERITED_XDG_VARS: [&str; 7] = [
"XDG_CONFIG_HOME", "XDG_CONFIG_DIRS",
"XDG_DATA_HOME", "XDG_DATA_DIRS",
"XDG_STATE_HOME", "XDG_CACHE_HOME",
"XDG_RUNTIME_DIR",
];