Advisory Database
  • Advisories
  • Dependency Scanning
  1. pypi
  2. ›
  3. djust
  4. ›
  5. CVE-2026-113731

CVE-2026-113731: djust: Arbitrary absolute-path file read in the find_handlers_for_template MCP tool

October 21, 2026

@mcp.tool()
def find_handlers_for_template(template_path: str) -> str:
"""
Args:
template_path: Either a logical template name (e.g.
'demos/counter.html' — what you'd pass to `render`) OR
an absolute filesystem path. Both are searched.
"""
...
resolved_path: str | None = None
if os.path.isabs(template_path) and os.path.isfile(template_path):
resolved_path = template_path
else:
...  # logical-name resolution via Django's template loader
...
with open(resolved_path, "r", encoding="utf-8", errors="replace") as f:
source = f.read()
handler_names_in_template = sorted({m.group(2) for m in dj_event_attr_re.finditer(source)})

When template_path is an absolute path to an existing file, it is used directly, with no confinement to the project/template directories — no realpath() + prefix check, no allowlist. open(resolved_path, …) then reads the file.

This is inconsistent with the sibling tool in the same file (loaddata, ~line 290-303), which explicitly rejects paths outside the project directory for its own path-like parameter:

candidate = os.path.realpath(...)
if base_dir and not candidate.startswith(os.path.realpath(str(base_dir))):
return json.dumps({"error": f"fixture path '{p}' resolves outside the project directory", ...})

find_handlers_for_template has no equivalent check for template_path before the open() call.

References

  • github.com/advisories/GHSA-r57g-mc79-8hj2
  • github.com/djust-org/djust/commit/45a5045793ebe7c9c2df86b0ad34275af6822619
  • github.com/djust-org/djust/commit/744bccf699c65c815d9379b36236a7c5592a339b
  • github.com/djust-org/djust/commit/85eed7caaf620bdb08986f2f3bb79432c0d3d715
  • github.com/djust-org/djust/commit/a62caf6b4ef540ad688d4dfdfa407ff914c78728
  • github.com/djust-org/djust/releases/tag/v1.0.10
  • github.com/djust-org/djust/releases/tag/v1.1.7
  • github.com/djust-org/djust/releases/tag/v1.2.4
  • github.com/djust-org/djust/releases/tag/v1.3.0rc8
  • github.com/djust-org/djust/security/advisories/GHSA-r57g-mc79-8hj2
  • nvd.nist.gov/vuln/detail/CVE-2026-113731

Code Behaviors & Features

Detect and mitigate CVE-2026-113731 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Dependency Scanning using SBOM also detects vulnerabilities from proprietary advisories that this site does not include. Learn more about Dependency Scanning using SBOM →

Affected versions

All versions starting from 0.9.0 before 1.0.10, all versions starting from 1.1.0 before 1.1.7, all versions starting from 1.2.0-dev.0 before 1.2.4, all versions starting from 1.3.0-dev.0 before 1.3.0-rc.8

Fixed versions

  • 1.0.10
  • 1.1.7
  • 1.2.4
  • 1.3.0-rc.8

Solution

Upgrade to versions 1.0.10, 1.1.7, 1.2.4, 1.3.0-rc.8 or above.

Impact 3.3 LOW

CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:N

Learn more about CVSS

Weakness

  • CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')

Source file

pypi/djust/CVE-2026-113731.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Sun, 08 Nov 2026 00:17:17 +0000.