The vulnerability is a classic path traversal issue (CWE-22) within the OpenClaw application, affecting versions up to 2026.2.9. The root cause is the improper handling of sessionId and sessionFile parameters, which were used to construct file paths for session transcripts without proper sanitization or validation.
The analysis of the fix commit 4199f9889f0c307b77096a229b9e085b8d856c26 reveals that several functions were involved in creating and using these unsafe paths. The core of the fix was to introduce validation for session IDs and to ensure that any resolved file path is strictly contained within the designated agent sessions directory.
The primary vulnerable function was resolveSessionFilePath, which previously returned user-provided paths without validation. This function was called by multiple other parts of the application that perform file operations, such as appendAssistantMessageToSessionTranscript (for writing) and the various usageHandlers (for reading). An attacker with gateway authentication could send a crafted request with a malicious sessionId or sessionFile (e.g., ../../etc/passwd) to trigger these functions, leading to arbitrary file reads or writes on the server's filesystem. The patch addresses this by rewriting the path resolution logic to be secure by default, rejecting any path that attempts to escape the sessions directory.