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.

