CVE-2026-55390
Path traversal in XML schema parsing allows arbitrary local file read.
- CVSS 7.5
- 22
- Input Validation and Sanitization
- Local
datamodel-code-generator generates Python data models from schema definitions. From 0.59.0 until 0.62.0, XML Schema parsing in src/datamodel_code_generator/parser/xmlschema.py for –input-file-type xmlschema resolves xs:include, xs:import, xs:redefine, and xs:override schemaLocation values outside the input base path, allowing arbitrary local files to be read and reflected into generated models. This issue is fixed in version 0.62.0.
- CWE
- 22
- CVSS base score
- 7.5
- Published
- 2026-07-28
- OWASP
- A05 Security Misconfiguration
- Orthogonal defect classification
- Checking
- Code defect classification
- Missing Check
- Category
- Input Validation and Sanitization
- Subcategory
- Path Traversal
- Accessibility scope
- Local
- Impact
- Information Disclosure
- Affected component
- datamodel-co
- Fixed by upgrading
- Yes
Solution
Upgrade `datamodel-code-generator` to version 0.62.0 or later.
Vulnerable code sample
from pathlib import Path
from typing import Any, Dict, Optional
import xmlschema
# This is a simplified representation of the real class structure.
class XMLSchemaParser:
def __init__(self) -> None:
self.schema: Optional[xmlschema.XMLSchema] = None
def parse_raw(
self,
raw_text: str,
*,
base_path: Optional[Path] = None,
) -> None:
schema_kwargs: Dict[str, Any] = {}
if base_path:
# VULNERABLE: The base_url allows the underlying `xmlschema` library to resolve
# and read files outside `base_path` via `schemaLocation` attributes.
schema_kwargs["base_url"] = base_path.as_uri()
# An attacker can craft a schema with an `xs:include` tag and a
# `schemaLocation` like `../../../../etc/passwd` to read local files.
self.schema = xmlschema.XMLSchema(raw_text, **schema_kwargs)Patched code sample
from pathlib import Path
from typing import Any, Dict, Optional
import xmlschema
from xmlschema.resources import XMLResource
# This is a simplified representation of the real class structure.
class XMLSchemaParser:
def __init__(self) -> None:
self.schema: Optional[xmlschema.XMLSchema] = None
def parse_raw(
self,
raw_text: str,
*,
base_path: Optional[Path] = None,
) -> None:
schema_kwargs: Dict[str, Any] = {}
if base_path:
def _url_resolver(url: str) -> str:
# FIX: Resolve the file path and ensure it remains within the base_path
# directory to prevent path traversal.
path = (base_path / url).resolve()
if (
path != base_path.resolve()
and base_path.resolve() not in path.parents
):
raise ValueError(f"Path traversal is not allowed: `{url}`")
return url
schema_kwargs["base_url"] = base_path.as_uri()
schema_kwargs["url_resolver"] = _url_resolver
schema_kwargs["resource"] = XMLResource
self.schema = xmlschema.XMLSchema(raw_text, **schema_kwargs)Payload
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="/etc/passwd" />
</xs:schema>
Cite this entry
@misc{vaitp:cve202655390,
title = {{Path traversal in XML schema parsing allows arbitrary local file read.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-55390},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-55390/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
