/

CVE-2026-108382

Severity:

HIGH RISK

(8.8)

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

CVE-2026-108382

Awaiting Analysis

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Arbitrary Code Execution

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 generate Python enum code using schema-controlled symbol values without safely escaping them. If an attacker can influence those symbols and generated code is later imported, arbitrary Python code may execute during module loading.

dataclasses-avroschema can generate Python enum code using schema-controlled symbol values without safely escaping them. If an attacker can influence those symbols and generated code is later imported, arbitrary Python code may execute during module loading.

Affected context

The vulnerability occurs when dataclasses-avroschema generator classes are invoked directly to render Python code from Avro schemas containing attacker-influenced enum symbols. The risk is present when generated modules are written to a location that the application or build process imports or executes.

The vulnerability occurs when dataclasses-avroschema generator classes are invoked directly to render Python code from Avro schemas containing attacker-influenced enum symbols. The risk is present when generated modules are written to a location that the application or build process imports or executes.

Exploit preconditions

  • Attack surface: Avro-to-Python code generation, specifically enum rendering - Required access: Ability to provide or alter an Avro schema or enum symbol consumed by the generator - Trigger point: Import or execution of the generated Python module - Why exploitation is possible: Schema-controlled symbols are inserted into a Python string literal without adequate escaping, allowing generated source structure to be altered
  • Attack surface: Avro-to-Python code generation, specifically enum rendering - Required access: Ability to provide or alter an Avro schema or enum symbol consumed by the generator - Trigger point: Import or execution of the generated Python module - Why exploitation is possible: Schema-controlled symbols are inserted into a Python string literal without adequate escaping, allowing generated source structure to be altered

Why this happens

The generator constructs Python enum assignments by concatenating schema-controlled symbol values between double quotes. A symbol containing source-breaking characters can terminate the intended string literal and introduce additional Python syntax into the generated enum class body. This behavior maps to CWE-94, Improper Control of Generation of Code, because untrusted input influences executable source code without reliable encoding or context-aware escaping.

The generator constructs Python enum assignments by concatenating schema-controlled symbol values between double quotes. A symbol containing source-breaking characters can terminate the intended string literal and introduce additional Python syntax into the generated enum class body. This behavior maps to CWE-94, Improper Control of Generation of Code, because untrusted input influences executable source code without reliable encoding or context-aware escaping.

Potential impact

  • Arbitrary Python code may execute when a generated module is imported
  • Build, development, or application environments could be compromised
  • Credentials and other process-accessible data could be exposed
  • Generated artifacts could be modified to support persistence or supply-chain abuse
  • Arbitrary Python code may execute when a generated module is imported
  • Build, development, or application environments could be compromised
  • Credentials and other process-accessible data could be exposed
  • Generated artifacts could be modified to support persistence or supply-chain abuse

General mitigation guidance

Mitigation generally focuses on treating schema values as data throughout code generation. Generators should apply context-aware escaping or use structured code-generation APIs that do not concatenate untrusted values into source text. Strict schema validation and allowlists for enum symbols can reduce input trust, while separating generated artifacts from sensitive execution environments and applying least-privilege permissions can limit impact. Generated code should be reviewed or validated before it is imported, and secure-by-default generator behavior should reject or safely encode unsupported symbols.

Mitigation generally focuses on treating schema values as data throughout code generation. Generators should apply context-aware escaping or use structured code-generation APIs that do not concatenate untrusted values into source text. Strict schema validation and allowlists for enum symbols can reduce input trust, while separating generated artifacts from sensitive execution environments and applying least-privilege permissions can limit impact. Generated code should be reviewed or validated before it is imported, and secure-by-default generator behavior should reject or safely encode unsupported symbols.

How teams detect issues like this

Detection can include static analysis rules for string concatenation or formatting of schema-controlled values into Python source, along with code review checks for generated literals that lack context-aware escaping. Repository policies can require schema validation, prohibit direct execution of unreviewed generated artifacts, and test enum symbols containing quotes or other syntax-sensitive characters. Automated security review tools may help identify these code-generation patterns.

Detection can include static analysis rules for string concatenation or formatting of schema-controlled values into Python source, along with code review checks for generated literals that lack context-aware escaping. Repository policies can require schema validation, prohibit direct execution of unreviewed generated artifacts, and test enum symbols containing quotes or other syntax-sensitive characters. Automated security review tools may help identify these code-generation patterns.

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-vrq9-94ww-jv3c

Frequently asked

questions

It is not inherently a network-only issue. Exploitation depends on whether an attacker can influence schemas or enum symbols that are processed by a reachable generation workflow and whether the resulting module is imported.

The attacker generally needs a path to supply or modify schema-controlled enum values, directly or through an upstream data or build process. They also need the generated Python code to reach an execution or import point.

Treat enum symbols as untrusted data, use context-aware escaping or structured code-generation mechanisms, and validate generated artifacts before import or execution.

Apply strict schema and symbol validation, isolate code-generation pipelines, review generated source, restrict generator privileges, and include syntax-sensitive values in security testing.

It is not inherently a network-only issue. Exploitation depends on whether an attacker can influence schemas or enum symbols that are processed by a reachable generation workflow and whether the resulting module is imported.

The attacker generally needs a path to supply or modify schema-controlled enum values, directly or through an upstream data or build process. They also need the generated Python code to reach an execution or import point.

Treat enum symbols as untrusted data, use context-aware escaping or structured code-generation mechanisms, and validate generated artifacts before import or execution.

Apply strict schema and symbol validation, isolate code-generation pipelines, review generated source, restrict generator privileges, and include syntax-sensitive values in security testing.

Find out what's already
exploitable in your codebase.