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-108378 Overview
CVE-2026-108378 is a code injection vulnerability [CWE-94] in dataclasses-avroschema, a Python library that generates Avro schemas from dataclasses, Pydantic models, and Faust Records, and generates Python code from Avro schemas. The flaw affects versions 0.40.0 through 0.70.5. The ClassRepresentation.render_docstring function copies a schema record's doc value into a generated triple-double-quoted class docstring without escaping quotes or backslashes. An attacker who can supply a crafted Avro schema can break out of the docstring and inject arbitrary Python statements into the generated module. Version 0.70.6 resolves the issue by escaping quotes, backslashes, and unsafe control characters.
Critical Impact
A crafted Avro schema can trigger arbitrary Python code execution during module import of the generated class.
Affected Products
- dataclasses-avroschema version 0.40.0
- dataclasses-avroschema versions through 0.70.5
- Python applications importing modules generated from untrusted Avro schemas
Discovery Timeline
- 2026-10-13 - CVE-2026-108378 published to NVD
- 2026-10-14 - Last updated in NVD database
Technical Details for CVE-2026-108378
Vulnerability Analysis
The vulnerability resides in the model generator component of dataclasses-avroschema. When the library converts an Avro schema into Python source code, it reads the schema record's doc field and places the value inside a triple-double-quoted ("""...""") docstring in the generated class. The rendering routine performs no sanitization. A doc value containing a """ sequence prematurely closes the docstring, allowing subsequent characters to be interpreted as Python statements inside the class body. A trailing backslash can also escape the generated closing delimiter and shift the injection point. Because the injected code runs during module import, exploitation is immediate the first time the generated module is loaded. The impact includes arbitrary code execution in the context of the Python process consuming the generated code.
Root Cause
The root cause is unsafe string interpolation of attacker-controlled schema metadata into generated source code. The render_docstring method emits the doc field verbatim between triple-double-quote delimiters without escaping ", \, or control characters. This violates the trust boundary between schema data and generated code.
Attack Vector
Exploitation requires that a victim run the model generator against a schema supplied by the attacker, then import the generated module. User interaction is required to trigger the generation and import workflow. Any pipeline that accepts Avro schemas from external systems — schema registries, uploaded files, or third-party feeds — can be abused to deliver a malicious doc payload.
# Patch excerpt: new exception class introduced to refuse
# schema values that would be rendered directly as code.
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}"
)
Source: GitHub Commit 429f3d7
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-108378
Indicators of Compromise
- Avro schema doc fields containing """, trailing backslashes, or embedded newlines followed by Python keywords such as import, exec, or __import__.
- Generated Python modules whose class docstrings terminate unexpectedly and contain executable statements inside the class body.
- Unexpected outbound network connections or child processes spawned during import of generated model modules.
Detection Strategies
- Scan Avro schemas before code generation for suspicious characters in doc, name, and namespace fields.
- Diff generated Python files against a known-good baseline to detect injected statements near docstring boundaries.
- Monitor Python processes for anomalous behavior immediately following imports of generated schema modules.
Monitoring Recommendations
- Log all invocations of the dataclasses-avroschema model generator with the source and hash of the input schema.
- Alert on process execution, file writes, or network activity initiated by Python interpreters loading auto-generated model packages.
- Track the installed version of dataclasses-avroschema across build systems and developer workstations to ensure patched versions are in use.
How to Mitigate CVE-2026-108378
Immediate Actions Required
- Upgrade dataclasses-avroschema to version 0.70.6 or later across all environments that run the model generator.
- Audit any Python modules previously generated from untrusted schemas and regenerate them with the patched version.
- Treat Avro schemas received from external parties or shared registries as untrusted input until validated.
Patch Information
The fix is delivered in GitHub Release 0.70.6. Commit 429f3d7 escapes quotes, backslashes, and unsafe control characters in docstring rendering and introduces an InvalidSchemaValue exception for values that would otherwise be emitted as code. Full details are documented in GitHub Security Advisory GHSA-ff3j-hw44-6vx4.
Workarounds
- Restrict the model generator to schemas from trusted internal sources only.
- Pre-validate every schema's doc, name, and namespace fields to reject """, trailing \, and non-printable characters.
- Review and sanitize generated Python code before importing it into application runtimes.
# Upgrade to the patched release
pip install --upgrade "dataclasses-avroschema>=0.70.6"
# Verify the installed version
python -c "import dataclasses_avroschema, sys; 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

