datamodel-code-generatorに任意のコードを実行される脆弱性
Summary
悪意あるJSON Schemaを読み込ませると、x-python-type注釈経由で任意のコードを実行されるおそれがあります。影響するのは0.84.0より前のdatamodel-code-generatorで、修正版は0.84.0です。開発者の端末やCI/CDパイプラインでも悪用されるおそれがあるため、0.84.0以降への更新を優先してください。
AI summary
Produced by SecPulse using an external AI model; it may contain mistakes. Check the original description and references below before acting on it.
悪意あるJSON Schemaを読み込ませると、x-python-type注釈経由で任意のコードを実行されるおそれがあります。影響するのは0.84.0より前のdatamodel-code-generatorで、修正版は0.84.0です。開発者の端末やCI/CDパイプラインでも悪用されるおそれがあるため、0.84.0以降への更新を優先してください。
Affected packages
| Package | Affected → Fixed | |
|---|---|---|
| datamodel-code-generatordatamodel-code-generator |
< 0.84.0→ 0.84.0 |
0.84.0 |
Original description The description as published by the source.
datamodel-code-generator before 0.84.0 contains a code injection vulnerability that allows attackers to achieve arbitrary code execution by supplying a malicious JSON Schema with a crafted x-python-type annotation containing a string ast.Constant node in a subscript slice position, which bypasses validation in parse_python_type_annotation and _python_type_expr_from_ast. Attackers can embed malicious Python expressions such as import calls within quoted string literals in the generated source code, which Pydantic v2 evaluates as a ForwardRef via eval() during model_rebuild(), resulting in arbitrary code execution on developer workstations, CI/CD pipelines, or applications that generate and import the produced models at runtime.
Source: CVE.org (CVE Program・cvelistV5) NVD GitHub Advisory
References
- advisory github.com
- advisory vulncheck.com
- advisory nvd.nist.gov
- advisory github.com
- package github.com
- patch github.com
- web github.com