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-108380 Overview
CVE-2026-108380 is a code injection vulnerability [CWE-94] in dataclasses-avroschema, a Python library that generates Avro schemas from Python dataclasses, Pydantic models, and Faust Records. The flaw affects versions 0.65.9 through 0.70.5. The PydanticFieldRepresentation.add_field_properties method inserts a schema field's doc value into the generated pydantic.Field description argument without escaping embedded quote characters. An attacker who controls the doc field of an Avro schema processed by the generator can break out of the string literal and inject arbitrary Python expressions. Those expressions execute when the generated class is defined, enabling arbitrary code execution during Pydantic and AvroDantic model generation.
Critical Impact
A crafted Avro schema loaded by a vulnerable code generator results in arbitrary Python code execution in the context of the process running the generator.
Affected Products
- dataclasses-avroschema versions 0.65.9 through 0.70.5
- Pydantic model generator (PydanticFieldRepresentation.add_field_properties)
- AvroDantic model generator (shares the vulnerable field representation code)
Discovery Timeline
- 2026-10-13 - CVE-2026-108380 published to the National Vulnerability Database (NVD)
- 2026-10-13 - Last updated in NVD database
- Fixed version - 0.70.6 released with escaping applied to the documentation value
Technical Details for CVE-2026-108380
Vulnerability Analysis
The library converts Avro schemas into Python source code that defines Pydantic or AvroDantic model classes. For each field, PydanticFieldRepresentation.add_field_properties renders the schema's doc string directly between double quotes in the generated pydantic.Field(description="...") call. The generator does not escape quote characters or backslashes before concatenation. A doc value containing a " terminates the string literal early, and anything that follows is emitted as live Python code rather than data.
Because the output is written to a module and then imported or exec'd to produce the model, injected expressions run at class-definition time. This grants the attacker the same privileges as the process generating code from the schema, often an application server, build pipeline, or developer workstation.
Root Cause
The root cause is unsafe string interpolation of untrusted schema metadata into generated source code. The vulnerable path handles the doc attribute as plain text when it is actually used as code context. The patch introduces an InvalidSchemaValue exception and a validate_type_expression helper, and escapes the documentation value before rendering it, closing the injection path.
Attack Vector
Exploitation requires a victim to run the model generator against an attacker-controlled Avro schema. This is common in build toolchains, schema registries, and services that regenerate models from externally supplied schemas. User interaction is required (UI:R), typically triggering code generation on the malicious schema, but no authentication or special privileges are needed.
# Patch excerpt: new exception type added to dataclasses_avroschema/exceptions.py
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: 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
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-108380
Indicators of Compromise
- Avro schema files containing doc values with embedded " characters followed by Python expressions such as +__import__('os').system(...).
- Generated Python model files whose pydantic.Field(description=...) arguments contain unbalanced quotes, function calls, or dunder references.
- Unexpected child processes spawned by build agents, schema-registry consumers, or code-generation jobs.
Detection Strategies
- Audit all call sites of PydanticFieldRepresentation.add_field_properties and model generator entry points for schemas sourced from untrusted inputs.
- Statically scan generated model modules for suspicious tokens inside description= arguments (for example __import__, os.system, backticks, or newlines).
- Compare installed dataclasses-avroschema versions across environments against the fixed version 0.70.6 using software composition analysis.
Monitoring Recommendations
- Alert on process execution of python or pip-invoked generators spawning shells, network tools, or package managers.
- Log and review schema-registry fetches performed by CI/CD runners that then execute code generation steps.
- Enable file integrity monitoring on directories that store generated model source to detect anomalous content.
How to Mitigate CVE-2026-108380
Immediate Actions Required
- Upgrade dataclasses-avroschema to version 0.70.6 or later in all applications, services, and CI/CD pipelines.
- Inventory every environment that imports the package and prioritize those that process externally provided Avro schemas.
- Revoke and rotate credentials accessible to any build agent or service that recently generated code from untrusted schemas.
Patch Information
Version 0.70.6 fixes the vulnerability by escaping the documentation value before rendering it into the generated pydantic.Field description and by introducing validate_type_expression for values rendered as code. See the GitHub Security Advisory GHSA-g7p7-mgvm-jw7p, the GitHub Pull Request #843, and the GitHub Release 0.70.6.
Workarounds
- Treat Avro schemas as untrusted input and strip or validate the doc field before passing schemas to the model generator.
- Run code generation in isolated, least-privileged sandboxes without network access or sensitive credentials.
- Pin dependency versions and block installation of affected ranges 0.65.9 through 0.70.5 via internal package policies.
# 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

