/

CVE-2026-108385

Severity:

HIGH RISK

(8.8)

Code Injection (CWE-94) in dataclasses-avroschema Enums

CVE-2026-108385

Deferred

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Generated-Code Injection and Module Integrity Loss

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

dataclasses-avroschema can place schema-controlled Avro enum symbols into generated Python enum member declarations without confirming that they are valid identifiers. When generator classes process crafted symbols, newline or punctuation characters may alter the generated class body, potentially enabling constrained code injection, namespace modification, or module-load failure.

dataclasses-avroschema can place schema-controlled Avro enum symbols into generated Python enum member declarations without confirming that they are valid identifiers. When generator classes process crafted symbols, newline or punctuation characters may alter the generated class body, potentially enabling constrained code injection, namespace modification, or module-load failure.

Affected context

The vulnerability occurs when dataclasses-avroschema generates Python code from Avro schemas and uses enum symbols as member names after case conversion. It is most relevant when applications invoke the generator classes directly and permit schemas or enum definitions to come from untrusted, externally modified, or insufficiently validated sources.

The vulnerability occurs when dataclasses-avroschema generates Python code from Avro schemas and uses enum symbols as member names after case conversion. It is most relevant when applications invoke the generator classes directly and permit schemas or enum definitions to come from untrusted, externally modified, or insufficiently validated sources.

Exploit preconditions

  • Attack surface: Python source-code generation for Avro enums
  • Required access: Ability to supply or influence an Avro schema containing enum symbols
  • Trigger point: Rendering an enum through the generator's parsing and symbol-rendering logic
  • Why exploitation is possible: Enum symbols are inserted into generated class syntax without sufficient identifier validation, allowing syntax-significant characters to affect the generated module
  • Attack surface: Python source-code generation for Avro enums
  • Required access: Ability to supply or influence an Avro schema containing enum symbols
  • Trigger point: Rendering an enum through the generator's parsing and symbol-rendering logic
  • Why exploitation is possible: Enum symbols are inserted into generated class syntax without sufficient identifier validation, allowing syntax-significant characters to affect the generated module

Why this happens

The underlying bug is improper neutralization of schema-controlled names during source-code generation. Enum symbols are transformed for naming but are not consistently checked against the target language's identifier rules before being emitted into a Python class body. This maps to CWE-94: Improper Control of Generation of Code, because data intended to represent an enum member can influence generated program structure.

The underlying bug is improper neutralization of schema-controlled names during source-code generation. Enum symbols are transformed for naming but are not consistently checked against the target language's identifier rules before being emitted into a Python class body. This maps to CWE-94: Improper Control of Generation of Code, because data intended to represent an enum member can influence generated program structure.

Potential impact

  • Generated modules may fail to load
  • An attacker-controlled schema could alter generated namespace contents
  • Code execution may be possible if injected statements are accepted and the generated module is subsequently executed
  • Build, deployment, or code-generation workflows could be disrupted
  • Downstream applications may consume tampered generated source
  • Generated modules may fail to load
  • An attacker-controlled schema could alter generated namespace contents
  • Code execution may be possible if injected statements are accepted and the generated module is subsequently executed
  • Build, deployment, or code-generation workflows could be disrupted
  • Downstream applications may consume tampered generated source

General mitigation guidance

Mitigation generally focuses on treating schema names as untrusted data during code generation.

Common defensive patterns include:

  • Validate every enum symbol against the target language's identifier grammar before rendering
  • Reject or safely transform invalid names using a deterministic, collision-resistant naming policy
  • Prefer structured code-generation APIs or templates that separate data from executable syntax
  • Apply strict schema validation before generation and restrict schemas to trusted sources
  • Avoid executing generated code in highly privileged environments
  • Run generation and subsequent imports with least privilege and appropriate filesystem isolation

Mitigation generally focuses on treating schema names as untrusted data during code generation.

Common defensive patterns include:

  • Validate every enum symbol against the target language's identifier grammar before rendering
  • Reject or safely transform invalid names using a deterministic, collision-resistant naming policy
  • Prefer structured code-generation APIs or templates that separate data from executable syntax
  • Apply strict schema validation before generation and restrict schemas to trusted sources
  • Avoid executing generated code in highly privileged environments
  • Run generation and subsequent imports with least privilege and appropriate filesystem isolation

How teams detect issues like this

Organizations can look for:

  • Static-analysis findings where schema-controlled strings are concatenated or interpolated into source code
  • Code-review signals involving enum-name conversion without identifier validation
  • Tests using punctuation, whitespace, newline, and reserved-word enum symbols
  • CI policies requiring generated identifiers to match an allowlisted language grammar
  • Runtime monitoring for unexpected generated files, import failures, or changes to generated module namespaces

Automated security review tools may help identify data-to-code generation paths, but generated output should also be tested directly.

Organizations can look for:

  • Static-analysis findings where schema-controlled strings are concatenated or interpolated into source code
  • Code-review signals involving enum-name conversion without identifier validation
  • Tests using punctuation, whitespace, newline, and reserved-word enum symbols
  • CI policies requiring generated identifiers to match an allowlisted language grammar
  • Runtime monitoring for unexpected generated files, import failures, or changes to generated module namespaces

Automated security review tools may help identify data-to-code generation paths, but generated output should also be tested directly.

Sources

SourceLink
github.comgithub.com/marcosschroh/dataclasses-avroschema/commit/429f3d705d2d04c0c65e2ef832daed5ff91318fc
github.comgithub.com/marcosschroh/dataclasses-avroschema/releases/tag/0.70.6
github.comgithub.com/marcosschroh/dataclasses-avroschema/security/advisories/GHSA-gw6w-pvv9-2fqc

Frequently asked

questions

It is generally not a direct network-service exploit. Exploitation depends on an attacker being able to influence an Avro schema that is processed by the vulnerable generator and on the resulting Python code being generated or executed.

The attacker needs control over, or the ability to modify, schema content consumed by the generator. The practical impact also depends on whether generated modules are imported automatically and what privileges the generation workflow has.

Validate every schema-controlled enum symbol as a legal target-language identifier before code generation, and reject or safely normalize values that do not meet the required rules.

Treat all schema names as untrusted input, use structured generation mechanisms where possible, test adversarial names in CI, and execute generation and generated imports with minimal privileges.

It is generally not a direct network-service exploit. Exploitation depends on an attacker being able to influence an Avro schema that is processed by the vulnerable generator and on the resulting Python code being generated or executed.

The attacker needs control over, or the ability to modify, schema content consumed by the generator. The practical impact also depends on whether generated modules are imported automatically and what privileges the generation workflow has.

Validate every schema-controlled enum symbol as a legal target-language identifier before code generation, and reject or safely normalize values that do not meet the required rules.

Treat all schema names as untrusted input, use structured generation mechanisms where possible, test adversarial names in CI, and execute generation and generated imports with minimal privileges.

Find out what's already
exploitable in your codebase.