{"id":"CVE-2026-44307","aliases":["CVE-2026-44307","GHSA-2h4p-vjrc-8xpq","PYSEC-2026-2617"],"related":[],"kind":"vulnerability","state":"published","title":"Mako: Path traversal via backslash URI on Windows in TemplateLookup","summary":"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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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.","source":"cvelist"},{"lang":"en","text":"## Summary\n\nOn 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.\n\n\n## Details\n\nThe 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.\n\nThe vulnerability chain:\n\n1. `get_template()` strips only leading `/` via `re.sub(r\"^\\/+\", \"\", uri)` and normalizes with `posixpath` — backslash `\\` is treated as a literal character, so `\\..\\ secret.txt` passes through with `..` undetected.\n2. `Template.__init__()` validation uses `os.path.normpath()` — on Windows this resolves `\\..\\ secret.txt` to `\\secret.txt`, which does not start with `..`, so the `startswith(\"..\")` check passes.\n3. `os.path.isfile()` on Windows interprets `\\` as a path separator, resolving the `..` traversal and finding files outside the template directory.\n\n### Affected code\n\n- `mako/lookup.py`: `TemplateLookup.get_template()` uses `posixpath.normpath`/`posixpath.join` for path construction but `os.path.isfile()` for existence check\n- `mako/template.py`: `Template.__init__()` URI validation uses `os.path.normpath()` which on Windows resolves backslash traversal to a form that passes the `startswith(\"..\")` guard\n\n## Impact\n\nIf 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.\n\n## Remediation\n\nThe fix should normalize backslashes to forward slashes early in the URI processing pipeline, before any path operations, to ensure consistent behavior across platforms.","format":"markdown","source":"ghsa"},{"lang":"es","text":"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.","source":"nvd"}],"published":"2026-05-06T21:45:16.000Z","modified":"2026-10-26T14:10:00.130Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"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","score":8.7,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"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","score":8.7,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"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","rating":"HIGH"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:4.0","vector":"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"}],"cwes":["CWE-22"],"affected":[{"ranges":[{"version":"< 1.3.12","status":"affected"}],"vendor":"sqlalchemy","product":"mako","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"1.3.12"}],"ecosystem":"PyPI","package":"mako","purl":"pkg:pypi/mako","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"1.3.12"}],"ecosystem":"PyPI","package":"mako","purl":"pkg:pypi/mako","source":"pysec"}],"references":[{"url":"https://github.com/sqlalchemy/mako/security/advisories/GHSA-2h4p-vjrc-8xpq","tags":["web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/sqlalchemy/mako/issues/435","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/sqlalchemy/mako/commit/72e10c573ca0fbcbddd4455abca8ce92a61780d7","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/sqlalchemy/mako/releases/tag/rel_1_3_12","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-44307","tags":["advisory"],"sources":["ghsa","pysec"]},{"url":"https://github.com/sqlalchemy/mako","tags":["package"],"sources":["ghsa","pysec"]},{"url":"https://pypi.org/project/mako","tags":["package"],"sources":["pysec"]},{"url":"https://github.com/advisories/GHSA-2h4p-vjrc-8xpq","tags":["advisory"],"sources":["pysec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"yes","technicalImpact":"partial","date":"2026-05-13T14:57:34.308Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-44307","url":"https://www.cve.org/CVERecord?id=CVE-2026-44307","licence":"CVE Terms of Use","modified":"2026-05-13T15:00:13.642Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-2h4p-vjrc-8xpq","url":"https://github.com/advisories/GHSA-2h4p-vjrc-8xpq","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:45.452Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-44307","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-44307","licence":"Public domain","modified":"2026-10-26T14:10:00.130Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-2617","url":"https://osv.dev/vulnerability/PYSEC-2026-2617","licence":"CC-BY-4.0","modified":"2026-07-13T16:32:12.378Z"}],"updatedAt":"2026-11-25T22:59:21.513Z","epss":{"score":0.00742,"percentile":0.55876,"date":"2026-12-01T12:00:22.000Z"}}