p PatchFirst

CVE-2026-54656

CVE-2026-54656 · `datamodel-code-generator` vulnerable to code execution on import via unescaped `validators` entries in --extra-template-data

This page contains facts from public vulnerability sources. Check the original advisory before updating.

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.

CVSS 7.8 · High · EPSS 0.3% · Fix available

Published
Updated

Stack: python

Affected products and versions

  • datamodel-code-generator

    Versions
    • >= 0.52.1, < 0.60.2: Affected

    No fix published

  • datamodel-code-generator PyPI

    Versions
    • 0.52.1
    • 0.52.2
    • 0.53.0
    • 0.54.0
    • 0.54.1
    • 0.55.0
    • 0.56.0
    • 0.56.1
    • 0.57.0
    • 0.58.0
    • 0.59.0
    • 0.59.1
    • 0.60.0
    • 0.60.1
    Affected ranges
    • ECOSYSTEM: ≥ 0.52.1, < 0.60.2

    Update to 0.60.2

Original sources

Check your server →