Summary
NanoClaw exposes a filesystem boundary weakness in its outbound attachment handling and outbox cleanup logic, allowing crafted outbox entries or symlinked files to escape the intended directory sandbox.
A compromised or prompt-injected container can abuse messages_out identifiers and attachment metadata to cause the host to read arbitrary files or, in some cases, recursively delete paths outside the designated outbox directory.
Affected context
This vulnerability appears in environments where NanoClaw mediates file exchange between containers and the host via an "outbox" directory.
It becomes relevant when:
- Containers can influence
messages_out.idandcontent.filesvalues for outbound attachments. - The host relies on these values to locate files without robust path normalization and boundary checks.
- Outbox files or directories may be symlinked or otherwise indirectly reference other parts of the host filesystem.
Under these conditions, a compromised or prompt-injected container can manipulate outbox entries so that host-side processing crosses the intended host/container filesystem boundary.
Exploit preconditions
- Attack surface: Host-side NanoClaw processes that handle outbound messages and perform outbox cleanup.
- Required access: Ability from within a container to:
- Set or influence
messages_out.idandcontent.filesfields for outbound attachments, and/or - Create or modify files and symlinks in the container-visible outbox directory.
- Trigger point: Host execution of:
- Outbound attachment handling routines that read files based on user-controlled identifiers or paths, and/or
- Outbox cleanup logic that recursively deletes directories derived from those identifiers.
- Why exploitation is possible: The host trusts path components derived from container-controlled metadata and filesystem entries, does not consistently normalize or canonicalize paths, and does not enforce that resolved paths remain under the intended outbox root, allowing traversal and symlink escape.
Why this happens
The underlying issue is a classic path traversal and directory boundary enforcement failure, as covered by CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Host-side NanoClaw logic uses container-supplied values such as messages_out.id and content.files to construct or resolve filesystem paths for reading attachments and cleaning up outbox content.
Without robust checks (e.g., resolving to an absolute canonical path, rejecting traversal components, and preventing symlink escape), the implementation allows an attacker-controlled container to direct file operations to locations outside the designated outbox directory.
Additionally, cleanup routines that recursively delete directories based on these same, insufficiently validated paths can be coerced into deleting unintended paths, extending the impact from read access to potential destructive operations.
Potential impact
- Host-side reads of arbitrary files accessible to the NanoClaw process, including configuration files, credentials, or other sensitive data.
- Leakage of host secrets back into the compromised container through normal NanoClaw message channels.
- Recursive deletion of directories outside the intended outbox root, which could:
- Remove application data or logs.
- Disrupt service availability.
- Interfere with security controls or monitoring artifacts.
- Expanded attack surface for lateral movement if sensitive host data is exfiltrated and reused.
- Degradation of isolation guarantees between containers and the host, undermining multi-tenant safety assumptions.
General mitigation guidance
Effective mitigation focuses on strict enforcement of directory boundaries, path hygiene, and least privilege for file operations.
Pattern-based defensive measures include:
- Canonical path enforcement:
- Resolve all file and directory paths to their absolute, canonical form (e.g., using realpath-like semantics) before use.
- Confirm that the resolved path is strictly within the intended outbox root directory before performing any read or delete operations.
- Input normalization and validation:
- Treat
messages_out.id,content.files, and similar fields as untrusted input. - Reject or sanitize values containing traversal indicators (e.g.,
.., absolute paths, or embedded path separators) rather than attempting to "fix" them silently. - Symlink-aware controls:
- Avoid following symlinks when operating within the outbox directory where possible.
- When symlinks must be supported, enforce checks on the resolved target to ensure it remains under the expected root; otherwise, fail the operation.
- Separation of identifiers from paths:
- Use opaque, server-generated identifiers for directory and file names instead of allowing containers to supply full or partial paths.
- Maintain a host-side mapping from identifiers to sanitized filesystem locations.
- Constrained cleanup routines:
- Implement cleanup logic that limits deletion to pre-defined, host-controlled directories derived from trusted configuration rather than dynamic, container-supplied values.
- Prefer whitelisting specific directories or patterns for deletion rather than constructing paths directly from container data.
- Least-privilege file permissions:
- Run NanoClaw host components with restricted filesystem privileges, ensuring they cannot read or delete sensitive host directories even if a path escape is attempted.
- Use OS-level controls (such as chroot jails, mount namespaces, or bind mounts) to further constrain accessible paths.
How teams detect issues like this
Detection and assurance can be improved by combining static analysis, code review, and runtime monitoring aimed at path handling logic.
Possible approaches include:
- Static analysis patterns:
- Flag uses of file APIs (open, read, delete, recursive directory operations) where any part of the path is derived from container-controlled fields like
messages_out.idorcontent.files. - Identify path concatenations that do not pass through canonicalization and boundary checks.
- Highlight code that follows symlinks within directories intended to act as isolation boundaries.
- Code review signals:
- Explicitly review all modules responsible for outbox handling and cleanup, looking for assumptions about the trustworthiness of container-supplied identifiers.
- Require documented invariants stating that all file operations must be confined to a specific root, and verify that these invariants are enforced programmatically.
- Check for reuse of helper functions that enforce canonicalization and boundary checks, rather than ad-hoc path manipulation scattered throughout the codebase.
- Policy and tooling:
- Introduce secure coding guidelines that mandate canonicalization and boundary verification for any path constructed from untrusted input.
- Integrate automated review tools and linters configured to detect path traversal patterns and risky cleanup logic as part of CI/CD.
- Runtime monitoring:
- Monitor host-side NanoClaw processes for access to directories outside the configured outbox path, using file integrity monitoring or audit logs.
- Set alerts for unexpected deletions or reads in sensitive directories that could indicate exploitation attempts.

