Repository navigation
deps: update dependency datamodel-code-generator to v0.81.0 [security] - #351
Open
renovate[bot] wants to merge 1 commit into
Open
renovate[bot] wants to merge 1 commit into
renovate[bot] wants to merge 1 commit into
Conversation
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
==0.75.1→==0.81.0datamodel-code-generator: Protobuf weak-import path traversal allows files to be written outside the temporary directory
CVE-2026-107377 / GHSA-77xj-x4rm-935c
More information
Details
Summary
When processing an attacker-controlled Protobuf schema, vulnerable versions of
datamodel-code-generatorcould write a generated weak-import stub outside theintended
__weak_imports__temporary directory. Absolute import paths and relativepaths containing
..could escape this directory.An attacker could create directories and new files at locations writable by the
process. Relative path traversal could also overwrite existing writable files
because the existence check and the stub write used different base directories.
An existing absolute target was skipped by the existence check.
Written content was limited to a generated Protobuf syntax declaration,
syntax = "proto2";orsyntax = "proto3";, followed by a newline. This issue didnot provide fully attacker-controlled file contents, and direct arbitrary code
execution has not been demonstrated.
These filesystem side effects occurred before
protocran. A subsequentcompilation error did not undo them. A user or CI job must process the
attacker-controlled schema for the issue to be triggered, whether the schema is
supplied as a local file or fetched via
--url.The fix has been merged into the parent repository's
mainbranch in5e94b8f. A patched package release is not yet available.
The technical details and PoC below describe the vulnerable implementation before
that fix.
Affected component
datamodel-code-generator/datamodel-code-generator(formerlykoxudaxi/datamodel-code-generator).pip install datamodel-code-generator==0.80.0) andmain@ commit834731d56c0a90c182a0919f316069cf5ff0659a(2026-09-13). Both contained the identical vulnerable sink.src/datamodel_code_generator/parser/protobuf.py, line numbers from 0.80.0):WEAK_IMPORT_PATTERN(protobuf.py:37) — attacker-controlled capture group._write_missing_weak_imports(protobuf.py:391-393) —weak_import_dir / import_path+mkdir(parents=True)+write_text._ProtoInputPreparer.__enter__(protobuf.py:333), beforeprotoc.main(...)runs inside thewithbody.--input-file-type protobufon an attacker-controlled.proto, supplied as a local file (--input) or a remote URL (--url). Requires thegrpcio-toolspackage (Protobuf support). The attacker does not need privileges on the affected system; filesystem effects are limited to locations writable by the code-generation process.Severity
Proposed: High.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N= 7.5.AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N= 7.5. This finding is the same attack surface (unvalidated path from a processed schema) with the impact moved from confidentiality (read) to integrity (write), henceC:N/I:H.AV:N: the malicious schema can be fetched over the network via--url, consistent with how the siblings were scored.I:H: attacker fully controls the write path and can create arbitrary directory trees and overwrite existing files; only the file content is constrained (a fixedsyntax = "proto{2,3}";line).A:Nchosen conservatively; overwriting build-critical files (lock files,__init__.py, entry points) can cause availability loss, which would argueA:L.UI:R), the score is 6.5 (Moderate). The project usedUI:Nfor the identical read-path siblings, soUI:Nis used here for consistency.Details
Source pattern — the imported path is captured with no character restriction:
Sink — the captured path is joined and written with no boundary check:
Two escape mechanisms, both from
pathlib's/semantics:Path(".../__weak_imports__") / "/etc/x"==/etc/x(an absoluteright operand replaces the base). Creates new files anywhere the process can write.
../traversal:Path(".../__weak_imports__") / "../../x"climbs out of thetemp directory.
Why the existence guard (line 389) does not protect the write: it checks
include_path / import_path, using a different base (include_paths) than theactual write, which uses
self.weak_import_dir / import_path. For a relativepath the two bases resolve to different directories, so the guard checks a location
that is not the real write target and misses it — enabling overwrite of existing
files. (For an absolute path the guard and the write coincide, so an already-
existing absolute target is skipped; absolute paths thus create new files but do not
overwrite. Overwrite is reached via the relative-traversal path.)
Timing:
_write_missing_weak_importsruns inside__enter__(line 333), andprotoc.main(...)runs later in thewithbody.protocrejects the malformedvirtual path (
Backslashes, consecutive slashes, "." or ".." are not allowed in the virtual path) and the overall command exits non-zero — but the file hasalready been written; the filesystem side effect is not rolled back.
Attack path
evil.protocontaining e.g.import weak "/home/victim/.config/x";and/or
import weak "../../overwrite_me.txt";, and gets the victim to process it(third-party schema, or
--urlto an attacker-hosted file)._write_missing_weak_importswrites the stub to the attacker-chosen path,creating any intermediate directories and overwriting an existing file (relative
case).
protocthen fails, but the file(s) are already on disk.Proof of Concept
Two self-contained scripts (
poc/reproduce.shfor--input,poc/reproduce-url.shfor
--url) install the releaseddatamodel-code-generator==0.80.0, serve/point amalicious
.proto, and assert the writes. The PoC drives the released packageunmodified; the sink file's sha256 is recorded in
REPRODUCE.md.Local
--inputrun against 0.80.0 — real output:Remote
--urlrun against 0.80.0 — real output (proto served over HTTP, then thesame writes fire):
Impact
Any user or CI pipeline that runs an affected version of
datamodel-code-generatoron an untrustedProtobuf schema (a downloaded third-party
.proto, or--urlto a remote source)is exposed to arbitrary file/directory creation and overwrite by the schema author,
with the process's own permissions. Concrete harms:
.env, lock files, or__init__.py/ entry-pointfiles → project corruption, broken builds, denial of service.
locations.
Direct arbitrary code execution has not been demonstrated. The written content
is limited to a generated
syntax = "proto2";orsyntax = "proto3";line and isnot fully attacker-controlled.
Resolution
The fix was merged into the parent repository's
mainbranch in5e94b8f.
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
SchemaParseErrorbefore checking include paths, creatingparent 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:
..traversal 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 versionsremains unset until arelease containing this fix is available. The advisory remains private pending
that release.
References
$refpath traversal (CWE-22/200/610, 7.5, patched 0.62.0). Same class, read primitive; sibling entry point.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.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 on
datamodel-code-generator/datamodel-code-generator, released 0.80.0 andmain@834731d56c0a90c182a0919f316069cf5ff0659a, 2026-09.Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
datamodel-code-generator: Protobuf weak-import path traversal allows files to be written outside the temporary directory
CVE-2026-107377 / GHSA-77xj-x4rm-935c / PYSEC-2026-4205
More information
Details
Summary
When processing an attacker-controlled Protobuf schema, vulnerable versions of
datamodel-code-generatorcould write a generated weak-import stub outside theintended
__weak_imports__temporary directory. Absolute import paths and relativepaths containing
..could escape this directory.An attacker could create directories and new files at locations writable by the
process. Relative path traversal could also overwrite existing writable files
because the existence check and the stub write used different base directories.
An existing absolute target was skipped by the existence check.
Written content was limited to a generated Protobuf syntax declaration,
syntax = "proto2";orsyntax = "proto3";, followed by a newline. This issue didnot provide fully attacker-controlled file contents, and direct arbitrary code
execution has not been demonstrated.
These filesystem side effects occurred before
protocran. A subsequentcompilation error did not undo them. A user or CI job must process the
attacker-controlled schema for the issue to be triggered, whether the schema is
supplied as a local file or fetched via
--url.The fix has been merged into the parent repository's
mainbranch in5e94b8f. A patched package release is not yet available.
The technical details and PoC below describe the vulnerable implementation before
that fix.
Affected component
datamodel-code-generator/datamodel-code-generator(formerlykoxudaxi/datamodel-code-generator).pip install datamodel-code-generator==0.80.0) andmain@ commit834731d56c0a90c182a0919f316069cf5ff0659a(2026-09-13). Both contained the identical vulnerable sink.src/datamodel_code_generator/parser/protobuf.py, line numbers from 0.80.0):WEAK_IMPORT_PATTERN(protobuf.py:37) — attacker-controlled capture group._write_missing_weak_imports(protobuf.py:391-393) —weak_import_dir / import_path+mkdir(parents=True)+write_text._ProtoInputPreparer.__enter__(protobuf.py:333), beforeprotoc.main(...)runs inside thewithbody.--input-file-type protobufon an attacker-controlled.proto, supplied as a local file (--input) or a remote URL (--url). Requires thegrpcio-toolspackage (Protobuf support). The attacker does not need privileges on the affected system; filesystem effects are limited to locations writable by the code-generation process.Severity
Proposed: High.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N= 7.5.AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N= 7.5. This finding is the same attack surface (unvalidated path from a processed schema) with the impact moved from confidentiality (read) to integrity (write), henceC:N/I:H.AV:N: the malicious schema can be fetched over the network via--url, consistent with how the siblings were scored.I:H: attacker fully controls the write path and can create arbitrary directory trees and overwrite existing files; only the file content is constrained (a fixedsyntax = "proto{2,3}";line).A:Nchosen conservatively; overwriting build-critical files (lock files,__init__.py, entry points) can cause availability loss, which would argueA:L.UI:R), the score is 6.5 (Moderate). The project usedUI:Nfor the identical read-path siblings, soUI:Nis used here for consistency.Details
Source pattern — the imported path is captured with no character restriction:
Sink — the captured path is joined and written with no boundary check:
Two escape mechanisms, both from
pathlib's/semantics:Path(".../__weak_imports__") / "/etc/x"==/etc/x(an absoluteright operand replaces the base). Creates new files anywhere the process can write.
../traversal:Path(".../__weak_imports__") / "../../x"climbs out of thetemp directory.
Why the existence guard (line 389) does not protect the write: it checks
include_path / import_path, using a different base (include_paths) than theactual write, which uses
self.weak_import_dir / import_path. For a relativepath the two bases resolve to different directories, so the guard checks a location
that is not the real write target and misses it — enabling overwrite of existing
files. (For an absolute path the guard and the write coincide, so an already-
existing absolute target is skipped; absolute paths thus create new files but do not
overwrite. Overwrite is reached via the relative-traversal path.)
Timing:
_write_missing_weak_importsruns inside__enter__(line 333), andprotoc.main(...)runs later in thewithbody.protocrejects the malformedvirtual path (
Backslashes, consecutive slashes, "." or ".." are not allowed in the virtual path) and the overall command exits non-zero — but the file hasalready been written; the filesystem side effect is not rolled back.
Attack path
evil.protocontaining e.g.import weak "/home/victim/.config/x";and/or
import weak "../../overwrite_me.txt";, and gets the victim to process it(third-party schema, or
--urlto an attacker-hosted file)._write_missing_weak_importswrites the stub to the attacker-chosen path,creating any intermediate directories and overwriting an existing file (relative
case).
protocthen fails, but the file(s) are already on disk.Proof of Concept
Two self-contained scripts (
poc/reproduce.shfor--input,poc/reproduce-url.shfor
--url) install the releaseddatamodel-code-generator==0.80.0, serve/point amalicious
.proto, and assert the writes. The PoC drives the released packageunmodified; the sink file's sha256 is recorded in
REPRODUCE.md.Local
--inputrun against 0.80.0 — real output:Remote
--urlrun against 0.80.0 — real output (proto served over HTTP, then thesame writes fire):
Impact
Any user or CI pipeline that runs an affected version of
datamodel-code-generatoron an untrustedProtobuf schema (a downloaded third-party
.proto, or--urlto a remote source)is exposed to arbitrary file/directory creation and overwrite by the schema author,
with the process's own permissions. Concrete harms:
.env, lock files, or__init__.py/ entry-pointfiles → project corruption, broken builds, denial of service.
locations.
Direct arbitrary code execution has not been demonstrated. The written content
is limited to a generated
syntax = "proto2";orsyntax = "proto3";line and isnot fully attacker-controlled.
Resolution
The fix was merged into the parent repository's
mainbranch in5e94b8f.
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
SchemaParseErrorbefore checking include paths, creatingparent 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:
..traversal 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 versionsremains unset until arelease containing this fix is available. The advisory remains private pending
that release.
References
$refpath traversal (CWE-22/200/610, 7.5, patched 0.62.0). Same class, read primitive; sibling entry point.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.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 on
datamodel-code-generator/datamodel-code-generator, released 0.80.0 andmain@834731d56c0a90c182a0919f316069cf5ff0659a, 2026-09.Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:NReferences
This data is provided by OSV and the GitHub Advisory Database (CC-BY 4.0).
datamodel-code-generator: Protobuf weak-import path traversal allows files to be written outside the temporary directory
CVE-2026-107377 / GHSA-77xj-x4rm-935c / PYSEC-2026-4205
More information
Details
Summary
When processing an attacker-controlled Protobuf schema, vulnerable versions of
datamodel-code-generatorcould write a generated weak-import stub outside theintended
__weak_imports__temporary directory. Absolute import paths and relativepaths containing
..could escape this directory.An attacker could create directories and new files at locations writable by the
process. Relative path traversal could also overwrite existing writable files
because the existence check and the stub write used different base directories.
An existing absolute target was skipped by the existence check.
Written content was limited to a generated Protobuf syntax declaration,
syntax = "proto2";orsyntax = "proto3";, followed by a newline. This issue didnot provide fully attacker-controlled file contents, and direct arbitrary code
execution has not been demonstrated.
These filesystem side effects occurred before
protocran. A subsequentcompilation error did not undo them. A user or CI job must process the
attacker-controlled schema for the issue to be triggered, whether the schema is
supplied as a local file or fetched via
--url.The fix has been merged into the parent repository's
mainbranch in5e94b8f. A patched package release is not yet available.
The technical details and PoC below describe the vulnerable implementation before
that fix.
Affected component
datamodel-code-generator/datamodel-code-generator(formerlykoxudaxi/datamodel-code-generator).pip install datamodel-code-generator==0.80.0) andmain@ commit834731d56c0a90c182a0919f316069cf5ff0659a(2026-09-13). Both contained the identical vulnerable sink.src/datamodel_code_generator/parser/protobuf.py, line numbers from 0.80.0):WEAK_IMPORT_PATTERN(protobuf.py:37) — attacker-controlled capture group._write_missing_weak_imports(protobuf.py:391-393) —weak_import_dir / import_path+mkdir(parents=True)+write_text._ProtoInputPreparer.__enter__(protobuf.py:333), beforeprotoc.main(...)runs inside thewithbody.--input-file-type protobufon an attacker-controlled.proto, supplied as a local file (--input) or a remote URL (--url). Requires thegrpcio-toolspackage (Protobuf support). The attacker does not need privileges on the affected system; filesystem effects are limited to locations writable by the code-generation process.Severity
Proposed: High.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N= 7.5.AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N= 7.5. This finding is the same attack surface (unvalidated path from a processed schema) with the impact moved from confidentiality (read) to integrity (write), henceC:N/I:H.AV:N: the malicious schema can be fetched over the network via--url, consistent with how the siblings were scored.I:H: attacker fully controls the write path and can create arbitrary directory trees and overwrite existing files; only the file content is constrained (a fixedsyntax = "proto{2,3}";line).A:Nchosen conservatively; overwriting build-critical files (lock files,__init__.py, entry points) can cause availability loss, which would argueA:L.UI:R), the score is 6.5 (Moderate). The project usedUI:Nfor the identical read-path siblings, soUI:Nis used here for consistency.Details
Source pattern — the imported path is captured with no character restriction:
Sink — the captured path is joined and written with no boundary check:
Two escape mechanisms, both from
pathlib's/semantics:Path(".../__weak_imports__") / "/etc/x"==/etc/x(an absoluteright operand replaces the base). Creates new files anywhere the process can write.
../traversal:Path(".../__weak_imports__") / "../../x"climbs out of thetemp directory.
Why the existence guard (line 389) does not protect the write: it checks
include_path / import_path, using a different base (include_paths) than theactual write, which uses
self.weak_import_dir / import_path. For a relativepath the two bases resolve to different directories, so the guard checks a location
that is not the real write target and misses it — enabling overwrite of existing
files. (For an absolute path the guard and the write coincide, so an already-
existing absolute target is skipped; absolute paths thus create new files but do not
overwrite. Overwrite is reached via the relative-traversal path.)
Timing:
_write_missing_weak_importsruns inside__enter__(line 333), andprotoc.main(...)runs later in thewithbody.protocrejects the malformedvirtual path (
Backslashes, consecutive slashes, "." or ".." are not allowed in the virtual path) and the overall command exits non-zero — but the file hasalready been written; the filesystem side effect is not rolled back.
Attack path
evil.protocontaining e.g.import weak "/home/victim/.config/x";and/or
import weak "../../overwrite_me.txt";, and gets the victim to process it(third-party schema, or
--urlto an attacker-hosted file)._write_missing_weak_importswrites the stub to the attacker-chosen path,creating any intermediate directories and overwriting an existing file (relative
case).
protocthen fails, but the file(s) are already on disk.Proof of Concept
Two self-contained scripts (
poc/reproduce.shfor--input,poc/reproduce-url.shfor
--url) install the releaseddatamodel-code-generator==0.80.0, serve/point amalicious
.proto, and assert the writes. The PoC drives the released packageunmodified; the sink file's sha256 is recorded in
REPRODUCE.md.Local
--inputrun against 0.80.0 — real output:Remote
--urlrun against 0.80.0 — real output (proto served over HTTP, then thesame writes fire):
Impact
Any user or CI pipeline that runs an affected version of
datamodel-code-generatoron an untrustedProtobuf schema (a downloaded third-party
.proto, or--urlto a remote source)is exposed to arbitrary file/directory creation and overwrite by the schema author,
with the process's own permissions. Concrete harms:
.env, lock files, or__init__.py/ entry-pointfiles → project corruption, broken builds, denial of service.
locations.
Direct arbitrary code execution has not been demonstrated. The written content
is limited to a generated
syntax = "proto2";orsyntax = "proto3";line and isnot fully attacker-controlled.
Resolution
The fix was merged into the parent repository's
mainbranch in5e94b8f.
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
SchemaParseErrorbefore checking include paths, creatingparent 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:
..traversal 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 versionsremains unset until arelease containing this fix is available. The advisory remains private pending
that release.
References
$refpath traversal (CWE-22/200/610, 7.5, patched 0.62.0). Same class, read primitive; sibling entry point.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.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 on
datamodel-code-generator/datamodel-code-generator, released 0.80.0 andmain@834731d56c0a90c182a0919f316069cf5ff0659a, 2026-09.Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:NReferences
This data is provided by OSV and the PyPI Advisory Database (CC-BY 4.0).
Release Notes
datamodel-code-generator/datamodel-code-generator (datamodel-code-generator)
v0.81.0Compare Source
v0.80.0Compare Source
v0.79.0Compare Source
v0.78.0Compare Source
v0.77.0Compare Source
v0.76.2Compare Source
v0.76.1Compare Source
v0.76.0Compare Source
Configuration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.