CVE-2026-108376: dataclasses-avroschema enum field defaults can inject statements into generated modules
dataclasses-avroschema generates Avro schemas from Python dataclasses, Pydantic models, and Faust Records and generates Python code from Avro schemas. From version 0.38.0 through 0.70.5, FieldRepresentation.getfielddefault renders a schema-controlled enum field default as an enum member reference after applying case conversion but without validating it as an identifier. Newlines, operators, and punctuation can escape the intended reference and inject constrained statements into the generated module, allowing namespace modification or preventing the module from loading. Version 0.70.6 fixes the vulnerability by validating enum defaults as names.
Other sources
dataclasses-avroschema generates Avro schemas from Python dataclasses, Pydantic models, and Faust Records and generates Python code from Avro schemas. From version 0.47.3 through 0.70.5, FieldRepresentation.getfielddefault inserts a schema-controlled referenced record name into the callable position of a generated defaultfactory lambda without validating it as an Avro name. A crafted record name can become an arbitrary Python expression that executes when an instance of the generated model consumes the field default. Version 0.70.6 fixes the vulnerability by rejecting record names that do not match the Avro name grammar.
— NVD
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
dataclasses-avroschemato a version that resolves this vulnerability.Fixed in 0.70.6
Event History
Frequently Asked Questions
Which deployments are exposed to this issue?
Deployments using dataclasses-avroschema versions 0.38.0 through 0.70.5 are affected when they generate Python code from an Avro schema containing a schema-controlled enum field default. The issue is in generated modules, not merely in schema generation.
What does an attacker need to exploit it?
An attacker needs to control, or cause the application to process, an Avro schema with a crafted enum field default. The crafted default must reach Python code generation; no authentication is required according to the supplied vector, but user interaction is required.
What is the impact of a successful exploit?
A crafted enum default can escape the intended enum-member reference and inject constrained statements into the generated Python module. This can modify the module namespace or cause the generated module to fail to load.
What should teams do if they cannot upgrade immediately?
Do not generate Python code from untrusted Avro schemas, and reject enum defaults that are not valid identifiers before code generation. Upgrading to version 0.70.6 is the documented fix.
How can teams identify potentially affected generated code?
Review generated Python modules produced from schemas with enum field defaults, especially where schemas originate from external or untrusted sources. Look for enum default values containing newlines, operators, or punctuation that would not be valid identifier names.