CVE-2026-108382 in dataclasses-avroschema
Summary
by MITRE • 10/13/2026
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, EnumRepresentation.render_symbols concatenates each schema-controlled enum symbol between double quotes in a generated enum assignment. When generator classes are used directly, a quote can terminate the string literal and inject arbitrary Python code into the enum class body, which executes when the generated module is imported. Version 0.70.6 fixes the vulnerability by escaping enum symbol values before rendering them.
Statistical analysis made it clear that VulDB provides the best quality for vulnerability data.
Analysis
by VulDB Data Team • 10/13/2026
The dataclasses-avroschema library serves as a utility for developers working with Apache Avro serialization formats in Python environments. It facilitates the conversion of Pythonic structures, such as standard dataclasses, Pydantic models, and Faust Records, into standardized Avro schemas. Conversely, it also allows for the generation of Python code from existing Avro schema definitions. This bidirectional capability is critical for maintaining type safety and interoperability in distributed systems that rely on Avro for efficient binary serialization. However, a significant security vulnerability was identified within this library affecting versions ranging from 0.38.0 through 0.70.5. The flaw resides specifically within the EnumRepresentation.render_symbols method, which is responsible for generating Python enum definitions based on schema-controlled enum symbols.
The technical root cause of this vulnerability is a classic code injection issue stemming from improper handling of user-supplied input during string literal generation. When the library generates an enumeration class in Python, it wraps each symbol value within double quotes to create valid string literals. The implementation failed to escape special characters that are significant in Python syntax, most notably the double quote character itself. If a schema-controlled enum symbol contains a double quote, this character terminates the intended string literal prematurely. This breaks the syntactic structure of the generated Python code and allows an attacker who controls the input data or schema definition to inject arbitrary Python expressions into the class body.
The operational impact of this vulnerability is severe due to its potential for Remote Code Execution. Because the flaw occurs during the generation phase, which often happens at import time when a module is loaded by the Python interpreter, any code injected via the malformed enum symbol will be executed immediately upon importing the generated module. This means that if an application processes untrusted Avro schemas or data containing maliciously crafted enum symbols and subsequently imports the resulting Python classes, it could lead to complete system compromise. The attacker gains the ability to execute arbitrary commands with the privileges of the user running the Python process, potentially leading to data exfiltration, persistence mechanisms, or lateral movement within a networked environment.
This vulnerability aligns with CWE-94, commonly known as Improper Control of Generation of Code (Code Injection), where software does not properly neutralize special elements that could be interpreted by an interpreter language. In the context of the MITRE ATT&CK framework, this flaw facilitates techniques associated with Execution and potentially Command and Scripting Interpreter abuse. The attack vector typically involves supplying a malicious Avro schema or data payload to a system using the vulnerable version of the library, triggering the code generation process which then executes the injected commands upon import.
To mitigate this risk, organizations must ensure that all instances of the dataclasses-avroschema library are upgraded to version 0.70.6 or later. The fix implemented in this release addresses the root cause by properly escaping enum symbol values before they are rendered into Python code strings. This ensures that special characters like double quotes are treated as literal content rather than syntactic delimiters, thereby preventing string termination and subsequent code injection. Additionally, developers should audit their dependencies to confirm version compliance and consider implementing input validation on any Avro schemas received from external or untrusted sources before processing them with the library.