# CVE-2026-107377: datamodel-code-generator Protobuf path traversal allows files to be written outside directory

Source: https://junglewise.ai/threats/cve-2026-107377-datamodel-code-generator-protobuf-weak-import-path-traversal  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-10-08. Updated: 2026-10-08  
License: CC BY 4.0 with a link back

CVE-2026-107377 · Severity: high · CVSS 7.5 · Published 2026-10-08

datamodel-code-generator is a Python tool that generates code from schema definitions. When processing a malicious Protobuf schema, the tool could write files and create directories outside its intended temporary directory, allowing an attacker to corrupt source files, config files, or other critical build artifacts. An attacker could supply a malicious schema via file or URL, and the tool's vulnerability would trigger when a user processes it.

Technologies: [datamodel-code-generator (PyPI)](https://junglewise.ai/threats/technologies/pypi-datamodel-code-generator). Vendors: [PyPI](https://junglewise.ai/threats/vendors/pypi).

## Quick answers

**Is CVE-2026-107377 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2026-107377 being exploited in the wild.

**How severe is CVE-2026-107377?** High severity, with a CVSS score of 7.5, published 8 October 2026.

**Which products and versions are affected?** Datamodel-Code-Generator <=0.80.0; datamodel-code-generator (PyPI) >= 0.59.0, <= 0.80.0, ECOSYSTEM:introduced=0.59.0,fixed=0.81.0.

**Is there a fix for CVE-2026-107377?** Yes. datamodel-code-generator (PyPI): upgrade to 0.81.0 or later. Until then: Do not process untrusted Protobuf schemas with datamodel-code-generator; restrict use to internal, trusted schemas until a patched release is available. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2026-107377 attacked?** It is attacked over the network, in a software library.

**Am I affected by CVE-2026-107377?** Check whether you run Datamodel-Code-Generator or datamodel-code-generator (PyPI) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- datamodel-code-generator (PyPI): upgrade to 0.81.0 or later

  ```sh
  pip install "datamodel-code-generator>=0.81.0"
  ```


Do not process untrusted Protobuf schemas with datamodel-code-generator; restrict use to internal, trusted schemas until a patched release is available.

## Technical details

The vulnerability exists in the Protobuf weak-import handler (`_write_missing_weak_imports`) which concatenates an attacker-controlled import path from the schema directly into a filesystem write operation without path normalization or containment checks. Absolute paths and `../` sequences in the weak-import statement can escape the `__weak_import__` temporary directory. The code also has a timing flaw: it checks whether a file exists in one location but writes to a different base directory, allowing relative paths to overwrite existing files. The attack triggers before protoc validation, so compilation failure does not roll back the write.

## Affected products

- datamodel-code-generator datamodel-code-generator <=0.80.0

## Identifiers

- CVE-2026-107377
- GHSA-77xj-x4rm-935c
- PYSEC-2026-4205

## Timeline

- 2026-10-08: disclosed

## Related threats

- [datamodel-code-generator code injection in type annotation parsing](https://junglewise.ai/threats/cve-2026-127208-datamodel-code-generator-before-0-84-0-contains-a-code-injection)
- [koxudaxi datamodel-code-generator code injection in generated imports](https://junglewise.ai/threats/cve-2026-55415-koxudaxi-datamodel-code-generator-code-injection-in-generated)
- [koxudaxi datamodel-code-generator credential leak in cross-origin redirects](https://junglewise.ai/threats/cve-2026-55403-koxudaxi-datamodel-code-generator-credential-leak-in-cross-origin)
- [koxudaxi datamodel-code-generator SSRF via DNS rebinding](https://junglewise.ai/threats/cve-2026-55391-koxudaxi-datamodel-code-generator-ssrf-via-dns-rebinding)
- [koxudaxi datamodel-code-generator path traversal in XML Schema parsing](https://junglewise.ai/threats/cve-2026-55390-koxudaxi-datamodel-code-generator-path-traversal-in-xml-schema)
