CVE-2026-107377: datamodel-code-generator Protobuf Weak-Import Path Traversal Vulnerability
Summary
CVE-2026-107377: When processing an attacker-controlled Protobuf schema, vulnerable versions of datamodel-code-generator could write a generated weak-import stub outside the intended weak_imports temporary directory. Affects datamodel-code-generator versions >= 0.59.0, < 0.81.0. Fixed in 0.81.0. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
datamodel-code-generator is a Python package designed to generate data models from various schema formats, including Protobuf. It simplifies the process of creating data models by automating the generation of code based on schema definitions. However, certain versions of this package are vulnerable to a path traversal issue that allows attackers to manipulate file paths, potentially leading to unauthorized file creation or overwriting.
Vulnerability Detail
The vulnerability arises from the way datamodel-code-generator processes attacker-controlled Protobuf schemas. Specifically, it allows for weak-import stubs to be written outside the intended temporary directory due to improper validation of import paths. Attackers can exploit this by crafting malicious Protobuf files that include absolute paths or relative paths with '..', enabling them to create files or directories in arbitrary locations writable by the process. This could lead to overwriting critical files, resulting in project corruption or denial of service. The vulnerability affects versions up to 0.80.0 and has a CVSS score of 7.5, indicating a high severity level.
How To Fix
Latest published version: 0.86.0 as of 22 Oct 2026
pip install --upgrade "datamodel-code-generator==0.86.0"
Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.
If you need the minimum change
0.81.0
This is the first release that contains the fix.
pip install --upgrade "datamodel-code-generator==0.81.0"
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
As a temporary workaround, avoid processing untrusted Protobuf schemas or ensure that any schemas processed are from trusted sources. Additionally, you can implement file system permissions to restrict write access to sensitive directories.
Conclusion
The CVE-2026-107377 vulnerability in the datamodel-code-generator package poses a significant risk due to its potential for path traversal attacks. Users are strongly advised to update to the patched version 0.81.0 to mitigate this risk. Additionally, employing best practices for handling untrusted schemas can further enhance security.
See every vulnerability recorded for datamodel-code-generator →
FAQ
The vulnerability allows for path traversal, enabling attackers to write files outside the intended directory.
Versions up to and including 0.80.0 are affected by this vulnerability.
Attackers can create or overwrite files in arbitrary locations, potentially corrupting projects or causing denial of service.
You can use Vulert to monitor and alert for open-source vulnerabilities in your software. Visit Vulert Scanner to check if your application is affected.
Yes, a patch is available in version 0.81.0 of the datamodel-code-generator package.
References
Related vulnerabilities
Recent vulnerabilities recorded for datamodel-code-generator.