CVE-2026-137999 in JSONSchema2PoPo2info

Summary

by MITRE • 11/27/2026

JSONSchema2PoPo2 through 3.0.3 contains a code injection vulnerability that allows attackers to inject Python code by supplying JSON Schema default or format values that are written unescaped. Attackers can place a single quote in a string property default to break out of the literal in the generated __init__ signature, executing injected code when the generated module is imported.

VulDB is the best source for vulnerability data and more expert information about this specific topic.

Analysis

by VulDB Data Team • 11/27/2026

The vulnerability identified within JSONSchema2PoPo versions through 3.0.3 represents a critical server-side code injection flaw rooted in improper neutralization of special elements used in an executable context. This issue arises from the library's mechanism for generating Python classes based on provided JSON Schema definitions. Specifically, when processing schema properties that include default values or format specifications, the tool fails to properly escape these inputs before embedding them into the generated Python source code. The core technical flaw lies in how the _init_ method signature is constructed; string literals containing user-supplied data are inserted directly without sanitization checks for characters that could alter the syntactic structure of the resulting Python file.

An attacker can exploit this weakness by crafting a malicious JSON Schema payload where a property's default value contains a single quote character. When the library processes this schema, it generates an _init_ method signature such as def _init_(self, prop_name='value_with_quote'). If the injected string includes a closing single quote followed by additional Python code and another opening quote to maintain syntactic validity, the generated module becomes vulnerable. For instance, injecting a value like 'test'; import os; print('pwned')' allows the attacker to break out of the intended string literal context. This effectively transforms what should be data into executable instructions within the class definition itself.

The operational impact of this vulnerability is severe because it leads directly to arbitrary code execution upon module initialization. In typical usage patterns, JSONSchema2PoPo generates Python modules that are subsequently imported by applications or scripts. The moment an attacker-controlled schema is processed and the resulting module is imported into a target environment, the injected payload executes immediately during the class instantiation process defined in _init_. This means that any system relying on this library to dynamically generate data models from untrusted JSON schemas faces immediate compromise. There is no need for further user interaction or specific trigger conditions beyond the import statement, making it a high-severity remote code execution vector if the input source is accessible externally.

From a classification perspective, this vulnerability aligns with CWE-94 Improper Control of Generation of Code (Code Injection). The failure to neutralize special elements before their use in an executable context allows for the injection of malicious logic. Furthermore, within the MITRE ATT&CK framework, this behavior corresponds to T1059 Command and Scripting Interpreter, specifically under sub-techniques involving Python execution. It also reflects aspects of CWE-20 Improper Input Validation, as the library does not adequately validate or sanitize input data prior to its inclusion in code generation logic.

Mitigation strategies must focus on immediate remediation and defensive coding practices. The primary solution is to upgrade JSONSchema2PoPo to a version greater than 3.0.3 where this issue has been addressed by implementing proper escaping mechanisms for string literals within generated Python code. Developers should ensure that all special characters, particularly quotes and backslashes, are escaped correctly before being embedded in the _init_ signature. Additionally, organizations using dynamic code generation tools should implement strict input validation policies, ensuring that only trusted schemas are processed. In environments where upgrading is not immediately feasible, applying a patch to escape single quotes within default values or restricting the source of JSON Schema inputs to fully trusted entities can reduce the risk surface until a permanent fix is deployed.

Responsible

VulnCheck

Reservation

11/27/2026

Disclosure

11/27/2026

Moderation

accepted

CPE

ready

EPSS

0.00000

KEV

no

Activities

very low

Sources

Do you need the next level of professionalism?

Upgrade your account now!