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.
A code injection vulnerability exists in dataclasses-avroschema versions 0.38.0 through 0.70.5. The vulnerability arises because the BaseGenerator.parse_fixed method interpolates a fixed type's aliases value directly into generated Python code without proper sanitization. If the aliases value is a bare string, it is emitted as an unquoted Python expression and evaluated when the generated module is imported, enabling arbitrary code execution. This issue is fixed in version 0.70.6 by rejecting aliases values that are not lists.
A code injection vulnerability exists in dataclasses-avroschema versions 0.38.0 through 0.70.5. The issue arises from improper validation of enum field defaults during schema generation, allowing injection of malicious code via crafted enum defaults. This can lead to namespace modification or failure to load the generated module. Version 0.70.6 addresses this by validating enum defaults as valid identifiers.
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.
A code injection vulnerability (CWE-94) exists in dataclasses-avroschema versions 0.44.0 through 0.70.5. The vulnerability arises because the Pydantic and AvroDantic model generators insert a schema field's pydantic-class value into generated Python code annotations without proper restriction, allowing arbitrary Python code execution when the generated module is imported. This issue is fixed in version 0.70.6 by restricting the inserted value to a bare name or a call to a bare name with literal arguments.
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.add_field_properties 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.
A code injection vulnerability exists in dataclasses-avroschema versions 0.38.0 through 0.70.5. The issue arises from improper handling of the fixed type's namespace value in generated Python code, allowing an attacker to inject arbitrary code. This is fixed in version 0.70.6 by enforcing namespace validation.
dataclasses-avroschema versions 0.40.0 through 0.70.5 contain a code injection vulnerability in the ClassRepresentation.render_docstring function. This function copies schema record doc values into generated Python class docstrings without escaping quotes or backslashes, allowing crafted input to inject and execute arbitrary Python code during module import. Version 0.70.6 addresses this issue by properly escaping unsafe characters in docstrings.
dataclasses-avroschema generates Avro schemas from Python dataclasses, Pydantic models, and Faust Records and generates Python code from Avro schemas. From version 0.62.3 through 0.70.5, ClassRepresentation.render_metaclass inserts a schema-controlled Avro record name into the quoted Meta.schema_name field of generated Python source without escaping it. A crafted name can terminate the string literal and inject statements into the generated class body, which execute when the generated module is imported. Version 0.70.6 fixes the vulnerability by escaping schema values rendered into generated string literals.
A code injection vulnerability exists in dataclasses-avroschema versions 0.47.3 through 0.70.5. The issue arises because the FieldRepresentation.get_field_default method inserts a schema-controlled record name into a generated default_factory lambda without validating it as a proper Avro name. This allows a crafted record name to be interpreted as arbitrary Python code, which executes when an instance of the generated model uses the field default. The vulnerability is fixed in version 0.70.6 by enforcing Avro name grammar validation on record names.
A code injection vulnerability (CWE-94) exists in dataclasses-avroschema versions 0.38.0 through 0.70.5. The vulnerability arises because FieldRepresentation.get_field_default inserts certain schema-controlled default values into generated Python source code without proper escaping. This allows crafted defaults to break out of string literals and inject arbitrary code that executes when the generated module is imported. The issue is fixed in version 0.70.6 by escaping schema values in generated string literals.