{
  "id": "CVE-2026-54654",
  "url": "https://poc.griffinguard.io/cve/CVE-2026-54654",
  "published_at": "2026-07-28T21:22:52.07Z",
  "title": "`datamodel-code-generator` vulnerable to code injection via unescaped carriage return in `--extra-template-data` `comment` field",
  "vendor": "koxudaxi",
  "product": "datamodel-code-generator",
  "cvss": {
    "score": 7.8,
    "source": "cna",
    "vector": "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H"
  },
  "kev": {
    "in_kev": false,
    "added_at": null,
    "days_after_publication": null
  },
  "first_poc": null,
  "poc_repo_count": 0,
  "exploit_count": 0,
  "suspicious_repo_count": 0,
  "edge_device": null,
  "description": "datamodel-code-generator generates Python data models from schema definitions. From 0.14.1 until 0.60.2, the --extra-template-data comment field is rendered into Python comments in src/datamodel_code_generator/model/template/TypeAliasAnnotation.jinja2, src/datamodel_code_generator/model/template/TypedDict.jinja2, src/datamodel_code_generator/model/template/dataclass.jinja2, src/datamodel_code_generator/model/template/msgspec.Struct.jinja2, src/datamodel_code_generator/model/template/pydantic/BaseModel.jinja2, and src/datamodel_code_generator/model/template/pydantic_v2/BaseModel.jinja2 without neutralizing carriage returns in Python # comments, allowing an attacker-controlled comment value to inject Python code into generated models that runs when imported. This issue is fixed in version 0.60.2.",
  "cwe": "CWE-94",
  "cvss_by_source": {
    "cna": 7.8
  },
  "repos": [],
  "remediation": {
    "affected": [
      {
        "vendor": "koxudaxi",
        "product": "datamodel-code-generator",
        "ranges": [
          "\u003e= 0.14.1, \u003c 0.60.2"
        ],
        "fixed_in": [
          "0.60.2"
        ]
      }
    ],
    "upgrade": [
      "Upgrade datamodel-code-generator to 0.60.2 or later."
    ],
    "references": [
      {
        "kind": "Vendor advisory",
        "url": "https://github.com/koxudaxi/datamodel-code-generator/security/advisories/GHSA-wjv6-jcfj-mf9r"
      },
      {
        "kind": "Patch",
        "url": "https://github.com/koxudaxi/datamodel-code-generator/commit/b73abb5cd703a50471b8950bbd3bd0b82ad71de7"
      },
      {
        "kind": "Release notes",
        "url": "https://github.com/koxudaxi/datamodel-code-generator/releases/tag/0.60.2"
      }
    ]
  },
  "exploit_refs": [],
  "hunt_profile": [],
  "rules": []
}
