{"id":"CVE-2026-54656","published":"2026-07-28T21:43:56Z","modified":"2026-07-29T14:12:17Z","title":"`datamodel-code-generator` vulnerable to code execution on import via unescaped `validators` entries in…","vendor":"koxudaxi","product":"datamodel-code-generator","tier":"tail","description":{"text":"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.","provenance":"source","from":"CVE.org"},"cvss":{"score":7.8,"severity":"HIGH","version":"3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H","provenance":"source","from":"CVE.org CNA"},"epss":{"score":0.00252,"percentile":0.17036,"provenance":"source"},"cwes":[{"id":"CWE-94","name":"Improper Control of Generation of Code"}],"references":[{"url":"https://github.com/koxudaxi/datamodel-code-generator/security/advisories/GHSA-8m8r-38jm-f355","tags":["x_refsource_CONFIRM"]},{"url":"https://github.com/koxudaxi/datamodel-code-generator/commit/a43d02906111a2fdcaf13ee5b62eb2da85376f19","tags":["x_refsource_MISC"]},{"url":"https://github.com/koxudaxi/datamodel-code-generator/releases/tag/0.60.2","tags":["x_refsource_MISC"]}],"priority":{"score":8.9,"factors":[{"name":"EPSS percentile","points":3.41},{"name":"CVSS severity","points":5.46}]},"vendorSlug":"koxudaxi","affectedVersions":[{"vendor":"koxudaxi","product":"datamodel-code-generator","versions":[">= 0.52.1, < 0.60.2"]}],"ssvc":{"exploitation":"poc","automatable":"no","technicalImpact":"total","timestamp":"2026-07-29T14:12:01.711005Z","from":"CISA ADP","provenance":"source"},"affected":[{"ecosystem":"PyPI","package":"datamodel-code-generator","vulnerableRanges":[">=0.52.1, <0.60.2"],"patched":["0.60.2"],"from":["GHSA-8m8r-38jm-f355","PYSEC-2026-3559"],"provenance":"source"}],"summary":{"text":"The datamodel-code-generator tool, which generates Pydantic v2 models and related types from schemas, contains a flaw in its validator handling within base_model.py: validators supplied through --extra-template-data are interpolated into @field_validator decorators without safe validation, affecting versions from 0.52.1 through 0.60.2. An attacker who can get a crafted validators entry into the generator's template data can achieve Python code execution when the generated Pydantic v2 model is imported, which requires local access and user interaction to trigger.","provenance":"ai","model":"claude-haiku-5-5","generatedAt":"2026-11-20T22:07:16Z"},"euvd":{"id":"EUVD-2026-50075","exploited":false,"provenance":"source"}}