The vulnerability lies in an incomplete blocklist of dangerous environment variables located in src/infra/host-env-security-policy.json. This allowed an attacker to override compiler-related environment variables (CC, CXX, CARGO_BUILD_RUSTC, CMAKE_C_COMPILER, CMAKE_CXX_COMPILER) for host execution requests. The patch addresses this by adding these variables to the blocklist.
The primary function responsible for enforcing this security policy is sanitizeHostExecEnv, which is located in src/infra/host-env-security.ts. This function takes a set of environment variable overrides and is supposed to strip any dangerous variables before they are used to execute commands on the host. Because the blocklist was incomplete, sanitizeHostExecEnv would fail to remove the malicious compiler overrides. The test file src/infra/host-env-security.test.ts was updated to verify that sanitizeHostExecEnv now correctly removes these variables.
A helper function, isDangerousHostEnvVarName, is used to check if a given environment variable is on the blocklist. This function was also implicitly vulnerable due to the incomplete blocklist. The updated tests confirm it now correctly identifies the compiler-related variables as dangerous.
Therefore, during exploitation, a profiler would likely show sanitizeHostExecEnv being called, which would then (prior to the patch) fail to sanitize the environment, leading to the execution of a malicious compiler.