| 标题 | nanocoai NanoClaw 2.0.64 Improper Limitation of a Pathname to a Restricted Directory (CWE-22) |
|---|
| 描述 | # Technical Details
An Arbitrary Local File Exfiltration via `send_file` absolute path exists in the `send_file` tool handler in `container/agent-runner/src/mcp-tools/core.ts` of NanoClaw.
The application fails to restrict file reads to trusted roots. The `send_file` MCP tool explicitly accepts absolute filesystem paths and copies the referenced file into the outbound outbox without any allowlist, `realpath` canonicalization, or containment check. When an absolute path is provided, the code resolves it unchanged and only checks existence before copying: `const resolvedPath = path.isAbsolute(filePath) ? filePath : path.resolve('/workspace/agent', filePath)`. This allows a prompt-injected agent to exfiltrate arbitrary container-visible files, including files mounted under `/workspace/extra/*`.
# Vulnerable Code
File: container/agent-runner/src/mcp-tools/core.ts
Method: send_file tool handler (lines ~136-176) — resolves absolute paths without root restriction, copies to outbox
Why: No allowlist of permitted local roots, no containment enforcement. The agent runner also auto-discovers directories under /workspace/extra/* and exposes them to the runtime, making sensitive mounts realistically reachable.
# Reproduction
1. Create `/workspace/agent/docs/allowed.txt` and `/workspace/extra/secret-mount/canary.txt`.
2. Start the built-in MCP stdio server and invoke `send_file` with `docs/allowed.txt` (relative, allowed) and `/workspace/extra/secret-mount/canary.txt` (absolute, should be blocked).
3. Observe both files are staged into `/workspace/outbox/<message_id>/` for outbound delivery.
# Impact
- Arbitrary local file read leading to data exfiltration through NanoClaw's outbound attachment pipeline.
- A prompt-injected or compromised agent can export local documents, internal artifacts, or other readable files to external messaging destinations.
- Sensitive mounted directories under `/workspace/extra/*` are directly reachable. |
|---|
| 来源 | ⚠️ https://github.com/nanocoai/nanoclaw/issues/2760 |
|---|
| 用户 | JohnChen (UID 99088) |
|---|
| 提交 | 2026-06-18 08時51分 (2 月前) |
|---|
| 管理 | 2026-08-05 20時48分 (2 months later) |
|---|
| 状态 | 已接受 |
|---|
| VulDB条目 | 386367 [nanocoai NanoClaw 直到 2.0.64 send_file core.ts 目录遍历] |
|---|
| 积分 | 20 |
|---|