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-108376 Overview
CVE-2026-108376 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 exists in FieldRepresentation.get_field_default, which inserts a schema-controlled referenced record name into the callable position of a generated default_factory lambda without validating it against the Avro name grammar. A crafted record name becomes an arbitrary Python expression that executes when an instance of the generated model consumes the field default. Versions 0.47.3 through 0.70.5 are affected, and version 0.70.6 resolves the issue.
Critical Impact
An attacker who controls an Avro schema processed by code generation can achieve arbitrary Python code execution in the context of any process that instantiates the generated model.
Affected Products
- dataclasses-avroschema versions 0.47.3 through 0.70.5
- Python applications generating models from untrusted Avro schemas
- Downstream services consuming schema-registry content via this library
Discovery Timeline
- 2026-10-13 - CVE CVE-2026-108376 published to NVD
- 2026-10-13 - Last updated in NVD database
Technical Details for CVE-2026-108376
Vulnerability Analysis
The dataclasses-avroschema library converts Avro schemas into Python source code for dataclass or Pydantic models. During code generation, FieldRepresentation.get_field_default constructs a default_factory lambda that references another record by name. The referenced record name is taken directly from the input schema and emitted into Python source as an identifier.
Because the generator does not verify that the name conforms to the Avro name grammar, any string, including Python expressions with parentheses, operators, or function calls, is rendered verbatim into the callable position of the lambda. When the generated module is imported and a model instance evaluates the default, Python executes the attacker-supplied expression.
This is a classic code injection pattern [CWE-94]: untrusted data is treated as code rather than as a data literal. Escaping does not apply because the value is intended to appear as a Python identifier, not inside a string. The only safe response is to reject non-conforming names, which is what the patch does.
Root Cause
The root cause is missing input validation on a schema-controlled value that is written into generated source code. The library trusted that referenced record names were well-formed Avro names and used them unmodified in positions that must be valid Python identifiers.
Attack Vector
Exploitation requires an attacker to supply or influence an Avro schema that the victim processes with the vulnerable library. In pipelines that pull schemas from a shared schema registry, a message broker, or user-submitted uploads, this is reachable over the network. Code execution occurs when the generated model is loaded and the vulnerable field default is first evaluated.
# Security patch adding InvalidSchemaValue exception
# 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: 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}"
)
The fix also introduces a validate_type_expression helper used by the Pydantic model generator to reject non-conforming names before emission.
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-108376
Indicators of Compromise
- Avro schemas containing record names with characters outside [A-Za-z_][A-Za-z0-9_]*, especially parentheses, dots, or whitespace
- Generated Python modules whose default_factory=lambda: ... lines contain unexpected function calls or imports
- Unexpected outbound connections or child processes from services that recently loaded generated model code
Detection Strategies
- Scan generated model files for default_factory lambdas whose callable position is not a bare class identifier
- Audit schema registry contents for record names that fail an Avro name grammar check (^[A-Za-z_][A-Za-z0-9_]*$)
- Inspect dependency manifests (requirements.txt, poetry.lock, uv.lock) for dataclasses-avroschema versions between 0.47.3 and 0.70.5
Monitoring Recommendations
- Alert on process-execution telemetry when Python interpreters running model-generation workflows spawn shells or network utilities
- Log and review all schema ingestion events, correlating source identity with schema content
- Enable file integrity monitoring on directories that store generated Python modules
How to Mitigate CVE-2026-108376
Immediate Actions Required
- Upgrade dataclasses-avroschema to version 0.70.6 or later in all environments
- Inventory existing generated model files and regenerate them from trusted schemas after upgrade
- Review schema registry access controls to limit who can publish or modify schemas
Patch Information
The maintainer released the fix in version 0.70.6, which rejects record names that do not match the Avro name grammar. See the GitHub Release 0.70.6, the commit 429f3d7, and the GHSA-jcjg-gjg5-xp7v advisory for technical details.
Workarounds
- Validate all incoming Avro schemas against the Avro name grammar before passing them to the generator
- Treat schema generation as a privileged offline process rather than runtime behavior triggered by untrusted input
- Execute generated-model loading in a sandboxed worker with restricted filesystem and network egress
# Upgrade to the patched release
pip install --upgrade 'dataclasses-avroschema>=0.70.6'
# Verify 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

