CVE-2026-54656
HIGH 7.8CVSS 3.1`datamodel-code-generator` vulnerable to code execution on import via unescaped `validators` entries in --extra-template-data
datamodel-code-generator generates Pydantic v2 models, dataclasses, TypedDict, and msgspec.Struct from OpenAPI, JSON Schema, GraphQL, Avro, Protobuf, and raw JSON, YAML, or CSV. From 0.52.1 until 0.60.2, datamodel-code-generator interpolates validators from --extra-template-data in src/datamodel_code_generator/model/pydantic_v2/base_model.py through _process_validators into @field_validator decorators without safe validation, allowing Python code execution when the generated Pydantic v2 model is imported. This issue is fixed in version 0.60.2.
- Published
- 28 Jul 2026
- Last modified
- 23 Oct 2026
- Assigned by
- security-advisories@github.com
- NVD status
- Analyzed
- Weakness
- CWE-94
- Also known as
- GHSA-8m8r-38jm-f355PYSEC-2026-3559
- Sources
- NVDJSONOSV GHSA-8m8r-38jm-f355JSONOSV PYSEC-2026-3559JSON
Scores
| Source | Scored by | Version | Score | Vector / decision |
|---|---|---|---|---|
| NVD | security-advisories@github.com (Secondary) | CVSS 3.1 | HIGH 7.8 | CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H |
| OSV | GitHub | CVSS 3.1 | HIGH 7.8 | CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H |
| OSV | PyPA | CVSS 3.1 | HIGH 7.8 | CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H |
Affected
| Source | Vendor / ecosystem | Product / package | Affected versions | Fixed in |
|---|---|---|---|---|
| NVD | koxudaxi | datamodel-code-generatorcpe:2.3:a:koxudaxi:datamodel-code-generator:*:*:*:*:*:*:*:* |
>= 0.52.1, < 0.60.2 | 0.60.2 |
| OSV | PyPI | datamodel-code-generator | >= 0.52.1, < 0.60.2 | 0.60.2 |
References
- https://github.com/koxudaxi/datamodel-code-generator/commit/a43d02906111a2fdcaf13ee5b62eb2da85376f19 · Patch, WEB
- https://github.com/koxudaxi/datamodel-code-generator/releases/tag/0.60.2 · Release Notes, WEB
- https://github.com/koxudaxi/datamodel-code-generator/security/advisories/GHSA-8m8r-38jm-f355 · Exploit, Vendor Advisory, WEB
- https://github.com/koxudaxi/datamodel-code-generator · PACKAGE
- https://pypi.org/project/datamodel-code-generator · PACKAGE
- https://github.com/advisories/GHSA-8m8r-38jm-f355 · ADVISORY
- https://nvd.nist.gov/vuln/detail/CVE-2026-54656 · ADVISORY
History
- 25 Nov 2026 21:04 UTC · NVD: first stored (published 28 Jul 2026)
- 25 Nov 2026 20:12 UTC · OSV: first stored (published 4 Aug 2026)
- 25 Nov 2026 20:11 UTC · OSV: first stored (published 28 Jul 2026)