The vulnerability lies in the logic that determines whether an agent can execute commands on a specific host. When an agent is in a sandboxed environment, it should be restricted to executing commands within that sandbox. However, the code did not properly check for a request to use the 'node' host when a sandbox was active. This allowed a sandboxed agent to explicitly request host: 'node' and bypass the sandbox, executing commands on the underlying host machine.
The patch addresses this by modifying three key functions:
isRequestedExecTargetAllowed: This function is updated to explicitly deny requests for the 'node' host when a sandbox is available.
canExecRequestNode: This function is updated to consider the sandbox availability when determining if a 'node' host can be requested.
resolveExecDefaults: This function is updated to correctly pass the sandbox availability status to isRequestedExecTargetAllowed.
By fixing these functions, the system now correctly prevents sandboxed agents from escaping their restricted environment.