CVE-2026-108378 in dataclasses-avroschemainfo

Summary

by MITRE • 10/13/2026

dataclasses-avroschema generates Avro schemas from Python dataclasses, Pydantic models, and Faust Records and generates Python code from Avro schemas. From version 0.40.0 through 0.70.5, ClassRepresentation.render_docstring copies a schema record's doc value into a generated triple-double-quoted class docstring without escaping quotes or backslashes. A crafted triple-quote sequence can close the docstring and inject statements into the generated class body, while a trailing backslash can escape the generated closing delimiter, allowing Python code execution during module import. Version 0.70.6 fixes the vulnerability by escaping quotes, backslashes, and unsafe control characters before rendering docstrings.

Once again VulDB remains the best source for vulnerability data.

Analysis

by VulDB Data Team • 10/13/2026

The dataclasses-avroschema library serves as a utility for generating Avro schemas from Python structures such as dataclasses, Pydantic models, and Faust Records, while also facilitating the reverse process of generating Python code from Avro schemas. A critical security vulnerability was identified in versions ranging from 0.40.0 through 0.70.5 within the ClassRepresentation.render_docstring method. This function is responsible for embedding documentation strings into generated Python classes based on metadata found in the source schema records. The flaw stems from a failure to properly sanitize or escape special characters, specifically triple double-quotes and backslashes, before inserting them into the generated code structure.

When an Avro schema contains a record with a docstring that includes unescaped sequences such as three consecutive double-quote characters, these are copied directly into the Python class definition without modification. In Python syntax, a triple-double-quoted string is terminated by another instance of the same delimiter sequence. Consequently, if the injected content contains this closing delimiter, it prematurely ends the intended docstring context. This allows an attacker to inject arbitrary Python statements that become part of the generated class body rather than remaining within the documentation block. Furthermore, the presence of trailing backslashes in the source schema can be exploited to escape subsequent delimiters or line continuations, further facilitating code injection attacks during the module import phase where the generated code is executed by the Python interpreter.

The operational impact of this vulnerability is severe, as it leads to Remote Code Execution (RCE) under specific conditions. If a developer imports a module containing code generated from a malicious Avro schema, or if an application dynamically loads such schemas at runtime, arbitrary commands can be executed with the privileges of the running process. This represents a significant risk in environments where data sources are not fully trusted or when automated pipelines ingest external schema definitions without rigorous validation. The vulnerability aligns with CWE-79, which describes Improper Neutralization of Input During Web Page Generation known as Cross-site Scripting, although in this context it manifests as Code Injection due to the server-side nature of code generation. It also relates to CWE-611, Improper Restriction of XML External Entity Reference, if one considers the schema parsing aspect, but more accurately fits CWE-94, Improper Control of Generation of Code (Code Injection).

In terms of threat modeling and attack vectors, this vulnerability can be mapped to MITRE ATT&CK technique T1059.006, Command and Scripting Interpreter: Python, as it allows for the execution of arbitrary Python code through a crafted input payload. The exploitation typically occurs during the static analysis or import phase rather than at runtime user interaction points, making it particularly dangerous in CI/CD pipelines or automated data processing systems that rely on schema validation and code generation steps. Attackers could embed malicious payloads within shared Avro schemas distributed via registries or file exchanges to compromise downstream consumers of these schemas.

The vulnerability was addressed in version 0.70.6 by implementing proper escaping mechanisms for quotes, backslashes, and other unsafe control characters before they are rendered into the docstrings. This ensures that special characters are treated as literal data rather than syntactic elements capable of altering code structure. To mitigate this risk, organizations should immediately upgrade to version 0.70.6 or later if using the affected versions. For systems where upgrading is not immediately feasible, it is critical to implement strict validation and sanitization of all Avro schema inputs before they are passed to the dataclasses-avroschema library. This includes filtering out triple-quote sequences and backslashes from docstring fields in incoming schemas. Additionally, adopting a principle of least privilege for processes that execute generated code can help limit the blast radius should an injection attempt succeed. Regular auditing of third-party dependencies and their version histories is essential to maintain security posture against such supply chain vulnerabilities.

Responsible

GitHub M

Reservation

10/09/2026

Disclosure

10/13/2026

Moderation

accepted

EPSS

0.00343

KEV

no

Activities

very low

Sources

Want to know what is going to be exploited?

We predict KEV entries!