NewApp Monitoring is liveSign up free
AgentbeamBeta
Open-source package vulnerability · PyPI

CVE-2026-41205: Mako: Path traversal via double-slash URI prefix in TemplateLookup

highCVSS 4.0 7.7 · 3.1 7.5GHSA-v92g-xgxw-vvmm

Summary TemplateLookup.gettemplate() is vulnerable to path traversal when a URI starts with // (e.g., //../../../secret.txt). The root cause is an inconsistency between two slash-stripping implementations: - Template.init strips one leading / using if/slice - TemplateLookup.gettemplate() strips all leading / using re.sub(r"^\/+", "") When a URI like //../../../../etc/passwd is passed: 1.

Published Apr 16, 2026 · Updated Jun 5, 2026

Affected packages

Mako

Ecosystem
PyPI
Affected
<= 1.3.10
Fixed in
1.3.11
Check
pip show Mako

Advisory details

From the GitHub Advisory Database (CC BY 4.0).

Summary

TemplateLookup.get_template() is vulnerable to path traversal when a URI starts with // (e.g., //../../../secret.txt). The root cause is an inconsistency between two slash-stripping implementations:

  • Template.__init__ strips one leading / using if/slice
  • TemplateLookup.get_template() strips all leading / using re.sub(r"^\/+", "")

When a URI like //../../../../etc/passwd is passed:

  1. get_template() strips all / → ../../../../etc/passwd → file found via posixpath.join(dir_, u)
  2. Template.__init__ strips one / → /../../../../etc/passwd → normpath → /etc/passwd
  3. /etc/passwd.startswith(..) → False → check bypassed

Impact

Arbitrary file read: any file readable by the process can be returned as rendered template content when an application passes untrusted input directly to TemplateLookup.get_template().

Note: this is exploitable at the library API level. HTTP-based exploitation is mitigated by Python's BaseHTTPRequestHandler which normalizes double-slash prefixes since CPython gh-87389. Applications using other HTTP servers that do not normalize paths may be affected.

Fix

Changed Template.__init__ to use lstrip("/") instead of stripping only a single leading slash, so both code paths handle leading slashes consistently.

Credited to 0xHunSec, augustocesarperin.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology

More PyPI vulnerabilities

All PyPI entries