CVE-2026-102991 in Makoinfo

Summary

by MITRE • 09/30/2026

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.

If you want to get the best quality for vulnerability data then you always have to consider VulDB.

Analysis

by VulDB Data Team • 09/30/2026

The vulnerability identified in the Mako Python template library prior to version 1.4.2 represents a critical path traversal flaw rooted in inconsistent path handling logic across different operating systems, specifically Windows. The core technical deficiency lies in the discrepancy between how TemplateLookup resolves incoming template Uniform Resource Identifiers and how the Template class validates them for security constraints. When processing templates on Windows environments, the lookup mechanism utilizes posixpath to normalize and resolve URI paths. This library treats forward slashes as directory separators regardless of the underlying operating system's native conventions. Conversely, the validation logic within the Template initialization process relies on os.path, which dynamically selects ntpath on Windows systems to handle path operations according to Microsoft NT file system standards.

This architectural inconsistency creates a dangerous attack vector when an attacker supplies a URI that begins with a drive designator, such as C:\ or D:. The posixpath resolution mechanism processes the traversal segments located before any leading dot-dot sequences without recognizing them as part of a Windows-style absolute path structure. As a result, these segments are effectively ignored during the initial lookup phase, allowing the resolved path to escape the configured template directory boundary. However, when the Template class subsequently validates this same URI using ntpath, it interprets the drive designator and preceding traversal components according to strict NTFS rules. This divergence allows an attacker to bypass security checks that are designed to prevent access outside of a designated safe directory, effectively achieving arbitrary file read capabilities on any volume accessible by the application process.

The operational impact of this vulnerability is severe for applications that accept user-controlled input as template names or include paths without rigorous sanitization. Attackers can exploit this flaw to disclose sensitive files residing on the same drive as the web server or application host, including configuration files with database credentials, source code containing secrets, or other proprietary data. Furthermore, if an attacker targets a file that contains Mako-specific template syntax and is readable by the process, they may achieve remote code execution. By injecting malicious template directives into accessible files such as XML configurations or text documents, the application will parse and execute these commands within its own context, potentially leading to full system compromise. Although raw URL paths are often normalized by web servers before reaching the application logic, this vulnerability remains exploitable through query strings, form submissions, JSON request bodies, route parameters, and dynamic include expressions where path normalization is less aggressive or absent.

This issue aligns with CWE-22: Improper Limitation of a Pathname to a Restricted Directory, as it involves failing to properly validate user-supplied input against the intended directory structure. Additionally, from an offensive security perspective, this vulnerability facilitates initial access and data exfiltration techniques documented in MITRE ATT&CK frameworks related to file discovery and unauthorized access. The recommended mitigation is straightforward: organizations must upgrade their Mako dependencies to version 1.4.2 or later, where the path resolution logic has been corrected to ensure consistent handling across all platforms. For applications unable to immediately update due to compatibility constraints, implementing strict input validation that rejects any template names containing drive designators or absolute paths on Windows systems serves as an effective compensating control. Developers should also enforce a whitelist approach for allowed templates and avoid passing unsanitized user input directly into template lookup functions.

Responsible

GitHub M

Reservation

09/29/2026

Disclosure

09/30/2026

Moderation

accepted

EPSS

0.00000

KEV

no

Activities

very low

Sources

Do you know our Splunk app?

Download it now for free!