Summary
CodeWhale's js_execution tool may pass parent-process environment variables into spawned Node.js processes without scrubbing them. Malicious JavaScript executed through the tool could read process.env and expose API keys, cloud credentials, or authentication tokens to the model context.
Affected context
The vulnerability affects CodeWhale deployments that use the js_execution tool to run JavaScript in a child Node.js process while inheriting the parent process environment. Risk is higher when sensitive credentials or tokens are present in environment variables and untrusted or insufficiently constrained code can reach the execution tool.
Exploit preconditions
- Attack surface: The CodeWhale js_execution tool and its JavaScript runtime - Required access: Ability to submit or influence JavaScript executed by the
tool
- Trigger point: Creation of a Node.js process followed by access to
process.env
- Why exploitation is possible: Parent environment variables are inherited
without adequate filtering, making sensitive values available to executed
code
Why this happens
The underlying issue is failure to establish a minimized environment for a child process before executing potentially untrusted JavaScript. Inherited process variables can contain secrets unrelated to the task, and exposing them to the script creates an unintended information flow. This maps to CWE-200, Information Exposure, because sensitive data becomes accessible through a component that does not require it.
Potential impact
- API keys may be disclosed
- Cloud credentials could be exposed and misused
- Authentication tokens may be revealed
- Downstream services or accounts could be accessed
- Sensitive environment metadata may be returned to the model context
General mitigation guidance
Mitigation generally focuses on reducing trust in executed code and limiting the data available to child processes. Common defensive patterns include constructing an explicit allowlist-based environment rather than inheriting the parent environment, keeping secrets out of process variables where practical, isolating JavaScript execution, and applying least-privilege identities and short-lived credentials. Output and tool boundaries can also be designed to prevent sensitive values from being returned to the model context.
How teams detect issues like this
Detection can include static analysis for child-process creation that inherits unrestricted environments, review of JavaScript execution paths, and checks for direct access to process.env in untrusted-code contexts. Code review should examine whether environment variables are explicitly allowlisted and whether credentials are available to execution workers. Runtime monitoring and policy enforcement can flag secret-like values in tool outputs or unexpected access to sensitive environment names.

