CVE-2026-102991

Mako: Path traversal via drive-letter URI on Windows in TemplateLookup

Published Sep 30, 2026 CVSS 3.1 · 6.5 Medium EPSS < 1% KEV · Not listed
Description
Mako is a template library written in Python. Prior to 1.4.2, on Windows, TemplateLookup.get_template() in mako/lookup.py resolves template URIs with posixpath, while Template.__init__() in mako/template.py validates them with os.path, which uses ntpath. A URI beginning with a drive designator causes ntpath to absorb the traversal segments before the leading dot-dot check, while posixpath resolution can escape the configured template directory. An application that passes attacker-controlled template names or include paths can disclose process-readable files on the same volume, and a targeted file containing Mako template syntax may also be parsed and executed as a template. Raw URL paths are generally normalized before reaching this form, but query strings, form or JSON bodies, route parameters, and dynamic include expressions can preserve it. This issue is fixed in version 1.4.2.

Analysis

AI-generated

Technical impact

The vulnerability is a directory traversal flaw that arises in the Mako template library when a Windows user supplies a URI that begins with a drive designator. In versions prior to 1.4.2, the lookup logic resolves the template path using posixpath, while the validation stage uses ntpath. This mismatch allows an attacker‑controlled template name or include path to escape the intended template directory, read files that are readable by the process, and, if the file contains Mako template syntax, have it parsed and executed as a template. The weakness is a CWE‑22 type input validation error.

Affected Systems

Mako, the Python templating library maintained by SQLAlchemy, is affected in all releases earlier than 1.4.2 when running on Windows. The flaw is specific to Windows file‑system handling and only impacts applications that invoke TemplateLookup.get_template() with untrusted or dynamic URI values.

Risk and Exploitability

The CVSS score of 6.5 places this flaw in the medium severity range. Exploit probability is not reported (EPSS not available) and the vulnerability is not listed in CISA’s KEV catalog, implying that it has not yet been widely exploited. However, the attack requires that an attacker can influence the template name or include path, which can occur in many web applications or services that accept user‑supplied template parameters. If exploit is possible, the attacker can read any process‑readable file on the same volume and potentially trigger template rendering of malicious content, leading to information disclosure and possibly code execution in the context of the running application.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Upgrade Mako to version 1.4.2 or later, which removes the path resolution mismatch on Windows
  • Validate or sanitize all template names and include paths, rejecting URIs that begin with a drive letter or contain traversal segments before normalization
  • Configure the application to confine template loading to a strict whitelisted directory and enforce path checks to prevent access outside that directory

Generated by OpenCVE AI on September 30, 2026 at 22:37 UTC.

Tracking

Sign in to view the affected projects.

Advisories

Source ID Title
Github GHSA Github GHSA GHSA-5639-2j2p-m4mx Mako: Path traversal via drive-letter URI on Windows in TemplateLookup
History
Type Values Removed Values Added
First Time appeared Sqlalchemy
Sqlalchemy mako
Vendors & Products Sqlalchemy
Sqlalchemy mako
Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'no', 'Exploitation': 'poc', 'Technical Impact': 'partial'}, 'version': '2.0.3'}

Type Values Removed Values Added
Description Mako is a template library written in Python. Prior to 1.4.2, on Windows, TemplateLookup.get_template() in mako/lookup.py resolves template URIs with posixpath, while Template.__init__() in mako/template.py validates them with os.path, which uses ntpath. A URI beginning with a drive designator causes ntpath to absorb the traversal segments before the leading dot-dot check, while posixpath resolution can escape the configured template directory. An application that passes attacker-controlled template names or include paths can disclose process-readable files on the same volume, and a targeted file containing Mako template syntax may also be parsed and executed as a template. Raw URL paths are generally normalized before reaching this form, but query strings, form or JSON bodies, route parameters, and dynamic include expressions can preserve it. This issue is fixed in version 1.4.2.
Title Mako: Path traversal via drive-letter URI on Windows in TemplateLookup
Weaknesses CWE-22
References
Metrics cvssV3_1

{'score': 6.5, 'vector': 'CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:L/A:N'}

Weaknesses
  • CWE-22

    Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')

Sources

Status
PUBLISHED
Assigner
GitHub_M
Published
Updated
Sep 30, 2026, 7:54 PM
Reserved
Sep 29, 2026, 8:46 PM
Status
Deferred
Published
Sep 30, 2026, 8:17 PM
Modified
Sep 30, 2026, 8:17 PM