Skip to main content
Vulnerability Database/CVE-2026-108377

CVE-2026-108377: dataclasses-avroschema RCE Vulnerability

CVE-2026-108377 is a remote code execution flaw in dataclasses-avroschema that allows attackers to inject malicious code through crafted Avro record names. This post explains its impact, affected versions, and mitigation steps.

Published:

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-108377 Overview

CVE-2026-108377 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. Versions 0.62.3 through 0.70.5 are affected. The ClassRepresentation.render_metaclass function inserts a schema-controlled Avro record name into the quoted Meta.schema_name field of generated Python source without escaping it. A crafted name can terminate the string literal and inject arbitrary Python statements into the generated class body. Those statements execute when the generated module is imported. Version 0.70.6 resolves the issue by escaping schema values rendered into generated string literals.

Critical Impact

An attacker who controls an Avro schema processed by a vulnerable version can achieve arbitrary Python code execution when the generated module is imported, leading to full compromise of the host process.

Affected Products

  • dataclasses-avroschema version 0.62.3
  • dataclasses-avroschema versions up to and including 0.70.5
  • Python applications that import code generated by vulnerable versions from untrusted Avro schemas

Discovery Timeline

  • 2026-10-13 - CVE-2026-108377 published to NVD
  • 2026-10-13 - Last updated in NVD database

Technical Details for CVE-2026-108377

Vulnerability Analysis

The flaw resides in the Python model generator component of dataclasses-avroschema. When the library converts an Avro schema into Python source code, ClassRepresentation.render_metaclass emits a Meta inner class on the generated model. The Meta.schema_name attribute is written as a quoted Python string literal containing the Avro record name taken directly from the schema. The renderer does not escape quote characters, backslashes, or newlines in that value. An attacker-controlled name containing a closing quote and a semicolon can break out of the string literal and append arbitrary Python statements inside the class body. The injected statements become part of the generated module and run during import, giving the attacker code execution with the privileges of the importing process.

Root Cause

The root cause is unsafe string interpolation of untrusted input into generated source code. The generator treated the Avro name as plain text and concatenated it into a template without applying Python literal escaping. The upstream fix in commit 919d3e07c8938369cfc2c0569007ba373247e74a routes schema_name through the metaclass_field_template and introduces a dedicated InvalidSchemaValue exception (commit 429f3d705d2d04c0c65e2ef832daed5ff91318fc) for values that must appear as code rather than as string literals.

Attack Vector

Exploitation requires an attacker to supply or influence an Avro schema that is consumed by code generation and then imported. Typical scenarios include schema registries, user-uploaded schemas in data pipelines, and automation that regenerates models from third-party schema sources. User interaction is required because the generated module must be imported for the injected code to execute.

python
# Patch: new exception for values rendered as code (not strings)
# 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, 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

python
# Patch: route schema_name through the metaclass field template
# dataclasses_avroschema/model_generator/lang/python/base.py
"aliases": templates.metaclass_alias_field_template,
"original_schema": templates.metaclass_schema_field_template,
"default": templates.metaclass_field_template,
"schema_name": templates.metaclass_field_template,

Source: GitHub commit 919d3e0

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 Attempts

Detection Methods for CVE-2026-108377

Indicators of Compromise

  • Generated Python modules whose Meta class contains statements other than simple attribute assignments, such as import, os.system, or exec calls.
  • Avro record name or namespace values containing quote characters, backslashes, newlines, or Python keywords.
  • Unexpected outbound network connections or child processes initiated by services that import freshly generated Avro model modules.

Detection Strategies

  • Inventory Python environments for dataclasses-avroschema versions in the 0.62.3 through 0.70.5 range using pip list or software composition analysis.
  • Statically scan generated model files for syntactic anomalies in Meta blocks and for schema_name values that break the single-line string literal pattern.
  • Validate incoming Avro schemas against a strict allowlist for name and namespace (for example, ^[A-Za-z_][A-Za-z0-9_]*$) before passing them to the generator.

Monitoring Recommendations

  • Log and alert on code generation jobs that process schemas from untrusted sources, including schema registry pulls and user uploads.
  • Monitor CI/CD runners and application hosts for process executions originating from Python import operations of generated modules.
  • Track outbound connections from services that recently regenerated Avro models to catch post-exploitation command-and-control activity.

How to Mitigate CVE-2026-108377

Immediate Actions Required

  • Upgrade dataclasses-avroschema to version 0.70.6 or later across all applications, build systems, and container images.
  • Regenerate all Python models produced by vulnerable versions and review the resulting source for injected statements before redeployment.
  • Treat any Avro schema from an external or multi-tenant source as untrusted and validate name and namespace fields against a strict identifier allowlist.

Patch Information

The fix is available in dataclasses-avroschema version 0.70.6. See the GitHub release 0.70.6 and the GHSA-57hr-pcm8-p9j9 security advisory for details. Relevant commits are 429f3d7 and 919d3e0.

Workarounds

  • Pin the library to version 0.70.6 or later in requirements.txt or pyproject.toml to prevent reintroduction of vulnerable versions.
  • Reject Avro schemas whose name or namespace contain characters outside [A-Za-z0-9_] before invoking code generation.
  • Isolate code generation and the first import of generated modules in a sandboxed, non-privileged environment with no outbound network access.
bash
# Upgrade to the patched release
pip install --upgrade '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)"

# Pin in requirements.txt
echo 'dataclasses-avroschema>=0.70.6' >> requirements.txt

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

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.