CVE-2026-54654 is a template injection vulnerability in datamodel-code-generator that allows arbitrary Python code execution through the --extra-template-data flag. The mechanism: JSON data passed via this flag flows into Jinja2 templates that render comment fields in generated model files. By injecting carriage return characters (\r) into template data fields that populate comments, an attacker can break out of the comment context and inject executable Python code that runs when the generated file is imported.
The fix in version 0.60.2 neutralizes \r in comment rendering contexts — a surgical patch that closes this specific path but leaves the architectural question open. The --extra-template-data flag is positioned as a developer customization feature, implying trusted input, but the tool's primary value proposition is automated schema-to-model pipelines where that data originates from external schema registries or untrusted upstream sources. The mental model gap — developers thinking they control the configuration while the tool routes it into a code generation context — is the structural weakness this CVE exposes.
Two things defenders should do now: first, audit any pipelines using --extra-template-data where the input originates from automated sources, external schemas, or multi-team shared registries; treat that input as untrusted and sanitize before passing to the generator. Second, regenerate any model files created between the tool's initial release and 0.60.2 using the flag — already-generated files may contain injected code committed to version control as trusted artifacts, and the fix only protects new generations.
The EPSS score of 0.00142 is deceptively low. This reflects absence of targeted exploitation in the wild, not absence of exposure — the vulnerable configuration (automated pipelines with external schemas) is exactly where the tool delivers its value. Low EPSS + high value in vulnerable configurations means defenders relying on automated scoring are likely outpacing attackers who understand the tool's actual deployment patterns.
Beyond this specific patch, evaluate whether other template-rendered fields (docstrings, type annotations, error messages) have the same structural gap. The narrow fix suggests the maintainers addressed the discovered exploit path without auditing the full template-data rendering surface — the next discovered channel will likely follow the same pattern this one did.