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-108382 Overview
CVE-2026-108382 is a code injection vulnerability [CWE-94] in the dataclasses-avroschema Python library. The library generates Avro schemas from Python dataclasses, Pydantic models, and Faust Records, and generates Python source code from Avro schemas. Versions 0.38.0 through 0.70.5 are affected. The flaw resides in EnumRepresentation.render_symbols, which embeds schema-controlled enum symbols between double quotes when emitting generated enum assignments. An attacker-controlled symbol containing a quote character can terminate the string literal and inject arbitrary Python code into the generated module. The injected code executes when a victim imports the generated module.
Critical Impact
An attacker who controls an Avro schema can achieve arbitrary Python code execution on any host that imports the generated module, leading to full application compromise.
Affected Products
- dataclasses-avroschema versions 0.38.0 through 0.70.5
- Python applications that invoke the generator classes directly on untrusted schemas
- Downstream services that import modules produced by vulnerable generator versions
Discovery Timeline
- 2026-10-13 - CVE-2026-108382 published to the National Vulnerability Database
- 2026-10-13 - Last updated in NVD database
Technical Details for CVE-2026-108382
Vulnerability Analysis
The dataclasses-avroschema library converts Avro schemas into Python source code and writes the output to a module file. During rendering, EnumRepresentation.render_symbols concatenates each enum symbol between literal double quote characters to produce a Python assignment such as symbols = ["VALUE_A", "VALUE_B"]. The rendering path does not escape or validate the symbol contents. An attacker who supplies a symbol containing a double quote can close the string literal and append arbitrary Python statements that become part of the generated enum class body. Those statements execute at import time, before any application logic inspects the generated module, giving the attacker arbitrary code execution in the context of the importing process.
Root Cause
The root cause is unsafe string concatenation of untrusted input into generated source code. The generator treats schema-provided symbols as safe literals rather than data that must be escaped. Patch commit 429f3d7 introduces an InvalidSchemaValue exception and validation helpers so that values rendered as code are rejected, while string-literal values are properly escaped before emission.
Attack Vector
Exploitation requires an attacker to supply a crafted Avro schema that is processed by a vulnerable generator and then imported. Any workflow that accepts third-party schemas, such as schema registries, data pipeline ingestion, or developer tooling that regenerates models from external definitions, is a viable path. User interaction is required because a victim or automated process must import the generated module.
# Security patch excerpt from dataclasses_avroschema/exceptions.py
# Source: https://github.com/marcosschroh/dataclasses-avroschema/commit/429f3d705d2d04c0c65e2ef832daed5ff91318fc
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, location, expected):
self.value = value
self.location = location
self.expected = expected
def __str__(self):
return (
f"Invalid {self.location} {self.value!r}. It is rendered into the generated source as code, "
f"so it must be {self.expected}"
)
The patch adds the InvalidSchemaValue class to reject schema values that would otherwise be rendered directly as Python code, and introduces a validate_type_expression helper imported into the generator modules.
Stop Remote Code Execution Before It Runs
Singularity™ Endpoint detects and blocks exploit attempts at machine speed, including zero-days and novel attack techniques.
Stop Exploit AttemptsDetection Methods for CVE-2026-108382
Indicators of Compromise
- Generated Python modules that contain unexpected statements inside enum class bodies or after symbols assignments.
- Avro schemas containing enum symbol values with embedded double quote ("), backslash, or newline characters.
- Unexplained outbound network connections, file writes, or subprocess activity originating from Python processes that import generated schema modules.
- Pinned dataclasses-avroschema versions between 0.38.0 and 0.70.5 in requirements.txt, pyproject.toml, or Pipfile.lock.
Detection Strategies
- Scan source control and build artifacts for generated modules and diff them against expected output to detect injected code.
- Add static analysis rules that flag non-identifier characters in Avro enum symbols fields prior to code generation.
- Review software composition analysis (SCA) reports to identify services depending on the vulnerable version range.
Monitoring Recommendations
- Log and alert on Avro schema ingestion events where enum symbols contain quote or escape characters.
- Monitor Python application processes for unexpected child processes or network activity shortly after schema regeneration tasks.
- Track changes to generated model directories in CI pipelines and require review for diffs that modify enum definitions.
How to Mitigate CVE-2026-108382
Immediate Actions Required
- Upgrade dataclasses-avroschema to version 0.70.6 or later across all services and build environments.
- Audit any Avro schemas received from external sources since adoption of a vulnerable version and regenerate the corresponding modules on the patched release.
- Review and remove any generated modules that cannot be reproduced deterministically from a known-good schema.
Patch Information
Version 0.70.6 fixes the vulnerability by escaping enum symbol values before rendering and by adding the InvalidSchemaValue exception for values that would otherwise be emitted directly as Python code. See the GitHub Security Advisory GHSA-vrq9-94ww-jv3c, the patch commit 429f3d7, and the 0.70.6 release notes.
Workarounds
- Restrict schema generation to trusted, internally authored Avro schemas until the upgrade is complete.
- Validate enum symbols against a strict allowlist of identifier characters ([A-Za-z_][A-Za-z0-9_]*) before passing schemas to the generator.
- Run model generation and import steps in isolated, non-privileged environments to limit blast radius if injection occurs.
# Upgrade to the patched release
pip install --upgrade "dataclasses-avroschema>=0.70.6"
# Verify the installed version
python -c "import dataclasses_avroschema; print(dataclasses_avroschema.__version__)"
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

