Summary
OpenClaw versions prior to 2026.2.12 do not properly validate the sessionFile path parameter used for storing transcript data, allowing path values outside the intended sessions directory.
An authenticated gateway client can direct OpenClaw to create or append to arbitrary files on the host filesystem, which may lead to configuration corruption or denial of service if critical files are targeted.
Affected context
This vulnerability occurs in OpenClaw deployments where gateway clients can specify a sessionFile path for transcript storage.
The issue is present when:
- The server accepts client-provided file paths without strict normalization and directory confinement
- The process has write permissions outside the intended sessions directory
- Transcript data is written/append to the disk based solely on the unvalidated
sessionFileparameter
It primarily affects environments where configuration, logs, or other sensitive files reside on the same filesystem and are writable by the OpenClaw service account.
Exploit preconditions
- Attack surface: Application-layer interface exposed to gateway clients (e.g., REST, RPC, or custom protocol) where
sessionFileis accepted. - Required access: Authenticated gateway client access; the attacker must be able to establish a session and control the
sessionFileparameter. - Trigger point: Any operation that causes the application to create or append a session transcript using the provided
sessionFilepath. - Why exploitation is possible: The application trusts the client-supplied path and does not strictly validate, normalize, or enforce confinement to the sessions directory, allowing file paths that resolve outside the intended storage location.
Why this happens
The underlying issue is the external control of a file path used in file creation and writing, aligning with CWE-73: External Control of File Name or Path.
Instead of treating the sessionFile parameter as untrusted input, the implementation appears to concatenate or otherwise combine it with filesystem operations without:
- Normalizing the path
- Rejecting traversal sequences or absolute paths
- Enforcing that the resolved path is located under a dedicated sessions directory
This insecure pattern allows authenticated clients to influence where on the filesystem the application writes transcript data, turning a benign logging mechanism into a primitive for arbitrary file creation and uncontrolled data append operations.
Potential impact
- Creation of arbitrary files on the host filesystem where the OpenClaw process has write permissions
- Repeated appending of arbitrary transcript data to existing files, potentially corrupting configuration or state files
- Induced denial of service by:
- Filling disk space via large or repeated transcript writes
- Corrupting critical configuration files so the service cannot start or function correctly
- Interference with log files or other operational data, complicating monitoring and incident response
- In some deployment-specific cases, influence over other components that rely on the integrity of modified files
General mitigation guidance
Effective mitigation focuses on eliminating direct use of client-controlled paths and constraining all file operations to safe locations.
Common defensive patterns include:
- Path confinement ("chroot" for files):
- Resolve and normalize all candidate paths and enforce that they remain inside a dedicated sessions directory.
- Reject any request whose resolved path escapes this directory, regardless of the user identity.
- Use identifiers, not raw paths:
- Treat
sessionFileas an opaque session identifier or token. - Map identifiers to server-generated filenames within a controlled directory, instead of allowing clients to specify path fragments.
- Restrictive filesystem permissions:
- Run the OpenClaw service under a dedicated OS account with write access only to its working/session directories.
- Prevent write access to configuration directories and other sensitive locations.
- Input validation and normalization:
- Strip or reject absolute paths, drive letters, and path traversal sequences (
../,..\\, symlink tricks where feasible). - Apply a strict naming policy (e.g., whitelist of allowed characters and length) for any user-supplied file-related parameters.
- Operational hardening:
- Consider quotas or size limits on transcript files to reduce the impact of abuse.
- Apply monitoring and alerting on unexpected file creation in sensitive directories.
How teams detect issues like this
Detection centers on both code-level review and runtime observability:
- Static analysis and code scanning:
- Flag uses of file APIs (open, create, append, write) where the path includes unvalidated client input such as
sessionFile. - Search for concatenation of request parameters with filesystem paths, especially where no normalization or directory checks exist.
- Enforce coding guidelines or linters that prohibit direct use of user input in filesystem operations.
- Manual code review signals:
- Handlers or controllers that accept file names or paths from authenticated clients.
- Lack of canonicalization (e.g.,
realpathchecks) or explicit verification that the resolved path resides under an allowed directory. - Absence of a centralized path-sanitization utility for all file-writing operations.
- Runtime monitoring and logging:
- Enable verbose logging of file-write targets when feasible, with safeguards for sensitive data, and alert on file writes outside expected directories.
- Monitor for unusual growth in configuration or non-session files, or sudden spikes in filesystem usage.
- Policy enforcement:
- Use host or container security policies (e.g., MAC frameworks or sandboxing) to restrict filesystem write locations and log violations.

