/

CVE-2026-45721

Severity:

CRITICAL RISK

(9.0)

Improper Input Validation / Insecure Handler Resolution

CVE-2026-45721

Deferred

Vulnerability type

Category:

Improper Input Validation / Insecure Handler Resolution

CWE:

CWE-20, CWE-426, CWE-552

Impact:

Unauthenticated Remote Code Execution

Severity:

CRITICAL RISK

(9.0)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Algernon's directory handler resolution logic walks parent directories above the configured server root to locate and execute a handler.lua file, loading it with full server privileges.

If an attacker can place a handler.lua file in any parent directory of the server root, they can achieve pre-authenticated remote code execution when a client requests a directory without an index file.

Affected context

This vulnerability appears in Algernon deployments where:

  • The server root is set to a directory that has parent directories writable by other processes or users.
  • URL paths can resolve to directories without an index file, causing Algernon's DirPage logic to search for handler.lua.
  • The application relies on Algernon's permission system to protect paths, but handler resolution is performed before permission checks.

In such contexts, any handler.lua found in a parent directory up to the filesystem root may be treated as trusted server-side code and executed with full access to Algernon's Lua API.

Exploit preconditions

  • Attack surface: HTTP interface of the Algernon server.
  • Required access: Ability to write a handler.lua file to any directory that is an ancestor of the configured server root (e.g., /, /var, /var/www, or a drive root on Windows).
  • Trigger point: Any HTTP request to a URL that resolves to a directory under the server root with no index file, such as GET / on a default configuration.
  • Why exploitation is possible: The DirPage logic traverses ancestor directories past the configured root, searching for handler.lua without constraining the search to a trusted area and without authenticating the requester before handler resolution, effectively treating any discovered script as trusted code.

Why this happens

The core issue is improper input and path validation in the handler resolution mechanism.

When Algernon processes a directory request without an index file, it walks up the directory tree beyond the configured server root, trusting the first handler.lua it encounters as an authorized request handler.

This behavior maps primarily to CWE-20: Improper Input Validation, because the server does not constrain or validate the search path relative to a defined trust boundary.

It is closely related to CWE-426: Untrusted Search Path, as the application searches untrusted locations for executable scripts, and CWE-552: Files or Directories Accessible to External Parties, because files outside the intended web root effectively become executable server-side logic.

Conceptually, the bug is an insecure handler-dispatch pattern where path-derived lookups extend into untrusted filesystem scopes and are evaluated as code with high privileges.

Potential impact

  • Unauthenticated execution of arbitrary Lua code with full access to Algernon's APIs.
  • Execution of OS commands via os.execute, io.popen, or similar primitives.
  • Server takeover, including installation of backdoors or web shells.
  • Access to and modification of backend databases through PQ, MSSQL, or other database integrations.
  • Unauthorized reading, modification, or deletion of filesystem content accessible to the Algernon process.
  • Use of the compromised server as a pivot point for further network attacks or data exfiltration.

General mitigation guidance

Mitigation typically focuses on constraining handler discovery, tightening trust boundaries, and reducing the privileges available to dynamically loaded logic.

Safer handler resolution patterns:

  • Restrict handler lookup strictly to directories at or below the configured server root, avoiding any traversal into parent directories.
  • Explicitly define and whitelist directories from which server-side scripts may be loaded, rather than relying on implicit ancestor searches.
  • Separate configuration and code storage from writable or user-controlled directories, ensuring handlers reside only in administratively managed locations.

Trust and privilege reduction:

  • Run the Algernon process under a dedicated, least-privileged user account and with minimal filesystem permissions required for operation.
  • Ensure parent directories of the server root are not writable by untrusted users or processes and avoid hosting content roots on shared or multi-tenant paths.
  • Limit the scope of the Lua API available to handlers where possible, especially functions that spawn processes, access the network, or manipulate the filesystem.

Defensive configuration practices:

  • Treat server-root configuration as a security boundary, and review directory layouts to avoid untrusted parents.
  • Use separate volumes or mount points with clear ownership and permissions for application code, user content, and system files.
  • Document and enforce internal policies for how and where handler.lua or similar scripts can be deployed, and require review before adding new handlers.

How teams detect issues like this

Detection efforts can focus on both code-level patterns and runtime behavior.

Static analysis and review:

  • Examine handler resolution logic for any directory-walking loops that traverse above a configured root or trust boundary.
  • Flag code that searches for executable scripts (e.g., handler.lua) using ancestor traversal or unbounded search paths.
  • Review uses of embedded scripting engines (such as Lua) for unstructured loading of scripts from the filesystem, particularly when paths are derived from HTTP requests.
  • Integrate static analysis rules that identify untrusted search paths (CWE-426) and improper trust of files outside a configured root.

Configuration and policy checks:

  • Periodically scan deployments for writable directories that are ancestors of known server roots and verify ownership and permissions.
  • Enforce CI/CD policies requiring that new handler directories and routing configurations undergo security review.

Runtime monitoring:

  • Monitor logs for unexpected execution of handler.lua files from non-standard locations, especially outside the server root.
  • Use file integrity monitoring on directories where handlers are expected, alerting on new or modified handler.lua files in parent directories.
  • Employ host-based intrusion detection systems to watch for unusual process creation or filesystem modifications initiated by the Algernon process.

Sources

SourceLink
github.comgithub.com/xyproto/algernon/security/advisories/GHSA-xwcr-wm99-g9jc

Frequently asked

questions

This vulnerability is broadly exploitable in environments where any ancestor directory of the Algernon server root is writable by an untrusted user or process.

Because handler resolution occurs before authentication checks, a single crafted handler.lua in such a directory can be executed in response to a basic HTTP request, such as GET /, on affected configurations.

No.

The handler lookup and execution are performed before Algernon's permission system evaluates the request, so an attacker does not need valid credentials to trigger the vulnerable behavior.

The safest pattern is to ensure handler resolution is strictly confined to trusted directories at or below the configured server root, eliminating any ancestor directory search.

Combine this with clear separation of code and data directories, enforcement of least privilege, and review of any mechanism that loads executable scripts from the filesystem.

Future designs can avoid this class of issue by:

  • Defining explicit trust boundaries for filesystem operations and never searching above those boundaries.
  • Using explicit, whitelisted paths or configuration-driven routing instead of dynamic ancestor searches for handlers.
  • Adopting secure defaults in embedded scripting integrations, limiting available APIs and restricting script loading locations.
  • Incorporating security reviews and automated checks for untrusted search paths and directory traversal patterns during development and deployment.
Find out what's already
exploitable in your codebase.