# Atomic Server: Stored XSS via uploaded files served inline (same-origin) on `/download` → account takeover

Atomic Server serves uploaded HTML/SVG inline from /download with no CSP or nosniff, so stored XSS in the app origin steals the session cookie and IndexedDB Ed25519 key for account takeover.

- Payout: Research
- Severity: high
- Program: Atomic Server
- Found by: luuhung1217
- Disclosed: 2026-11-18
- CVE: CVE-2026-69155
- Write-up quality: 7/10
- Original: https://github.com/advisories/GHSA-x277-3wcg-g9r2
- Library page: https://bugbountylibrary.com/r/ghsa%3AGHSA-x277-3wcg-g9r2
- Tags: area:web domain:web impact:ato impact:data-leak impact:privesc kind:research platform:ghsa sev:high tech:rust technique:source-review vuln:account-takeover vuln:xss

**Target:** actix-files /download route serving user uploads
**Root cause:** GET /download/{path} returns user files via actix_files::NamedFile, which sets Content-Disposition: inline for text/html and image/svg+xml; the route adds no CSP, no X-Content-Type-Options: nosniff, and no forced attachment, and serves from the same origin as the app UI.
**Steps:**
1. Authenticate as any Agent with write on a folder and POST a multipart file to `/upload?parent=http://localhost:9883` with signed headers (`x-atomic-public-key`, `x-atomic-agent`, `x-atomic-timestamp`, `x-atomic-signature`) and body `<html><body><script>alert(document.domain)</script>STORED-XSS-PROOF</body></html>` as `xss.html` with `Content-Type: text/html`.
2. Response 200 returns a `downloadURL` like `http://localhost:9883/download/files/<ts>-xss.html`.
3. `curl -D - http://localhost:9883/download/files/<ts>-xss.html` shows `content-type: text/html; charset=utf-8`, `content-disposition: inline; filename="<ts>-xss.html"`, and no `Content-Security-Policy` or `X-Content-Type-Options`.
4. Send the link to a victim; the script runs same-origin, reads `document.cookie` (session not HttpOnly) and the Ed25519 private key from IndexedDB, then signs Commits as the victim.
**How found:** Code review of the upload/download handlers: noticed download.rs:65 uses NamedFile::open(...).into_response(req) with no CSP/nosniff/attachment while CSP is only set in single_page_app.rs, and that actix-files 0.6.6 sets inline disposition for text/html and image/svg+xml; then confirmed the response headers at the HTTP layer.
**Exploitation:** Attacker with write access uploads an HTML (or SVG) file, obtains the returned same-origin /download URL, and lures a victim to open it. The inline-rendered script executes in the app origin, exfiltrates the non-HttpOnly atomic_session cookie and the Ed25519 private key stored in same-origin IndexedDB, allowing the attacker to sign Commits as the victim indefinitely, bypassing the 10-second token window.
**Escalation:** If the victim is an admin/root Agent, the stolen key yields server takeover.
**Insight:** When a framework's static-file handler auto-selects inline disposition for text/html and SVG, check whether the app's security headers (CSP, nosniff) are applied only on the SPA route and not on the file-serving route; also check whether session cookies and signing keys live in JS-readable storage on the same origin, which turns a file-render into full ATO.

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

**curl showing inline text/html without CSP**

```
$ curl -D - http://localhost:9883/download/files/<ts>-xss.html
HTTP/1.1 200 OK
content-type: text/html; charset=utf-8
content-disposition: inline; filename="<ts>-xss.html"
# (no Content-Security-Policy, no X-Content-Type-Options)
```

