/

CVE-2026-108376

Severity:

HIGH RISK

(8.8)

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

CVE-2026-108376

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 place a schema-controlled record name into the callable position of a generated Python default factory without validating that name as an Avro identifier. If an attacker can influence a referenced record name and the generated model later consumes the default, the crafted value may execute an arbitrary Python expression in the application process.

dataclasses-avroschema can place a schema-controlled record name into the callable position of a generated Python default factory without validating that name as an Avro identifier. If an attacker can influence a referenced record name and the generated model later consumes the default, the crafted value may execute an arbitrary Python expression in the application process.

Affected context

The vulnerability occurs in dataclasses-avroschema versions that generate Python models or schema-related code from Avro definitions. It becomes risky when a referenced record name is obtained from a schema or other controllable input and is inserted into generated default-factory code before being checked against the Avro name grammar.

The vulnerability occurs in dataclasses-avroschema versions that generate Python models or schema-related code from Avro definitions. It becomes risky when a referenced record name is obtained from a schema or other controllable input and is inserted into generated default-factory code before being checked against the Avro name grammar.

Exploit preconditions

  • Attack surface: Avro schema processing and Python model code generation
  • Required access: Ability to supply or modify an Avro schema, or otherwise influence a referenced record name
  • Trigger point: Instantiation of a generated model that evaluates the affected field's default factory
  • Why exploitation is possible: The record name is placed in a callable expression without strict identifier validation, allowing crafted input to be interpreted as Python code
  • Attack surface: Avro schema processing and Python model code generation
  • Required access: Ability to supply or modify an Avro schema, or otherwise influence a referenced record name
  • Trigger point: Instantiation of a generated model that evaluates the affected field's default factory
  • Why exploitation is possible: The record name is placed in a callable expression without strict identifier validation, allowing crafted input to be interpreted as Python code

Why this happens

The underlying flaw is dynamic code generation that treats schema metadata as a trusted Python expression. A referenced record name is inserted into the callable position of a generated lambda without first restricting it to valid Avro name characters and structure. This maps to CWE-94: Improper Control of Generation of Code, because attacker-influenced data can alter executable code produced by the application.

The underlying flaw is dynamic code generation that treats schema metadata as a trusted Python expression. A referenced record name is inserted into the callable position of a generated lambda without first restricting it to valid Avro name characters and structure. This maps to CWE-94: Improper Control of Generation of Code, because attacker-influenced data can alter executable code produced by the application.

Potential impact

  • An attacker may execute arbitrary Python expressions in the consuming application process
  • The application could disclose, modify, or delete accessible data
  • Credentials, tokens, or environment information could be exposed
  • The affected service may be used for further compromise or lateral movement
  • An attacker may execute arbitrary Python expressions in the consuming application process
  • The application could disclose, modify, or delete accessible data
  • Credentials, tokens, or environment information could be exposed
  • The affected service may be used for further compromise or lateral movement

General mitigation guidance

Mitigation generally focuses on preventing schema data from becoming executable source code.

Common defensive patterns include:

  • Validate referenced record names against the complete Avro name grammar before code generation
  • Generate callable references from trusted, structured symbols rather than string interpolation
  • Prefer data-driven default handling over dynamically generated executable expressions
  • Apply strict schema validation before generating models or Python code
  • Run schema-processing workloads with least-privilege permissions and restricted access to secrets
  • Treat externally supplied schemas as untrusted even when they conform to a broader serialization format

Mitigation generally focuses on preventing schema data from becoming executable source code.

Common defensive patterns include:

  • Validate referenced record names against the complete Avro name grammar before code generation
  • Generate callable references from trusted, structured symbols rather than string interpolation
  • Prefer data-driven default handling over dynamically generated executable expressions
  • Apply strict schema validation before generating models or Python code
  • Run schema-processing workloads with least-privilege permissions and restricted access to secrets
  • Treat externally supplied schemas as untrusted even when they conform to a broader serialization format

How teams detect issues like this

Organizations can look for:

  • Static analysis rules identifying string interpolation or concatenation inside generated Python expressions
  • Code review signals where schema fields, record names, or metadata are inserted into callable positions
  • Tests using invalid and adversarial Avro names to verify rejection before code generation
  • Policy checks requiring allowlisted identifier validation and structured symbol resolution
  • Runtime monitoring for unexpected model-generation behavior or child-process activity in schema-processing services

Automated security review tools may help identify dynamic code-generation patterns, but findings should be validated against the actual generation and execution flow.

Organizations can look for:

  • Static analysis rules identifying string interpolation or concatenation inside generated Python expressions
  • Code review signals where schema fields, record names, or metadata are inserted into callable positions
  • Tests using invalid and adversarial Avro names to verify rejection before code generation
  • Policy checks requiring allowlisted identifier validation and structured symbol resolution
  • Runtime monitoring for unexpected model-generation behavior or child-process activity in schema-processing services

Automated security review tools may help identify dynamic code-generation patterns, but findings should be validated against the actual generation and execution flow.

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-jcjg-gjg5-xp7v
hackmd.iohackmd.io/@1ExmmukzRMWN7B4gQ4W-4Q/cve-2026-110113-publiccms-trade-address-save-cross-user-overwrite

Frequently asked

questions

It can be exploitable through a remote schema-processing interface when an attacker can submit or influence Avro schemas. In other deployments, exploitation may require local access to schema files or another trusted input path.

The attacker needs control over, or the ability to modify, a referenced record name that reaches code generation. They must also cause a generated model instance to evaluate the affected default factory.

Validate record names against the Avro grammar before they reach code generation, and avoid constructing executable expressions from untrusted strings. Structured references are safer than interpolated source code.

Treat schemas as untrusted input, enforce validation at trust boundaries, test generated code with adversarial names, and run schema-processing components with minimal privileges.

It can be exploitable through a remote schema-processing interface when an attacker can submit or influence Avro schemas. In other deployments, exploitation may require local access to schema files or another trusted input path.

The attacker needs control over, or the ability to modify, a referenced record name that reaches code generation. They must also cause a generated model instance to evaluate the affected default factory.

Validate record names against the Avro grammar before they reach code generation, and avoid constructing executable expressions from untrusted strings. Structured references are safer than interpolated source code.

Treat schemas as untrusted input, enforce validation at trust boundaries, test generated code with adversarial names, and run schema-processing components with minimal privileges.

Find out what's already
exploitable in your codebase.