CVE-2026-102991: Mako: Path traversal via drive-letter URI on Windows in TemplateLookup
Mako is a template library written in Python. Prior to 1.4.2, on Windows, TemplateLookup.gettemplate() 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.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
Makoto a version that resolves this vulnerability.Fixed in 1.4.2
Event History
Frequently Asked Questions
Which deployments are exposed?
Windows deployments using Mako versions before 1.4.2 are exposed when an application passes attacker-controlled template names or include paths to TemplateLookup.get_template(). Inputs from query strings, form or JSON bodies, route parameters, and dynamic include expressions may preserve the required path form.
What does an attacker need to provide?
The attacker needs to control a template URI or include path that begins with a drive designator. Raw URL paths are generally normalized before reaching this form, so exploitation depends on an application accepting the value through another input path or preserving it in a dynamic include expression.
What is the practical impact?
An attacker may escape the configured template directory and disclose files readable by the process on the same volume. If a targeted file contains Mako template syntax, it may also be parsed and executed as a template.
How can this be remediated?
Upgrade Mako to version 1.4.2, which fixes the issue. Review application code that passes externally controlled values as template names or include paths.