{"id":"XE-0051","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"71","source_url":"https://github.com/xeprotocol/xe/issues/71","reporter_id":23,"title":"web: the wallet origin sends no CSP, no frame-ancestors and no HSTS, and the wallet renders seed material into that origin (Medium)","area":"sdk-docs-web","claimed_tier":"medium","assessed_tier":null,"verdict":null,"duplicate_of":null,"tracked":true,"internal_ref":"","internal_url":null,"status":"accepted","closed_reason":null,"github_state":"open","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-10-29T13:57:19.785678+00:00","updated_at":"2026-11-10T11:38:23.702381+00:00","source_created_at":"2026-10-26T17:49:59+00:00","told_at":"2026-11-10T00:15:51+00:00","status_changed_at":"2026-10-29T14:04:13.512085+00:00","url":"https://bounty.xe.network/XE-0051","body":"# web: the wallet origin sends no CSP, no frame-ancestors and no HSTS, and the wallet renders seed material into that origin (Medium)\n\n**Severity (suggested):** Medium — \"missing security headers with impact\". No XSS was found; the finding is that the wallet's own origin has none of the mitigations that would bound one, and the seed-reveal flow is framable.\n\n**Area:** The explorer, the web wallet, this website and the docs (including header, XSS and content issues)\n\n**Observed:** 2026-10-26, on `https://ldn.test.network/wallet/` (the node-served wallet that `/wallet` links to) and `https://test.network/wallet`\n**XE payout address:** `69429f663b836b7ee1c8042a301a8576cf70f5ec6945ba21eff94b30d27dd234`\n\n---\n\n## Summary\n\nThe web wallet at `ldn.test.network/wallet/` is served by the node (`api/ui.go:64`, `walletGate` → static file server over the embedded `web/` tree) and ships `assets/wallet.js`, `assets/vault.js`, `assets/xe-block.js` etc. It stores encrypted seeds in `localStorage` (`vault.js`: PBKDF2-SHA256, 600,000 iterations, AES-GCM-256 — that part is sound for a hot wallet) and it has a seed-reveal flow that prints the recovery phrase into the DOM (`#reveal-display`, `#reveal-hex`, and the first-run `#seed-confirm-display` / `#seed-confirm-hex`).\n\nThe response carries **none** of the six security headers:\n\n```\n$ curl -sI https://ldn.test.network/wallet/ | grep -Ei 'content-security|x-frame|strict-transport|x-content-type|referrer|permissions'\n(nothing)\n```\n\nVerified complete header set for that URL (identical on all three bootstrap nodes — `ldn`, `nyc`, `ffm` all return exactly these eight lines and nothing else, all serving the same 10,453-byte `wallet.html`):\n\n```\nHTTP/2 200\naccept-ranges: bytes\nalt-svc: h3=\":443\"; ma=2592000\ncontent-type: text/html; charset=utf-8\ndate: Mon, 26 Oct 2026 17:49:34 GMT\nvia: 1.1 Caddy\ncontent-length: 10453\n```\n\nNo `Content-Security-Policy`, no `X-Frame-Options`, no `frame-ancestors`, no `Strict-Transport-Security`, no `X-Content-Type-Options`, no `Referrer-Policy`.\n\n`https://test.network/wallet` (nginx 1.24.0 / Next.js) is the same story — no CSP, no frame protection, no HSTS, no `nosniff` — plus information disclosure headers:\n\n```\nHTTP/1.1 200 OK\nServer: nginx/1.24.0 (Ubuntu)\nVary: rsc, next-router-state-tree, next-router-prefetch, next-router-segment-prefetch, Accept-Encoding\nx-nextjs-cache: HIT\nx-nextjs-prerender: 1\nx-nextjs-stale-time: 300\nX-Powered-By: Next.js\nCache-Control: s-maxage=31536000\n```\n\n## Impact\n\nTwo concrete consequences, in order of seriousness:\n\n1. **Seed material is framable.** `wallet.html` contains the unlock/reveal UI and `wallet.js:181` wires a submit handler to `onReveal`, which writes the phrase with `textContent` into `#reveal-display`. Because the origin sends no `X-Frame-Options` and no `frame-ancestors`, any site can frame `/wallet/` and overlay it — a classic clickjacking/drag-targeting setup against an interface whose entire purpose is to display a seed. There is no SRI and no CSP, so there is also nothing constraining injected script on the one origin that holds encrypted keys.\n\n2. **No CSP means an XSS is unbounded.** I did not find an XSS in `wallet.js`/`vault.js`; the render paths I read use `td()` → `textContent`, `setText()` → `textContent`, and `blockLinkTd()` builds anchors with `createElement` and `encodeURIComponent`. The nine `innerHTML` uses I found are literal strings (`''`, `'<tr><td colspan=\"3\" class=\"muted\">no balances yet</td></tr>'`). So the header gap is defence-in-depth rather than an active vulnerability — which is exactly the \"with impact\" bar for Medium, not a High.\n\n3. **No HSTS.** `http://ldn.test.network/wallet/` currently 404s with a JSON body (the plaintext listener answers, it just does not serve the wallet), so there is no live downgrade today. The risk is prospective: the moment the vhost serves both schemes, there is no HSTS to force the wallet onto TLS, and PBKDF2-protected seeds would be unlockable by an on-path attacker who can serve the page.\n\n## Third-party script note (weaker than it looks, stated honestly)\n\n`test.network/wallet` loads one third-party script with no `integrity` attribute:\n\n```html\n<script src=\"https://assist.edge.network/widget.js\" data-sitekey=\"ea_85a8c978130527cce742b5b5e5de55ee\" defer=\"\">\n```\n\nI pulled `widget.js` (36,833 bytes) and it contains `fetch(` ×4 and `localStorage` ×3 — a support-chat widget behaving normally, not obviously malicious. I want to be explicit that this script is on the **marketing** wallet page (`test.network`), **not** on the hosted wallet that handles seeds (`ldn.test.network/wallet`), which loads only same-origin `/assets/*.js` modules. So do not read this as \"a third party can reach the keystore\". The reason to mention it at all is that `test.network` sending no CSP means that widget has unrestricted same-origin reach into a page served from the domain that markets the wallet — a supply-chain dependency with no SRI and no policy floor. Low on its own; it is the missing CSP that makes it worth a line.\n\n## Suggested fix\n\nAdd the headers at the node's UI handler (`api/ui.go`, wrapping the `fileServer` like `corsMiddleware` already wraps the API) and at the `test.network` nginx layer:\n\n```\nContent-Security-Policy: default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; frame-ancestors 'none'; base-uri 'none'; form-action 'self'\nX-Frame-Options: DENY\nStrict-Transport-Security: max-age=31536000; includeSubDomains\nX-Content-Type-Options: nosniff\nReferrer-Policy: no-referrer\nPermissions-Policy: geolocation=(), microphone=(), camera=()\n```\n\n`wallet.js` is an ES module tree loading only same-origin modules, so `script-src 'self'` should be achievable without `unsafe-inline`. For `test.network`, either add SRI to the widget or move it behind `script-src` with an explicit hash, and drop `X-Powered-By`.\n\n## Prior art check\n\nNo open issue reports missing security headers on `test.network` or the node-served `/wallet/`. The nearest is #66 (\"Five Cryptographic Security Issues That Need Investigation\"), whose point 4 raises the wallet caching the unlock passphrase in `sessionStorage` for up to 30 minutes and asks the team to \"review the wallet's script-injection protections, dependency security, session expiration, and secret-handling practices\". This report is the concrete, measurable answer to that request on the header side: there is no CSP to bound injected script on the origin that holds the cached passphrase, and no frame protection on the origin that renders the seed. Filed separately because it is a distinct deployment defect with its own reproduction, not a duplicate of #66 — #66 is a design question, this is a missing header on a live host.\n\n## Scope\n\nPassive observation only: header reads and downloaded static assets. No wallet was created, no unlock attempted, no key material touched, no framing test performed against a real user.\n","patch_refs":[{"id":157,"repo":"xeprotocol/xe","kind":"pr","ref":"138","title":"fix(web,api): enforce security headers (CSP, X-Frame-Options, HSTS, X-Content-Type-Options) on web and wallet UI (#71)","url":"https://github.com/xeprotocol/xe/pull/138","note":"","state":"open","author":"arturbarszcz78","added_by":"desk","created_at":"2026-10-29T13:57:30.091343+00:00"}],"thread":[{"id":1578,"source":"github","source_ref":"6755095203","author":"XE desk","team":true,"body":"Read and accepted. It is tracked internally and the fix will land in a public PR; this issue is\nupdated when it does, and the tier and award follow the fix. The desk entry is https://bounty.xe.network/XE-0051.","created_at":"2026-11-10T00:15:51+00:00"}]}