Details
Remote --url run against 0.80.0 — real output (proto served over HTTP, then the
same writes fire):
[*] serving malicious proto at http://127.0.0.1:<port>/evil_url.proto
[PASS] server actually served the proto (HTTP 200)
[PASS] absolute-path arbitrary file created
[PASS] pre-existing victim overwritten via ../
==================== RESULT: 3 passed, 0 failed ====================
Impact
Any user or CI pipeline that runs an affected version ofdatamodel-code-generator on an untrusted
Protobuf schema (a downloaded third-party .proto, or --url to a remote source)
is exposed to arbitrary file/directory creation and overwrite by the schema author,
with the process's own permissions. Concrete harms:
- Overwrite source, config,
.env, lock files, or__init__.py/ entry-point files → project corruption, broken builds, denial of service. - Create arbitrary directory trees / drop files into watched or auto-loaded locations.
Direct arbitrary code execution has not been demonstrated. The written content
is limited to a generated syntax = "proto2"; or syntax = "proto3"; line and is
not fully attacker-controlled.
Resolution
The fix was merged into the parent repository's main branch in
5e94b8f.
The Protobuf input preparer now resolves the dedicated temporary weak-import
directory and each candidate stub path. If a resolved candidate is outside that
directory, it raises SchemaParseError before checking include paths, creating
parent directories, or writing the stub. The containment check rejects
absolute-path escapes and relative .. traversal that would leave the sandbox.
Input-preparation failures also immediately clean up the temporary directory.
Regression tests cover:
- rejection of absolute weak-import paths outside the sandbox;
- rejection of relative
..traversal outside the sandbox; - preservation of a pre-existing file outside the sandbox.
Local tox validation of the patch passed across the Python 3.10–3.14 and formatter
matrix, the CI compatibility environments, and the repository checks. Combined
line and branch coverage, including the changed files, reached 100%.
A fixed package has not yet been published to PyPI; the latest published version
at the time of this update is 0.80.0. Patched versions remains unset until a
release containing this fix is available. The advisory remains private pending
that release.
References
- GHSA-8359-h9fx-j6v9 / CVE-2026-55389 — datamodel-code-generator arbitrary local file read via JSON-Schema
$refpath traversal (CWE-22/200/610, 7.5, patched 0.62.0). Same class, read primitive; sibling entry point. - GHSA-442q-2j6p-642g / CVE-2026-55390 — datamodel-code-generator arbitrary local file read via XSD
schemaLocationpath traversal (CWE-22/200/610, 7.5, affected>= 0.59.0, <= 0.61.0, patched 0.62.0). Same class, read primitive; the fix sweep that missed the Protobuf entry point. - Python
pathlib—PurePath.__truediv__: an absolute right-hand operand discards the left operand;..segments are not normalized. (https://docs.python.org/3/library/pathlib.html)
Discovery
Found via source review and a reproducing PoC ondatamodel-code-generator/datamodel-code-generator, released 0.80.0 and main @834731d56c0a90c182a0919f316069cf5ff0659a, 2026-09.