CVE-2026-108377
Unescaped schema name leads to code injection in generated Python classes.
- CVSS 8.8
- CWE-94
- Input Validation and Sanitization
- Remote
dataclasses-avroschema generates Avro schemas from Python dataclasses, Pydantic models, and Faust Records and generates Python code from Avro schemas. From version 0.62.3 through 0.70.5, ClassRepresentation.render_metaclass inserts a schema-controlled Avro record name into the quoted Meta.schema_name field of generated Python source without escaping it. A crafted name can terminate the string literal and inject statements into the generated class body, which execute when the generated module is imported. Version 0.70.6 fixes the vulnerability by escaping schema values rendered into generated string literals.
- CWE
- CWE-94
- CVSS base score
- 8.8
- Published
- 2026-10-13
- OWASP
- A03 Injection
- Orthogonal defect classification
- Checking
- Code defect classification
- Missing Check
- Category
- Input Validation and Sanitization
- Subcategory
- Command Injection
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Affected component
- dataclasses-avroschema
- Fixed by upgrading
- Yes
Solution
Upgrade dataclasses‑avroschema to version 0.70.6 or newer.
Vulnerable code sample
import dataclasses
from dataclasses_avroschema import AvroModel
# Simulated internal rendering (simplified)
class ClassRepresentation:
def __init__(self, schema_name: str):
self.schema_name = schema_name
def render_metaclass(self) -> str:
# VULNERABLE: inserts unescaped schema_name into generated source
template = f'''
class Meta:
schema_name = "{self.schema_name}"
'''
return template
# Example usage with malicious schema name
malicious_name = 'SafeName"; import os; os.system("echo exploited") #'
rep = ClassRepresentation(malicious_name)
generated_code = rep.render_metaclass()
# The following exec simulates importing the generated module
exec(generated_code)Patched code sample
import dataclasses
from dataclasses_avroschema import AvroModel
import json
# Simulated internal rendering (simplified)
class ClassRepresentation:
def __init__(self, schema_name: str):
self.schema_name = schema_name
def render_metaclass(self) -> str:
# FIX: safely escape schema_name when rendering
escaped_name = json.dumps(self.schema_name)
template = f'''
class Meta:
schema_name = {escaped_name}
'''
return template
# Example usage with malicious schema name
malicious_name = 'SafeName"; import os; os.system("echo exploited") #'
rep = ClassRepresentation(malicious_name)
generated_code = rep.render_metaclass()
exec(generated_code)Published fix
Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.
- fix: security patched (marcosschroh/dataclasses-avroschema)
dataclasses_avroschema/exceptions.py,dataclasses_avroschema/model_generator/lang/python/avrodantic/avrodantic_model_generator.py,dataclasses_avroschema/model_generator/lang/python/avrodantic/avrodantic_model_generator.py · AvroDanticModelGenerator._resolve_type_from_metadata,dataclasses_avroschema/model_generator/lang/python/base.py,dataclasses_avroschema/model_generator/lang/python/base.py · BaseGenerator.parse_enum,dataclasses_avroschema/model_generator/lang/python/base.py · BaseGenerator.parse_fixed,dataclasses_avroschema/model_generator/lang/python/base.py · ClassRepresentation.render_docstring,dataclasses_avroschema/model_generator/lang/python/base.py · ClassRepresentation.render_metaclass,dataclasses_avroschema/model_generator/lang/python/base.py · EnumRepresentation.render_symbols,dataclasses_avroschema/model_generator/lang/python/base.py · FieldRepresentation.get_field_default,dataclasses_avroschema/model_generator/lang/python/pydantic/pydantic_model_generator.py,dataclasses_avroschema/model_generator/lang/python/pydantic/pydantic_model_generator.py · PydanticFieldRepresentation.add_field_propertiesand 2 more - fix: incorrect casing when rendering fields and enums (#694). Closes #693 and #692 (marcosschroh/dataclasses-avroschema)
dataclasses_avroschema/fields/fields.py · EnumField.get_avro_type,dataclasses_avroschema/model_generator/lang/python/base.py,dataclasses_avroschema/model_generator/lang/python/base.py · BaseGenerator.get_field_default,dataclasses_avroschema/model_generator/lang/python/base.py · BaseGenerator.get_language_type,dataclasses_avroschema/model_generator/lang/python/base.py · BaseGenerator.parse_enum,dataclasses_avroschema/model_generator/lang/python/base.py · BaseGenerator.render_class,dataclasses_avroschema/model_generator/lang/python/base.py · BaseGenerator.render_metaclass,dataclasses_avroschema/utils.py,dataclasses_avroschema/utils.py · FieldMetadata.create
Cite this entry
@misc{vaitp:cve2026108377,
title = {{Unescaped schema name leads to code injection in generated Python classes.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-108377},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-108377/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
