The vulnerability in OpenClaw's system.run functionality was due to a discrepancy in how dispatch wrapper depth boundaries were handled between the security approval and execution planning stages. Specifically, two internal functions, hasEnvManipulationBeforeShellWrapperInternal and extractShellWrapperCommandInternal, had inconsistent boundary checks.
The hasEnvManipulationBeforeShellWrapperInternal function, used for approval classification, would stop processing at the depth boundary (depth >= MAX_DISPATCH_WRAPPER_DEPTH), incorrectly concluding that a command was not a shell wrapper requiring approval. In contrast, the execution logic, including extractShellWrapperCommandInternal, would continue to unwrap the command at that same depth, leading to the execution of a shell command that should have been gated by the approval mechanism.
The patch corrects this by changing the boundary check from >= to > in both functions. This ensures that the command at the depth boundary is correctly classified as a shell wrapper and subjected to the necessary security approvals, aligning the behavior of the approval and execution paths.