Read the docs

Path traversal in datamodel-code-generator lets attackers write files

Priority HIGH 72CWE-22Published · Updated

Key facts

Attack vector
Network
Privileges required
None
User interaction
None
Attack complexity
Low
Impact type
—
Confidentiality · integrity · availability
None · High · None
Fix status
Fixed

Attack profile from CVSS 3.1 · CNA. Fix status from CNA and GitHub.

Summary

datamodel-code-generator from 0.59.0 before 0.81.0 is affected. Its Protobuf parser accepts absolute or parent-directory paths from weak imports, so writes escape the temporary directory (CWE-22). An attacker who supplies a Protobuf schema can make a victim or automated job process it when grpcio-tools is installed, and can then create files or overwrite writable files with a proto syntax declaration. The written content is limited to that declaration, and direct code execution has not been demonstrated.

Written with Claude Haiku 5.5 from the sources below · 2026-10-29

Description from the CNA

datamodel-code-generator generates Python data models from schema definitions. From 0.59.0 until 0.81.0, an attacker-controlled Protobuf schema can supply absolute or parent-directory paths captured by WEAK_IMPORT_PATTERN and consumed by _write_missing_weak_imports in src/datamodel_code_generator/parser/protobuf.py. Exploitation requires a victim or automated job to process the attacker-controlled schema with Protobuf input support, which requires the grpcio-tools package. The paths escape the weak_imports temporary directory before protoc runs, allowing creation of directory trees and new files or overwrite of existing writable files with a generated Protobuf syntax declaration. The effect persists when later Protobuf compilation fails. The written content is limited to a proto2 or proto3 syntax declaration, and direct arbitrary code execution has not been demonstrated. This issue is fixed in version 0.81.0.

Why it matters now

Exploitation Proof of concept CISA SSVC · not in CISA KEV
EPSS 0.00535 45th percentileScored 2026-11-07
Fix Fixed datamodel-code-generator (datamodel-code-generator): 0.81.0datamodel-code-generator (PyPI): 0.81.0

SSVC decision points

CISA ADP · SSVC 2.0.3

Exploitation
Poc
Automatable
Yes
Technical impact
Partial

The decision (Track, Attend, Act) also depends on your mission and well-being impact; see CISA's SSVC guide.

Affected products

VendorProductAffected versionsFixed inStatusSource
datamodel-code-generatordatamodel-code-generator0.59.0 to before 0.81.00.81.0Patch availableCNA
—datamodel-code-generator (PyPI)0.59.0 to before 0.81.00.81.0Patch availableGHSA-77xj-x4rm-935c
  • datamodel-code-generator Vendordatamodel-code-generator Affected 0.59.0 to before 0.81.0 Fixed in 0.81.0 Patch available CNA
  • datamodel-code-generator (PyPI) Vendor— Affected 0.59.0 to before 0.81.0 Fixed in 0.81.0 Patch available GHSA-77xj-x4rm-935c

Remediation

Upgrade datamodel-code-generator to version 0.81.0, which fixes this issue.

Written with Claude Haiku 5.5 from the sources below · 2026-10-29

  • Fix · CNA datamodel-code-generator (datamodel-code-generator) Fixed in 0.81.0
  • Fix · GHSA-77xj-x4rm-935c datamodel-code-generator (PyPI) Fixed in 0.81.0 Advisory →

Timeline

  1. 2026-10-08 Threatist record created from CVE-2026-107377
  2. 2026-10-08 Alias added: GHSA-77xj-x4rm-935c
  3. 2026-10-10 Priority changed: MEDIUM → LOW
  4. 2026-10-14 CISA SSVC decision points changed
  5. 2026-10-14 Priority changed: LOW → HIGH

References

Sources