CVE-2026-108380: dataclasses-avroschema field documentation allows code injection in generated Pydantic descriptions
dataclasses-avroschema generates Avro schemas from Python dataclasses, Pydantic models, and Faust Records and generates Python code from Avro schemas. From version 0.65.9 through 0.70.5, PydanticFieldRepresentation.addfieldproperties inserts a schema field's doc value between the quotes of a generated pydantic.Field description argument without escaping it. A crafted quote can terminate the string and inject an expression evaluated during generated class definition, allowing arbitrary Python code execution for Pydantic and AvroDantic model generation. Version 0.70.6 fixes the vulnerability by escaping the documentation value before rendering it.
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?
Deployments using dataclasses-avroschema versions 0.65.9 through 0.70.5 are exposed when they generate Pydantic or AvroDantic model code from an Avro schema containing field documentation. Dataclass and Faust Record generation are not identified as affected by this issue.
What must an attacker control to exploit this?
An attacker must be able to supply or modify an Avro schema field's doc value that is used in Pydantic or AvroDantic model generation. The documentation value must contain a crafted quote that escapes the generated description string and injects a Python expression.
When does the injected code run?
The injected expression is evaluated during generated class definition. Exploitation therefore requires the generated Python code to be executed or imported so that the class definition is evaluated.
What should be done if upgrading is not immediately possible?
Do not generate Pydantic or AvroDantic code from untrusted Avro schemas, and review or sanitize field doc values before generation. In particular, reject or remove crafted quote characters from documentation values until version 0.70.6 can be deployed.
How can teams determine whether they may already be affected?
Check whether dataclasses-avroschema is version 0.65.9 through 0.70.5 and whether Pydantic or AvroDantic code was generated from schemas with externally controlled field doc values. Review generated model source for description arguments containing unexpected code or documentation values with quote characters.