/

CVE-2026-108377

Severity:

HIGH RISK

(8.8)

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

CVE-2026-108377

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

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.

Sources

SourceLink
github.comgithub.com/marcosschroh/dataclasses-avroschema/commit/429f3d705d2d04c0c65e2ef832daed5ff91318fc
github.comgithub.com/marcosschroh/dataclasses-avroschema/commit/919d3e07c8938369cfc2c0569007ba373247e74a
github.comgithub.com/marcosschroh/dataclasses-avroschema/releases/tag/0.70.6
github.comgithub.com/marcosschroh/dataclasses-avroschema/security/advisories/GHSA-57hr-pcm8-p9j9

Frequently asked

questions

It can be exploitable through a remote or indirect path if an application accepts attacker-controlled Avro schemas and imports the generated Python code. Otherwise, exploitation may require local access to the schema or generation workflow.

An attacker must be able to influence the Avro record name or another schema input that reaches the vulnerable rendering path, and the generated module must subsequently be imported or executed.

Escape schema-controlled values according to the target Python string-literal context, validate names before generation, and avoid constructing executable source through unsafe string interpolation.

Treat schemas as untrusted input, apply source-generation security reviews, test hostile names, restrict generated-code execution privileges, and enforce artifact validation before import.

It can be exploitable through a remote or indirect path if an application accepts attacker-controlled Avro schemas and imports the generated Python code. Otherwise, exploitation may require local access to the schema or generation workflow.

An attacker must be able to influence the Avro record name or another schema input that reaches the vulnerable rendering path, and the generated module must subsequently be imported or executed.

Escape schema-controlled values according to the target Python string-literal context, validate names before generation, and avoid constructing executable source through unsafe string interpolation.

Treat schemas as untrusted input, apply source-generation security reviews, test hostile names, restrict generated-code execution privileges, and enforce artifact validation before import.

Find out what's already
exploitable in your codebase.