Summary
CVE-2026-108377 is a code-injection vulnerability in dataclasses-avroschema, where a schema-controlled Avro record name is inserted into generated Python source without escaping. An attacker who can influence that name may inject statements that execute when the generated module is imported.
CVE-2026-108377 is a code-injection vulnerability in dataclasses-avroschema, where a schema-controlled Avro record name is inserted into generated Python source without escaping. An attacker who can influence that name may inject statements that execute when the generated module is imported.
Affected context
The vulnerability affects workflows that generate Python code from Avro schemas using dataclasses-avroschema versions in the affected range. Risk arises when an untrusted or insufficiently controlled Avro record name reaches ClassRepresentation.render_metaclass and the resulting source is later imported or executed.
The vulnerability affects workflows that generate Python code from Avro schemas using dataclasses-avroschema versions in the affected range. Risk arises when an untrusted or insufficiently controlled Avro record name reaches ClassRepresentation.render_metaclass and the resulting source is later imported or executed.
Exploit preconditions
- Attack surface: Avro-to-Python source generation and subsequent module import
- Required access: Ability to provide or influence an Avro schema record name
- Trigger point: Import or execution of the generated Python module
- Why exploitation is possible: The record name is inserted into a Python string literal without escaping, allowing crafted input to alter the generated class body
- Attack surface: Avro-to-Python source generation and subsequent module import
- Required access: Ability to provide or influence an Avro schema record name
- Trigger point: Import or execution of the generated Python module
- Why exploitation is possible: The record name is inserted into a Python string literal without escaping, allowing crafted input to alter the generated class body
Why this happens
The underlying flaw is improper neutralization of schema-controlled data when generating Python source code. A record name is rendered inside a quoted string literal without applying syntax-aware escaping, allowing data intended to remain a value to become executable Python statements. This maps to CWE-94: Improper Control of Generation of Code, because untrusted input can influence generated program structure.
The underlying flaw is improper neutralization of schema-controlled data when generating Python source code. A record name is rendered inside a quoted string literal without applying syntax-aware escaping, allowing data intended to remain a value to become executable Python statements. This maps to CWE-94: Improper Control of Generation of Code, because untrusted input can influence generated program structure.
Potential impact
- Arbitrary Python code execution when generated modules are imported
- Compromise of the process running the code generator or generated application
- Access to sensitive files, credentials, or environment data
- Modification of generated artifacts or downstream application behavior
- Potential lateral movement depending on process privileges and network access
- Arbitrary Python code execution when generated modules are imported
- Compromise of the process running the code generator or generated application
- Access to sensitive files, credentials, or environment data
- Modification of generated artifacts or downstream application behavior
- Potential lateral movement depending on process privileges and network access
General mitigation guidance
Mitigation generally focuses on separating schema data from generated source syntax and reducing trust in externally supplied schemas.
Common defensive patterns include:
- Apply context-appropriate escaping whenever values are rendered into source-code string literals
- Prefer structured code-generation APIs or safe serialization mechanisms over string concatenation
- Validate record names against a strict schema and identifier policy before generation
- Treat generated code as untrusted until it has passed review and automated checks
- Generate or import code in least-privileged, isolated environments
- Restrict access to generated artifacts and prevent unauthorized schema modification
Mitigation generally focuses on separating schema data from generated source syntax and reducing trust in externally supplied schemas.
Common defensive patterns include:
- Apply context-appropriate escaping whenever values are rendered into source-code string literals
- Prefer structured code-generation APIs or safe serialization mechanisms over string concatenation
- Validate record names against a strict schema and identifier policy before generation
- Treat generated code as untrusted until it has passed review and automated checks
- Generate or import code in least-privileged, isolated environments
- Restrict access to generated artifacts and prevent unauthorized schema modification
How teams detect issues like this
Organizations can detect this class of issue through:
- Static analysis rules for concatenating or interpolating untrusted values into Python source
- Code review checks covering escaping, quoting, and template rendering in code generators
- Tests using delimiter, quote, and statement-like characters in schema names
- Policy enforcement requiring generated source to pass syntax, security, and provenance checks before import
- Monitoring unexpected generated-module imports or anomalous process behavior
Automated security review tools may help identify unsafe source-generation patterns, but generated-code testing remains important.
Organizations can detect this class of issue through:
- Static analysis rules for concatenating or interpolating untrusted values into Python source
- Code review checks covering escaping, quoting, and template rendering in code generators
- Tests using delimiter, quote, and statement-like characters in schema names
- Policy enforcement requiring generated source to pass syntax, security, and provenance checks before import
- Monitoring unexpected generated-module imports or anomalous process behavior
Automated security review tools may help identify unsafe source-generation patterns, but generated-code testing remains important.

