The vulnerability is a path traversal issue (CWE-22) in the openclaw npm package, allowing an attacker with permissions to modify the configuration file to read arbitrary files on the local filesystem. The root cause lies in the insecure handling of the $include directive within the configuration file parser.
The core of the vulnerability is in the IncludeProcessor.processIncludes method in src/config/includes.ts. The original code used a simple startsWith string comparison to validate that the path provided in the $include directive was within the bounds of the configuration directory. This check was insufficient and could be bypassed using relative path traversal sequences (../) or by providing an absolute path to a file outside the intended directory.
The patch rectifies this by implementing a more robust validation mechanism. It introduces the concept of a rootDir (the top-level configuration directory) and uses a new isPathInside helper function to strictly enforce that all resolved include paths are contained within this directory. Furthermore, the patch adds fs.realpathSync to resolve any symbolic links before validation, preventing bypasses that use symlinks to point to files outside the configuration directory.
The primary vulnerable function is IncludeProcessor.processIncludes, as it contains the flawed validation logic. However, IncludeProcessor.process and the exported resolveConfigIncludes function are also identified as key components of the vulnerable execution path, as they are responsible for initiating and managing the configuration parsing process that triggers the vulnerability. A runtime profiler would likely show these functions in the call stack during an exploit.