| 제목 | 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. AM 08:51 (2 개월 ago) |
|---|
| 모더레이션 | 2026. 08. 05. PM 08:48 (2 months later) |
|---|
| 상태 | 수락 |
|---|
| VulDB 항목 | 386367 [nanocoai NanoClaw 까지 2.0.64 send_file core.ts 디렉토리 순회] |
|---|
| 포인트들 | 20 |
|---|