Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2026-108385 Overview
CVE-2026-108385 is a code injection vulnerability [CWE-94] in dataclasses-avroschema, a Python library that generates Avro schemas from dataclasses, Pydantic models, and Faust Records. The flaw affects versions 0.38.0 through 0.70.5. The BaseGenerator.parse_enum and EnumRepresentation.render_symbols methods consume schema-controlled enum symbols as generated Python enum member names after case conversion but without validating them as identifiers. An attacker who controls an Avro schema fed to the generator can inject Python statements into the enum class body, allowing namespace modification or module load failure.
Critical Impact
Attacker-controlled Avro schemas can inject arbitrary Python code into generated modules, compromising confidentiality, integrity, and availability of applications that process untrusted schemas.
Affected Products
- dataclasses-avroschema version 0.38.0 through 0.70.5
- Python code generators invoking BaseGenerator.parse_enum directly
- Downstream applications consuming generated enum classes from untrusted Avro schemas
Discovery Timeline
- 2026-10-13 - CVE-2026-108385 published to NVD
- 2026-10-13 - Last updated in NVD database
- Patch released - Version 0.70.6 validates every enum symbol as a Python identifier
Technical Details for CVE-2026-108385
Vulnerability Analysis
The vulnerability resides in the code generation pipeline that converts Avro enum definitions into Python enum classes. When BaseGenerator.parse_enum processes an Avro schema, each symbol in the enum's symbols array is passed through case conversion and then embedded directly into the generated Python source. The library did not verify that the resulting token conformed to Python identifier rules.
Because the rendered text becomes code rather than a string literal, standard escaping does not apply. A symbol containing newlines, equals signs, or other punctuation terminates the enum member assignment and introduces additional statements inside the enum class body. The injected statements execute whenever the generated module is imported.
Impact ranges from namespace tampering (overwriting attributes, redefining helpers) to a denial-of-service condition where the generated module fails to parse. The vulnerability is categorized as Code Injection [CWE-94].
Root Cause
The root cause is missing identifier validation on schema-controlled strings that are rendered as code. EnumRepresentation.render_symbols emitted symbols verbatim into the class body. Any value that is syntactically a valid Python token sequence after case conversion is accepted, including sequences that close one statement and start another.
Attack Vector
Exploitation requires the victim to invoke the generator classes directly against an attacker-supplied Avro schema. Typical paths include schema registry pipelines, developer tooling that regenerates models from external schemas, and automated code-generation jobs in CI/CD. The attack is network-reachable where schemas traverse untrusted channels and requires user interaction in the form of running the generator and importing the output.
# Security patch excerpt from dataclasses_avroschema/exceptions.py
# A new exception is raised when a schema value would be rendered as code
# rather than inside a string literal, blocking injection at generation time.
class InvalidSchemaValue(Exception):
"""
A value taken from the schema cannot be rendered into the generated source.
It is raised for the values that end up in code rather than in a string literal --
a name, a namespace, an annotation -- where escaping does not apply and the only
safe answer is to refuse the schema.
"""
def __init__(self, value: typing.Any, location: str, expected: str) -> None:
self.value = value
self.location = location
self.expected = expected
def __str__(self) -> str:
return (
f"Invalid {self.location} {self.value!r}. It is rendered into the generated source as code, "
f"so it must be {self.expected}"
)
Source: GitHub Commit 429f3d7
Detection Methods for CVE-2026-108385
Indicators of Compromise
- Generated Python modules containing unexpected statements, assignments, or imports inside enum class bodies.
- ImportError or SyntaxError exceptions raised when loading auto-generated model modules.
- Avro enum symbols arrays containing newline characters, =, parentheses, or non-identifier punctuation.
Detection Strategies
- Scan code-generation output directories for enum classes whose members do not match the [A-Za-z_][A-Za-z0-9_]* identifier pattern.
- Inspect schema registries and inbound Avro definitions for enum symbols that fail Python str.isidentifier() validation.
- Compare generated artifacts against expected schema-to-code mappings in CI to flag drift introduced by malicious symbols.
Monitoring Recommendations
- Log and alert on dataclasses-avroschema generator invocations that consume externally sourced schemas.
- Monitor import-time exceptions in services that dynamically load generated models.
- Track dataclasses-avroschema package versions across build systems to confirm every pipeline runs 0.70.6 or later.
How to Mitigate CVE-2026-108385
Immediate Actions Required
- Upgrade dataclasses-avroschema to version 0.70.6 or later across all development, CI, and runtime environments.
- Audit CI/CD pipelines and developer tooling for code generation runs against schemas sourced outside the trust boundary.
- Regenerate and review any Python modules previously produced from untrusted Avro schemas.
Patch Information
Version 0.70.6 fixes the issue by validating every enum symbol as a Python identifier before rendering. The patch introduces the InvalidSchemaValue exception and a validate_type_expression helper that reject schema values destined to be emitted as code. See the GitHub Security Advisory GHSA-gw6w-pvv9-2fqc and the v0.70.6 release notes.
Workarounds
- Pre-validate every Avro enum symbol with str.isidentifier() and reject schemas containing non-identifier values before invoking the generator.
- Restrict schema sources to trusted internal registries with authenticated publishers until the upgrade is deployed.
- Isolate code-generation jobs in sandboxed environments and review generated modules before import in production services.
# Pin the fixed version in requirements management
pip install 'dataclasses-avroschema>=0.70.6'
# Verify the installed version
python -c "import dataclasses_avroschema, sys; \
sys.exit(0 if dataclasses_avroschema.__version__ >= '0.70.6' else 1)"
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

