8.7high
Mako: Path traversal via backslash URI on Windows in TemplateLookup
- Severity
- 8.7high CVSS:4.0 by GitHub_M
- Exploit likelihood
- 0.74% (higher than 55% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-2h4p-vjrc-8xpqPYSEC-2026-2617
Description
Mako is a template library written in Python. Prior to 1.3.12, on Windows, a URI using backslash traversal (e.g. \..\..\ secret.txt) bypasses the directory traversal check in Template.__init__ and the posixpath-based normalization in TemplateLookup.get_template(), allowing reads of files outside the configured template directory. This vulnerability is fixed in 1.3.12.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| sqlalchemy mako | < 1.3.12 | CVE List |
| mako (PyPI) | before 1.3.12 | GitHub Advisory Database, PyPA Advisory Database |
All scores
| GitHub_M | 8.7high CVSS:4.0 | 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 |
| GitHub | high CVSS:4.0 | 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 |
| PyPA Advisory Database | Not scored CVSS:4.0 | 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 |
Classification
SSVC (CISA-ADP): exploitation none, automatable yes, technical impact partial.
What each source says
CVE List
Mako is a template library written in Python. Prior to 1.3.12, on Windows, a URI using backslash traversal (e.g. \..\..\ secret.txt) bypasses the directory traversal check in Template.__init__ and the posixpath-based normalization in TemplateLookup.get_template(), allowing reads of files outside the configured template directory. This vulnerability is fixed in 1.3.12.
GitHub Advisory Database
Summary
On Windows, a URI using backslash traversal (e.g. \..\..\ secret.txt) bypasses the directory traversal check in Template.__init__ and the posixpath-based normalization in TemplateLookup.get_template(), allowing reads of files outside the configured template directory.
Details
The root cause is a mismatch between posixpath (used for URI normalization in get_template()) and os.path (used for file access via os.path.isfile() and validation via os.path.normpath() in Template.__init__). On Windows, os.path is ntpath, which treats \ as a path separator, while posixpath treats it as a literal character.
The vulnerability chain:
get_template()strips only leading/viare.sub(r"^\/+", "", uri)and normalizes withposixpath— backslash\is treated as a literal character, so\..\ secret.txtpasses through with..undetected.Template.__init__()validation usesos.path.normpath()— on Windows this resolves\..\ secret.txtto\secret.txt, which does not start with.., so thestartswith("..")check passes.os.path.isfile()on Windows interprets\as a path separator, resolving the..traversal and finding files outside the template directory.
Affected code
mako/lookup.py:TemplateLookup.get_template()usesposixpath.normpath/posixpath.joinfor path construction butos.path.isfile()for existence checkmako/template.py:Template.__init__()URI validation usesos.path.normpath()which on Windows resolves backslash traversal to a form that passes thestartswith("..")guard
Impact
If an application passes user-controlled template names or include paths to TemplateLookup.get_template(), an attacker on Windows may be able to load and disclose readable files outside the configured template directory. The primary impact is local file disclosure. If the targeted file contains Mako/Python template syntax, it may also be parsed and executed as a template.
Remediation
The fix should normalize backslashes to forward slashes early in the URI processing pipeline, before any path operations, to ensure consistent behavior across platforms.
NVD (es)
Mako es una biblioteca de plantillas escrita en Python. Antes de la 1.3.12, en Windows, una URI que utiliza salto de directorio con barras invertidas (por ejemplo, \.. / .. / secret.txt) omite la verificación de salto de directorio en Template.__init__ y la normalización basada en posixpath en TemplateLookup.get_template(), lo que permite la lectura de archivos fuera del directorio de plantillas configurado. Esta vulnerabilidad se corrigió en la 1.3.12.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-44307 changed 2026-05-13 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-2h4p-vjrc-8xpq changed 2026-09-10 | CC-BY-4.0 |
| NVD | CVE-2026-44307 changed 2026-10-26 | Public domain |
| PyPA Advisory Database | PYSEC-2026-2617 changed 2026-07-13 | CC-BY-4.0 |