/

CVE-2026-108384

Severity:

HIGH RISK

(8.8)

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

CVE-2026-108384

Deferred

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 embed a fixed type's aliases value directly into generated Python annotations without ensuring that the value is a list. If an attacker can supply or influence a crafted Avro schema and the generated module is later imported, the injected expression may execute with the module's privileges.

dataclasses-avroschema can embed a fixed type's aliases value directly into generated Python annotations without ensuring that the value is a list. If an attacker can supply or influence a crafted Avro schema and the generated module is later imported, the injected expression may execute with the module's privileges.

Affected context

The vulnerability occurs in schema-to-code generation workflows that process fixed Avro types and emit Python source code. It becomes risky when an attacker can influence the Avro schema, the generated source is written to a location that will be imported, and the import occurs in a sufficiently privileged environment.

The vulnerability occurs in schema-to-code generation workflows that process fixed Avro types and emit Python source code. It becomes risky when an attacker can influence the Avro schema, the generated source is written to a location that will be imported, and the import occurs in a sufficiently privileged environment.

Exploit preconditions

  • Attack surface: Avro schema processing and Python code generation
  • Required access: Ability to provide or modify a schema containing a crafted fixed type
  • Trigger point: Generation followed by import or execution of the resulting Python module
  • Why exploitation is possible: A non-list aliases value can be interpolated as an unquoted Python expression in generated source code
  • Attack surface: Avro schema processing and Python code generation
  • Required access: Ability to provide or modify a schema containing a crafted fixed type
  • Trigger point: Generation followed by import or execution of the resulting Python module
  • Why exploitation is possible: A non-list aliases value can be interpolated as an unquoted Python expression in generated source code

Why this happens

The underlying bug is insufficient validation and escaping of schema metadata before it is inserted into generated Python code. Although aliases is expected to be represented as a list, a bare string can pass through generation and become executable syntax rather than inert data. This maps to CWE-94: Improper Control of Generation of Code, because attacker-influenced input affects the contents of generated code.

The underlying bug is insufficient validation and escaping of schema metadata before it is inserted into generated Python code. Although aliases is expected to be represented as a list, a bare string can pass through generation and become executable syntax rather than inert data. This maps to CWE-94: Improper Control of Generation of Code, because attacker-influenced input affects the contents of generated code.

Potential impact

  • Arbitrary Python code execution in the process importing the generated module
  • Access to application data, credentials, and environment variables
  • Modification or deletion of files available to the process
  • Further compromise of connected services or build environments
  • Supply-chain or build-pipeline tampering
  • Arbitrary Python code execution in the process importing the generated module
  • Access to application data, credentials, and environment variables
  • Modification or deletion of files available to the process
  • Further compromise of connected services or build environments
  • Supply-chain or build-pipeline tampering

General mitigation guidance

Mitigation generally focuses on treating schemas as untrusted input and preventing metadata from becoming executable source code.

Common defensive patterns include:

  • Enforcing that aliases is a list before code generation
  • Rejecting unexpected types, expressions, and syntax-bearing values
  • Escaping or safely serializing values inserted into generated Python
  • Preferentially generating data through structured APIs rather than source-code interpolation
  • Separating generation from import or execution and applying least privilege to generation jobs
  • Restricting schema provenance, write access, and execution of generated artifacts

These controls reduce exposure even when a schema is obtained from an external or semi-trusted source.

Mitigation generally focuses on treating schemas as untrusted input and preventing metadata from becoming executable source code.

Common defensive patterns include:

  • Enforcing that aliases is a list before code generation
  • Rejecting unexpected types, expressions, and syntax-bearing values
  • Escaping or safely serializing values inserted into generated Python
  • Preferentially generating data through structured APIs rather than source-code interpolation
  • Separating generation from import or execution and applying least privilege to generation jobs
  • Restricting schema provenance, write access, and execution of generated artifacts

These controls reduce exposure even when a schema is obtained from an external or semi-trusted source.

How teams detect issues like this

Organizations can look for this class of issue through:

  • Static analysis rules identifying string interpolation into generated source code
  • Code review checks for schema values inserted without type validation or escaping
  • Tests using unexpected scalar, expression-like, and malformed metadata values
  • Dependency and component policies that flag unsafe code-generation paths
  • Runtime monitoring for unexpected imports, subprocess creation, or file access during schema generation

Automated security review tools may help identify generated-code sinks, but findings should be validated against the complete generation and import workflow.

Organizations can look for this class of issue through:

  • Static analysis rules identifying string interpolation into generated source code
  • Code review checks for schema values inserted without type validation or escaping
  • Tests using unexpected scalar, expression-like, and malformed metadata values
  • Dependency and component policies that flag unsafe code-generation paths
  • Runtime monitoring for unexpected imports, subprocess creation, or file access during schema generation

Automated security review tools may help identify generated-code sinks, but findings should be validated against the complete generation and import workflow.

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-8j5c-xq6f-2c43

Frequently asked

questions

It can be exploitable remotely when an application accepts attacker-controlled Avro schemas and automatically generates or imports Python code. In other deployments, exploitation may require access to a schema repository, build job, or generation service.

The attacker generally needs a way to influence a fixed type's aliases value and cause the resulting generated module to be imported or executed. The required privileges depend on how schemas and generated artifacts are managed.

Validate aliases against the expected list type, reject unexpected values, and ensure schema data is serialized as data rather than interpolated into executable Python source.

Treat schemas as untrusted input, apply strict schemas and allowlists, test generated output with hostile metadata, review code-generation sinks, and run generation and import processes with minimal privileges.

It can be exploitable remotely when an application accepts attacker-controlled Avro schemas and automatically generates or imports Python code. In other deployments, exploitation may require access to a schema repository, build job, or generation service.

The attacker generally needs a way to influence a fixed type's aliases value and cause the resulting generated module to be imported or executed. The required privileges depend on how schemas and generated artifacts are managed.

Validate aliases against the expected list type, reject unexpected values, and ensure schema data is serialized as data rather than interpolated into executable Python source.

Treat schemas as untrusted input, apply strict schemas and allowlists, test generated output with hostile metadata, review code-generation sinks, and run generation and import processes with minimal privileges.

Find out what's already
exploitable in your codebase.