Atomic Server: Stored XSS via uploaded files served inline (same-origin) on `/download` → account takeoverGHSA-x277-3wcg-g9r2
HIGHFix: ontola/atomic-server@457c1dcGHSA-x277-3wcg-g9r2 is a high-severity (CVSS 8.7) Cross-site Scripting (XSS) vulnerability in atomic-server. The records list no fixed version yet; check the vendor advisory below and apply the mitigations in the meantime.
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
How urgent is this, really
Where this sits among everything scored
Real-World Exposure
atomic-serverReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects crates.io packages — download data is not available via public APIs for these ecosystems.
Description
Summary
Files uploaded via POST /upload are served back by GET /download/{path} using actix_files::NamedFile. For text/html and image/svg+xml, actix-files (0.6.6) sets Content-Disposition: inline, so the browser renders the file instead of downloading it. The /download route sets no Content-Security-Policy, no X-Content-Type-Options: nosniff, and no forced attachment (CSP exists only on the SPA route), and files are served from the same origin as the app UI. An authenticated Agent uploads evil.html containing <script>; when a victim opens the link, the script executes in the app origin. Because the atomic_session cookie is set via document.cookie (not HttpOnly) and the Agent's Ed25519 private key is stored in same-origin IndexedDB (browser/data-browser/src/helpers/agentStorage.ts), the script exfiltrates the private key → permanent account takeover.
Affected component
server/src/handlers/upload.rs— stores the file; mimetype guessed from extension.server/src/handlers/download.rs:65—NamedFile::open(...).into_response(req)with no CSP/nosniff/attachment; CSP is only set inserver/src/handlers/single_page_app.rs.
Steps to Reproduce
Environment: joepmeneer/atomic-server:develop, http://localhost:9883. Attacker is any Agent with write on a folder.
- Upload an HTML file (multipart, with signed auth headers):
POST /upload?parent=http://localhost:9883 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/upload?parent=http://localhost:9883 <ms>")>
Content-Type: multipart/form-data; boundary=----poc
------poc
Content-Disposition: form-data; name="assets"; filename="xss.html"
Content-Type: text/html
<html><body><script>alert(document.domain)</script>STORED-XSS-PROOF</body></html>
------poc--
Response 200 returns a downloadURL, e.g. http://localhost:9883/download/files/<ts>-xss.html.
- Inspect how the server serves it:
$ 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)
text/html + inline + no CSP/nosniff + same origin → the browser executes the uploaded HTML/JS in the app origin. image/svg+xml behaves identically.
- The attacker sends the link to a victim. On open, the script runs same-origin and reads
document.cookie(session is not HttpOnly) and the Ed25519 private key from IndexedDB → signs Commits as the victim indefinitely.
Expected: user files served with Content-Disposition: attachment + nosniff, or from an isolated origin.
Actual: served inline, text/html, same origin, no CSP/nosniff → stored XSS executes.
(Confirmed at the HTTP layer in the lab: content-type, disposition, missing CSP/nosniff, same origin, and the intact <script> body. In-browser execution and IndexedDB key theft follow directly from these response headers.)
Impact
Stored XSS in the app origin → theft of the victim's session cookie (not HttpOnly) and Ed25519 private key from IndexedDB → permanent account takeover (not limited by the 10-second token window). If the victim is an admin/root Agent, this is server takeover.
Remediation
- On
/download, forceContent-Disposition: attachmentfor user files, addX-Content-Type-Options: nosniff, and asandboxCSP. - Serve user-uploaded files from a separate origin/subdomain.
- Set
HttpOnly+Secureon the session cookie; do not persist the private key in JS-readable storage.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 🦀crates.io | atomic-server | ≥ 0.30.0 | No fix |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for atomic-server, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Remediation status
The records we use list no patched version of atomic-server for GHSA-x277-3wcg-g9r2. Check the maintainer's advisory, and where your build allows, override or pin the dependency away from the vulnerable range.
Mitigate without a patch
Escape or sanitise the affected output on the server side rather than relying on client-side filtering, and add a Content-Security-Policy that blocks inline script execution so injected markup cannot run even if it reaches the page.
Frequently Asked Questions
Is GHSA-x277-3wcg-g9r2 in your dependencies?
Find it across crates.io, including transitive dependencies.