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

CVE-2026-108381: dataclasses-avroschema RCE Vulnerability

CVE-2026-108381 is a remote code execution vulnerability in dataclasses-avroschema that allows attackers to execute arbitrary Python code through crafted schema fields. This article covers technical details, affected versions, and mitigation.

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

CVE-2026-108381 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.44.0 through 0.70.5. The Pydantic and AvroDantic model generators insert a schema field's pydantic-class value into a generated field annotation without restricting the expression. Because Python evaluates annotations when the generated module is imported, a crafted schema value can execute arbitrary Python code on the host running the generator or importing the generated module.

Critical Impact

An attacker who controls an Avro schema processed by the generator can achieve arbitrary Python code execution with the privileges of the generating or importing process.

Affected Products

  • dataclasses-avroschema versions 0.44.0 through 0.70.5
  • Pydantic model generator component
  • AvroDantic model generator component

Discovery Timeline

  • 2026-10-13 - CVE CVE-2026-108381 published to NVD
  • 2026-10-13 - Last updated in NVD database
  • Version 0.70.6 - Maintainer marcosschroh releases patched release

Technical Details for CVE-2026-108381

Vulnerability Analysis

The vulnerability resides in the Pydantic and AvroDantic code generators that convert Avro schemas into Python source modules. When a schema field declares a pydantic-class value, the generator emits a field annotation of the form pydantic.<value> directly into the produced Python module. The value is interpolated as code rather than as a string literal, with no validation that it represents a bare identifier.

Python evaluates class-level annotations at import time. Consequently, any expression placed in the annotation runs when the generated module loads, which hands execution control to whoever supplied the schema. The attack surface covers both the system running the generator and any downstream system that imports the resulting module.

Root Cause

The root cause is unsafe code template interpolation. The generator trusted the pydantic-class schema field as a type name and concatenated it into source code without parsing or restricting the syntax. Any attacker-supplied string, including function calls, attribute chains, or arbitrary statements, became part of the module. The fix in version 0.70.6 introduces a validate_type_expression routine and an InvalidSchemaValue exception that reject values which are not a bare name or a bare-name call with literal arguments.

Attack Vector

An attacker supplies a malicious Avro schema to a workflow that invokes the Pydantic or AvroDantic model generator. Exploitation requires user interaction, typically a developer or automation pipeline that generates and imports the resulting module. On import, the injected expression executes with the privileges of the Python process, enabling data theft, lateral movement, or supply-chain compromise of downstream artifacts.

python
# Security patch excerpt from dataclasses_avroschema/exceptions.py
# The fix adds a dedicated exception for unsafe schema values
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-108381

Indicators of Compromise

  • Avro schemas containing pydantic-class values that are not bare Python identifiers, for example values containing parentheses with non-literal arguments, dots, equals signs, or __import__.
  • Generated Python modules under source control whose field annotations include unexpected function calls after pydantic..
  • Python processes spawning unexpected child processes or outbound network connections immediately after importing a generated model module.

Detection Strategies

  • Inventory all repositories, CI pipelines, and services that consume dataclasses-avroschema between versions 0.44.0 and 0.70.5, using software composition analysis tools.
  • Statically scan Avro schemas for pydantic-class fields and verify each value matches the regex for a bare Python identifier before processing.
  • Review commit history of auto-generated model files for annotation lines that deviate from the pydantic.<Identifier> pattern.

Monitoring Recommendations

  • Monitor Python interpreter processes in build and runtime environments for anomalous child-process creation, DNS lookups, and filesystem writes correlated with model-generation jobs.
  • Alert on code-review events that modify generated Avro model modules outside of the automated regeneration workflow.
  • Capture and retain Avro schema inputs to CI pipelines so suspicious schemas can be reviewed after an incident.

How to Mitigate CVE-2026-108381

Immediate Actions Required

  • Upgrade dataclasses-avroschema to version 0.70.6 or later across all development, CI, and production environments.
  • Audit any Python modules previously generated by vulnerable versions and regenerate them from trusted schemas after upgrading.
  • Restrict who can submit or modify Avro schemas consumed by the generator, and treat schema inputs as untrusted code.

Patch Information

The maintainer released version 0.70.6 with the fix. The patch adds validate_type_expression and raises InvalidSchemaValue when a schema value is not a bare name or a bare-name call with literal arguments. Full details are available in the GitHub Security Advisory GHSA-4jmx-9m83-vxx8, the GitHub Release 0.70.6, and the GitHub Pull Request Discussion.

Workarounds

  • Pre-validate every Avro schema before invoking the generator, rejecting any pydantic-class value that is not a bare Python identifier.
  • Run model generation inside an isolated, least-privilege sandbox with no network access to limit blast radius if a crafted schema is processed.
  • Avoid importing generated model modules in sensitive processes until their source has been reviewed against the expected pydantic.<Identifier> annotation pattern.
bash
# 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

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.