# CVE-2026-54653: `datamodel-code-generator` vulnerable to code injection in via attacker-controlled `default_factory` schema field

- Severity: High 8.8 (CVSS:3.1, scored by GitHub_M) `CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Likelihood of exploitation in the next 30 days (EPSS): 0.37%, higher than 32% of CVEs (2026-12-01)
- Public exploit code or proof of concept: 2 links below, marked "exploit"
- Published: 2026-07-28T21:48:04.619Z
- Modified: 2026-10-23T23:10:00.157Z
- Also known as: GHSA-386q-5hp3-95m9, PYSEC-2026-3555
- Weaknesses: CWE-94, CWE-1336
- SSVC (CISA-ADP): exploitation none, automatable no, technical impact total
- Assigned by: GitHub_M

## Description

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.17.0 until 0.60.2, datamodel-code-generator preserves attacker-controlled default_factory values in src/datamodel_code_generator/parser/jsonschema.py through JsonSchemaObject.init and get_field_extras and emits them into Field(default_factory=...) or field(default_factory=...), allowing Python expression execution when the generated model is imported. This issue is fixed in version 0.60.2.

(As written by CVE List.)

## Affected

- koxudaxi datamodel-code-generator: >= 0.17.0, < 0.60.2; from 0.17.0 before 0.60.2
- datamodel-code-generator (PyPI): from 0.17.0 before 0.60.2

## Every score

- GitHub_M: CVSS:3.1 8.8 High `CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H`
- GitHub: CVSS:3.1 8.8 High `CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H`
- PyPA Advisory Database: CVSS:3.1 8.8 High `CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H`

## References

- <https://github.com/koxudaxi/datamodel-code-generator/security/advisories/GHSA-386q-5hp3-95m9> (exploit, vendor-advisory, web)
- <https://gist.github.com/thegr1ffyn/9648b0fe4fcf7d569ac8e61dd11eebaf> (exploit, third-party-advisory)
- <https://github.com/koxudaxi/datamodel-code-generator/commit/17fc235e234cbcfaaadef8c74cb72c9687db0d1d> (patch, web)
- <https://github.com/koxudaxi/datamodel-code-generator/releases/tag/0.60.2> (release-notes, web)
- <https://github.com/koxudaxi/datamodel-code-generator> (package)
- <https://pypi.org/project/datamodel-code-generator> (package)
- <https://github.com/advisories/GHSA-386q-5hp3-95m9> (advisory)
- <https://nvd.nist.gov/vuln/detail/CVE-2026-54653> (advisory)

## Sources

- CVE List: [CVE-2026-54653](https://www.cve.org/CVERecord?id=CVE-2026-54653), CVE Terms of Use, modified 2026-07-29
- GitHub Advisory Database: [GHSA-386q-5hp3-95m9](https://github.com/advisories/GHSA-386q-5hp3-95m9), CC-BY-4.0, modified 2026-09-10
- NVD: [CVE-2026-54653](https://nvd.nist.gov/vuln/detail/CVE-2026-54653), Public domain, modified 2026-10-23
- PyPA Advisory Database: [PYSEC-2026-3555](https://osv.dev/vulnerability/PYSEC-2026-3555), CC-BY-4.0, modified 2026-08-04

---

Page: https://cve.day/CVE-2026-54653 · Whole record: https://cve.day/CVE-2026-54653.json · Rebuilt by cve.day 2026-11-25T22:59:30.385Z
