The vulnerability exists due to unsafe handling of module paths provided in the OpenClaw gateway configuration. The application dynamically imports JavaScript/TypeScript modules for hooks and transforms, but in affected versions, it failed to properly sanitize and restrict the file paths for these modules. The core of the issue lies in two areas of the configuration: hooks.mappings[].transform.module and hooks.internal.handlers[].module.
An attacker with the ability to modify the gateway's configuration could specify a malicious path for these modules. The functions resolveHookMappings and normalizeHookMapping in src/gateway/hooks-mapping.ts processed the transform.module path without preventing path traversal (e.g., ../) or absolute paths. Similarly, the loadInternalHooks function in src/hooks/loader.ts handled the internal.handlers[].module path insecurely, allowing modules to be loaded from outside the intended workspace directory.
This lack of path validation meant that the import() function could be pointed to an arbitrary file on the local filesystem, resulting in remote code execution within the security context of the OpenClaw gateway process. The patches address this by introducing strict path validation, ensuring that all loaded modules are confined within designated, safe directories (~/.openclaw/hooks/transforms and the workspace directory, respectively), and rejecting any attempts at path traversal or the use of absolute paths.