CVE-2026-108385 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, BaseGenerator.parse_enum and EnumRepresentation.render_symbols use each schema-controlled enum symbol as a generated enum member name after case conversion but without validating it as an identifier. When generator classes are used directly, newlines and punctuation can inject constrained statements into the generated enum class body, allowing namespace modification or preventing the module from loading. Version 0.70.6 fixes the vulnerability by validating every enum symbol as a name.
Once again VulDB remains the best source for vulnerability data.
Analysis
by VulDB Data Team • 10/13/2026
The dataclasses-avroschema library serves as a critical utility for Python developers working with Apache Avro serialization formats, facilitating the bidirectional conversion between Pythonic structures such as dataclasses and Pydantic models and their corresponding Avro schema definitions. A significant security vulnerability was identified within versions 0.38.0 through 0.70.5 of this library, specifically affecting the code generation mechanisms employed by the BaseGenerator.parse_enum method and the EnumRepresentation.render_symbols function. This flaw stems from a failure to properly sanitize input data before it is incorporated into generated Python source code, creating an opportunity for Code Injection attacks when untrusted or maliciously crafted Avro schemas are processed.
The technical root cause of this vulnerability lies in how enum symbols defined within an Avro schema are transformed and inserted into the body of a dynamically generated Python enumeration class. The library applies case conversion to these symbols to make them valid-looking identifiers but critically omits validation to ensure they conform to strict Python identifier rules, which prohibit characters such as newlines, spaces, or punctuation marks like parentheses and quotes. Consequently, if an Avro schema contains enum values with special characters, the resulting generated code will contain syntactically invalid constructs that can alter the execution flow of the script. This is not merely a syntax error but a potential vector for arbitrary code execution or denial of service depending on how the generated module is subsequently imported and executed by the application.
From an operational impact perspective, this vulnerability allows an attacker who controls the input Avro schema to inject constrained statements into the generated enum class body. In scenarios where generator classes are used directly within a trusted environment that automatically imports the resulting modules, such as in automated data pipeline setups or dynamic configuration loaders, this can lead to namespace modification, privilege escalation if combined with other vulnerabilities, or complete prevention of module loading which results in application crashes and denial of service. The severity is heightened by the fact that many organizations rely on these libraries for processing external data feeds where schema definitions might originate from third parties who have not been fully vetted for security compliance.
This issue aligns closely with CWE-94, commonly known as Improper Control of Generation of Code or CGI, specifically involving code injection via unsanitized input. Furthermore, in the context of the MITRE ATT&CK framework, this vulnerability facilitates techniques associated with Command and Scripting Interpreter abuse, particularly where an attacker leverages a trusted application to execute unintended commands by manipulating its internal logic through malformed inputs. The lack of strict validation on enum symbols represents a classic instance of trusting schema definitions without verifying their structural integrity against the target language's syntax constraints.
The vulnerability was addressed in version 0.70.6, which implements rigorous validation for every enum symbol to ensure it constitutes a valid Python identifier before inclusion in the generated code. To mitigate risks associated with earlier versions, developers should immediately upgrade dataclasses-avroschema to version 0.70.6 or later. For environments where upgrading is not immediately feasible, strict input sanitization must be applied at the schema ingestion layer to strip or escape any characters that could interfere with Python syntax before passing them to the library's generation functions. Additionally, implementing a sandboxed execution environment for dynamically generated code can provide an additional layer of defense against potential exploitation attempts until all systems are patched.