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

CVE-2026-108383: dataclasses-avroschema Code Injection

CVE-2026-108383 is a code injection flaw in dataclasses-avroschema that allows attackers to inject statements into generated modules through malicious enum defaults. 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-108383 Overview

CVE-2026-108383 is a code injection vulnerability [CWE-94] in dataclasses-avroschema, a Python library that generates Avro schemas from dataclasses, Pydantic models, and Faust Records. Versions 0.38.0 through 0.70.5 are affected. The flaw resides in FieldRepresentation.get_field_default, which renders a schema-controlled enum field default as an enum member reference after case conversion but without validating the result as a Python identifier. Attackers controlling schema input can inject newlines, operators, and punctuation to break out of the intended reference and execute constrained statements in the generated module. Version 0.70.6 remediates the issue by validating enum defaults as names.

Critical Impact

An attacker who supplies a crafted Avro schema can inject Python statements into generated code, modify module namespaces, or prevent generated modules from loading.

Affected Products

  • dataclasses-avroschema versions 0.38.0 through 0.70.5
  • Python applications consuming untrusted Avro schemas via this library
  • Pipelines that auto-generate Python models from third-party schemas

Discovery Timeline

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

Technical Details for CVE-2026-108383

Vulnerability Analysis

The dataclasses-avroschema library converts Avro schema definitions into Python source code. When a field uses an enum type with a default value, the generator emits a reference such as MyEnum.MEMBER into the output module. The FieldRepresentation.get_field_default method constructs that reference by applying case conversion to the schema-provided symbol, then writing it directly into the generated source.

Because the generator trusts the post-conversion string to be a valid Python identifier, any character permitted by case conversion survives into generated code. Newlines, operators, and punctuation inside the enum default escape the intended member reference. The resulting statements execute when the generated module is imported, producing namespace tampering, import-time errors, or arbitrary module-level side effects within the constraints of Python statement syntax.

Root Cause

The root cause is missing input validation on schema-sourced identifiers before source-code emission. The library treats schema strings as safe tokens for code generation rather than as untrusted data requiring strict identifier validation. The patch introduces an InvalidSchemaValue exception and a validate_type_expression helper to reject non-identifier values at generation time.

Attack Vector

Exploitation requires an attacker to deliver a malicious Avro schema to a system that generates Python models with dataclasses-avroschema. User interaction is required to run the code generator or import the generated module. Once the generated module loads, injected statements run in that module's namespace with the privileges of the consuming process.

python
# Security patch excerpt from 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: 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}"
        )

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 Attempts

Detection Methods for CVE-2026-108383

Indicators of Compromise

  • Generated Python modules containing unexpected statements, imports, or assignments outside documented enum references
  • SyntaxError or NameError exceptions raised when importing modules produced by dataclasses-avroschema
  • Avro schema files with enum default values containing newlines, punctuation, or non-identifier characters

Detection Strategies

  • Scan code-generation inputs for Avro schemas where enum default fields fail Python identifier validation (str.isidentifier()).
  • Diff generated model files against expected templates to flag unexpected top-level statements.
  • Pin and audit the dataclasses-avroschema version in dependency manifests to confirm versions below 0.70.6 are not in use.

Monitoring Recommendations

  • Monitor CI/CD pipelines that invoke dataclasses-avroschema for abnormal file writes or runtime errors during model generation.
  • Alert on imports of auto-generated modules producing unexpected side effects, process spawns, or network calls.
  • Track schema registry changes and require review for enum symbol and default modifications.

How to Mitigate CVE-2026-108383

Immediate Actions Required

  • Upgrade dataclasses-avroschema to version 0.70.6 or later across all environments.
  • Regenerate any Python models produced from untrusted schemas using the patched version and review existing generated files for injected content.
  • Restrict schema inputs to trusted sources until the upgrade is complete.

Patch Information

The fix is available in dataclasses-avroschemarelease 0.70.6. The patch adds an InvalidSchemaValue exception and introduces validate_type_expression to reject schema values that cannot safely be rendered as Python code. See the GitHub Security Advisory GHSA-4xxf-mv22-hcr8 and the patch commit for implementation details.

Workarounds

  • Validate every Avro schema before generation and reject any enum default whose value is not a valid Python identifier.
  • Run model generation in an isolated environment with no network access and least-privilege filesystem permissions.
  • Review generated modules in code review before importing them into production services.
bash
# Upgrade to the patched version
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

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.