/

CVE-2026-108383

Severity:

HIGH RISK

(8.8)

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

CVE-2026-108383

Awaiting Analysis

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Arbitrary Code Injection in Generated Python Modules

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

CVE-2026-108383 is a high-severity code injection vulnerability in dataclasses-avroschema's Avro-to-Python code generation path. When an attacker can influence an enum field default in a schema, insufficient validation may allow injected statements to alter the generated module or prevent it from loading.

CVE-2026-108383 is a high-severity code injection vulnerability in dataclasses-avroschema's Avro-to-Python code generation path. When an attacker can influence an enum field default in a schema, insufficient validation may allow injected statements to alter the generated module or prevent it from loading.

Affected context

The vulnerability affects applications that use dataclasses-avroschema to generate Python code from Avro schemas and process schema-controlled enum defaults. It becomes risky when an untrusted or insufficiently trusted party can supply or modify schemas whose enum defaults are incorporated into generated source code after case conversion but before identifier validation.

The vulnerability affects applications that use dataclasses-avroschema to generate Python code from Avro schemas and process schema-controlled enum defaults. It becomes risky when an untrusted or insufficiently trusted party can supply or modify schemas whose enum defaults are incorporated into generated source code after case conversion but before identifier validation.

Exploit preconditions

  • Attack surface: Avro schema processing and Python source-code generation
  • Required access: Ability to provide or modify an Avro schema, or influence an enum default consumed by the generator
  • Trigger point: Rendering an enum field default into the generated Python module
  • Why exploitation is possible: The generated reference is not validated as a safe identifier, allowing special characters, line breaks, or operators to escape the intended expression context
  • Attack surface: Avro schema processing and Python source-code generation
  • Required access: Ability to provide or modify an Avro schema, or influence an enum default consumed by the generator
  • Trigger point: Rendering an enum field default into the generated Python module
  • Why exploitation is possible: The generated reference is not validated as a safe identifier, allowing special characters, line breaks, or operators to escape the intended expression context

Why this happens

The underlying bug is improper neutralization of schema-controlled data during source-code generation, mapping to CWE-94: Improper Control of Generation of Code ('Code Injection').

The generator treats an enum default as a Python enum-member reference after applying case conversion, but does not confirm that the resulting value is a valid identifier. As a result, syntactic content can be inserted into generated source rather than being represented solely as data.

The underlying bug is improper neutralization of schema-controlled data during source-code generation, mapping to CWE-94: Improper Control of Generation of Code ('Code Injection').

The generator treats an enum default as a Python enum-member reference after applying case conversion, but does not confirm that the resulting value is a valid identifier. As a result, syntactic content can be inserted into generated source rather than being represented solely as data.

Potential impact

  • Generated Python modules may fail to load
  • Injected statements may alter module behavior or namespace contents
  • Code generation workflows may execute unintended logic when generated code is imported or run
  • Downstream applications may experience integrity, availability, or supply-chain impacts
  • Generated Python modules may fail to load
  • Injected statements may alter module behavior or namespace contents
  • Code generation workflows may execute unintended logic when generated code is imported or run
  • Downstream applications may experience integrity, availability, or supply-chain impacts

General mitigation guidance

Mitigation generally focuses on treating schema values as untrusted data throughout code generation.

Common defensive patterns include:

  • Validate enum defaults against a strict identifier grammar before embedding them in source code
  • Prefer structured code-generation APIs or AST-based generation over string concatenation
  • Use safe serialization and escaping appropriate to the target language
  • Enforce schema ownership, integrity, and review controls before generation
  • Separate generated-code creation from execution and apply least-privilege permissions to generation and build environments
  • Reject invalid schemas before rendering any source code

Mitigation generally focuses on treating schema values as untrusted data throughout code generation.

Common defensive patterns include:

  • Validate enum defaults against a strict identifier grammar before embedding them in source code
  • Prefer structured code-generation APIs or AST-based generation over string concatenation
  • Use safe serialization and escaping appropriate to the target language
  • Enforce schema ownership, integrity, and review controls before generation
  • Separate generated-code creation from execution and apply least-privilege permissions to generation and build environments
  • Reject invalid schemas before rendering any source code

How teams detect issues like this

Detection can include static analysis for string interpolation or concatenation involving schema-controlled values in generated source code. Code reviews should look for missing identifier validation, language-aware escaping, and source generation that occurs before schema integrity checks.

CI policies can reject schemas containing enum defaults that do not conform to the target language's identifier rules. Automated code review and taint-analysis tools may also help identify flows from schema input into generated Python statements.

Detection can include static analysis for string interpolation or concatenation involving schema-controlled values in generated source code. Code reviews should look for missing identifier validation, language-aware escaping, and source generation that occurs before schema integrity checks.

CI policies can reject schemas containing enum defaults that do not conform to the target language's identifier rules. Automated code review and taint-analysis tools may also help identify flows from schema input into generated Python statements.

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-4xxf-mv22-hcr8

Frequently asked

questions

Its exploitability depends on whether an attacker can supply or modify Avro schemas used by a generation workflow. A network-accessible schema-management or build service could expand the attack surface, while locally controlled schemas reduce it.

Authentication is not the decisive factor. The relevant prerequisite is the ability to influence an enum default that reaches the Python code generator; that ability may be obtained through an authenticated service, repository access, or another trusted input path.

Validate enum defaults as strict identifiers before inserting them into generated code, and use language-aware escaping or structured code-generation mechanisms rather than direct source concatenation.

Treat schemas as untrusted input, enforce integrity and schema validation gates, review generated-code boundaries, and run generation and validation processes with minimal privileges.

Its exploitability depends on whether an attacker can supply or modify Avro schemas used by a generation workflow. A network-accessible schema-management or build service could expand the attack surface, while locally controlled schemas reduce it.

Authentication is not the decisive factor. The relevant prerequisite is the ability to influence an enum default that reaches the Python code generator; that ability may be obtained through an authenticated service, repository access, or another trusted input path.

Validate enum defaults as strict identifiers before inserting them into generated code, and use language-aware escaping or structured code-generation mechanisms rather than direct source concatenation.

Treat schemas as untrusted input, enforce integrity and schema validation gates, review generated-code boundaries, and run generation and validation processes with minimal privileges.

Find out what's already
exploitable in your codebase.