{"id":"CVE-2026-127208","kind":"vulnerability","aliases":["CVE-2026-127208"],"related":[],"title":"datamodel-code-generator: crafted JSON Schema runs code on generating machines","description":"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.","summary":"datamodel-code-generator before 0.84.0 fails to validate the x-python-type annotation in a JSON Schema, so a malicious schema can put Python expressions into generated models. When Pydantic v2 evaluates those strings during model_rebuild(), the attacker's code runs on the developer workstation, CI pipeline, or application that imports the models.","severity":"high","cvss":8.8,"epss":null,"exploited":false,"exploited_at":null,"products":[],"ecosystems":[],"tags":["ci-cd","datamodel-code-generator","package","pydantic","python"],"not_affected_if":["no-runtime-model-import","trusted-schemas-only"],"how_to_check":"- Check the installed version with `datamodel-code-generator --version` or `pip show datamodel-code-generator`.\n- Search your project for any JSON Schema input from untrusted sources that uses `x-python-type`.\n- Check whether generated models are imported at runtime with Pydantic v2 `model_rebuild()`.","fix":"- datamodel-code-generator: move to `0.84.0` or later.","status":"open","published_at":"2026-11-12T21:17:22+00:00","first_seen_at":"2026-11-12T21:40:31+00:00","triaged_at":"2026-11-12T21:42:21+00:00","updated_at":"2026-11-12T21:42:21+00:00","category":"package","confidence":0.8,"triage":{"at":"2026-11-12T21:42:21Z","model":"claude-haiku-5-5","output":{"fix":"- datamodel-code-generator: move to `0.84.0` or later.","reach":"unknown","title":"datamodel-code-generator: crafted JSON Schema runs code on generating machines","impact":"high","summary":"datamodel-code-generator before 0.84.0 fails to validate the x-python-type annotation in a JSON Schema, so a malicious schema can put Python expressions into generated models. When Pydantic v2 evaluates those strings during model_rebuild(), the attacker's code runs on the developer workstation, CI pipeline, or application that imports the models.","audience":"developers","category":"package","nicknames":[],"who_cares":["python","pydantic","datamodel-code-generator","ci-cd"],"confidence":0.8,"fix_status":"available","needs_auth":"no","worst_case":"Arbitrary code runs on developer workstations and CI runners.","analyst_note":"","how_to_check":"- Check the installed version with `datamodel-code-generator --version` or `pip show datamodel-code-generator`.\n- Search your project for any JSON Schema input from untrusted sources that uses `x-python-type`.\n- Check whether generated models are imported at runtime with Pydantic v2 `model_rebuild()`.","plain_action":"","product_name":"","needs_analyst":false,"not_affected_if":["trusted-schemas-only","no-runtime-model-import"],"who_is_affected":"Any team that runs datamodel-code-generator on JSON Schemas it does not fully control, or imports the generated models at runtime with Pydantic v2. Teams that only generate models from their own trusted schemas, in a sealed build, are less exposed but should still upgrade. The sources do not say whether a default configuration is exposed.","user_interaction":"yes","product_ecosystem":"","needs_special_setup":"unknown","severity_if_unknown":"high"},"cost_usd":0.000786,"input_tokens":4744,"output_tokens":623,"severity_before":"high"},"analyst_status":null,"analyst_note":null,"search":"'-127208':15A,18A '-2026':14A,17A '0.84.0':34B,90C 'achiev':100C 'allow':97C 'annot':43B,117C,135C 'applic':80B,184C 'arbitrari':101C,175C 'ast':141C 'ast.constant':121C 'attack':69B,98C,142C 'bypass':129C 'call':151C 'cd':21B 'ci':20B,77B 'ci-cd':19B 'ci/cd':181C 'code':3A,9A,24B,31B,71B,87C,93C,102C,160C,176C 'contain':91C,118C 'craft':5A,112C 'cve':13A,16A 'datamodel':2A,23B,30B,86C 'datamodel-code-gener':1A,22B,29B,85C 'develop':75B,179C 'emb':144C 'eval':169C 'evalu':62B,164C 'execut':103C,177C 'expr':139C 'express':55B,147C 'fail':35B 'forwardref':167C 'generat':4A,11A,25B,32B,57B,88C,158C,186C 'import':82B,150C,188C 'inject':94C 'json':6A,46B,108C 'liter':155C 'machin':12A 'malici':50B,107C,145C 'model':58B,66B,84B,171C,191C 'node':122C 'packag':26B 'pars':132C 'pipelin':78B,182C 'posit':127C 'produc':190C 'put':53B 'pydant':27B,60B,162C 'python':28B,41B,54B,115C,133C,137C,146C 'quot':153C 'rebuild':67B,172C 'result':173C 'run':8A,72B 'runtim':193C 'schema':7A,47B,51B,109C 'slice':126C 'sourc':159C 'string':64B,120C,154C 'subscript':125C 'suppli':105C 'type':42B,116C,134C,138C 'v2':61B,163C 'valid':37B,130C 'via':168C 'vulner':95C 'within':152C 'workstat':76B,180C 'x':40B,114C 'x-python-typ':39B,113C","nicknames":[],"mitigations":[],"who_affected":"Any team that runs datamodel-code-generator on JSON Schemas it does not fully control, or imports the generated models at runtime with Pydantic v2. Teams that only generate models from their own trusted schemas, in a sealed build, are less exposed but should still upgrade. The sources do not say whether a default configuration is exposed.","tier":"B","verified":{},"analyst_revisit_at":null,"fix_status":"available","audience":"developers","plain_action":null,"pkeys":[],"ptokens":[],"labels":["cicd","datamodelcodegenerator","high","package","pydantic","python"],"campaign_type":null,"search_a":"'-127208':15A,18A '-2026':14A,17A 'code':3A,9A 'craft':5A 'cve':13A,16A 'datamodel':2A 'datamodel-code-gener':1A 'generat':4A,11A 'json':6A 'machin':12A 'run':8A 'schema':7A","search_b":"'0.84.0':34B 'annot':43B 'applic':80B 'attack':69B 'cd':21B 'ci':20B,77B 'ci-cd':19B 'code':24B,31B,71B 'datamodel':23B,30B 'datamodel-code-gener':22B,29B 'develop':75B 'evalu':62B 'express':55B 'fail':35B 'generat':25B,32B,57B 'import':82B 'json':46B 'malici':50B 'model':58B,66B,84B 'packag':26B 'pipelin':78B 'put':53B 'pydant':27B,60B 'python':28B,41B,54B 'rebuild':67B 'run':72B 'schema':47B,51B 'string':64B 'type':42B 'v2':61B 'valid':37B 'workstat':76B 'x':40B 'x-python-typ':39B","search_c":"'0.84.0':90C 'achiev':100C 'allow':97C 'annot':117C,135C 'applic':184C 'arbitrari':101C,175C 'ast':141C 'ast.constant':121C 'attack':98C,142C 'bypass':129C 'call':151C 'ci/cd':181C 'code':87C,93C,102C,160C,176C 'contain':91C,118C 'craft':112C 'datamodel':86C 'datamodel-code-gener':85C 'develop':179C 'emb':144C 'eval':169C 'evalu':164C 'execut':103C,177C 'expr':139C 'express':147C 'forwardref':167C 'generat':88C,158C,186C 'import':150C,188C 'inject':94C 'json':108C 'liter':155C 'malici':107C,145C 'model':171C,191C 'node':122C 'pars':132C 'pipelin':182C 'posit':127C 'produc':190C 'pydant':162C 'python':115C,133C,137C,146C 'quot':153C 'rebuild':172C 'result':173C 'runtim':193C 'schema':109C 'slice':126C 'sourc':159C 'string':120C,154C 'subscript':125C 'suppli':105C 'type':116C,134C,138C 'v2':163C 'valid':130C 'via':168C 'vulner':95C 'within':152C 'workstat':180C 'x':114C 'x-python-typ':113C","cause_entry":null,"cause_path":null,"disclosures_checked_at":null,"first_public_at":"2026-11-12T21:17:22+00:00","kev":null,"cvss_vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:A/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X","cvss_by":"disclosure@vulncheck.com","poc_count":0,"sources":[{"source":"nvd","external_id":"CVE-2026-127208","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-127208","severity":null,"published_at":"2026-11-12T21:17:22+00:00","modified_at":"2026-11-12T21:17:23+00:00","first_seen_at":"2026-11-12T21:40:31+00:00","fetched_at":"2026-11-12T21:40:31+00:00","note":null}],"documents":[{"id":139272,"url":"https://github.com/datamodel-code-generator/datamodel-code-generator/commit/ebfc11d0644d37a71374b28aac06d98748e584ec","title":"Patch: github.com","kind":"other","source":"nvd","publisher":"vendor","text":null,"published_at":null,"relation":"fix","confidence":null,"note":"Patch: github.com"},{"id":139273,"url":"https://github.com/datamodel-code-generator/datamodel-code-generator/releases/tag/0.84.0","title":"Release notes: github.com","kind":"release","source":"nvd","publisher":"vendor","text":null,"published_at":null,"relation":"fix","confidence":null,"note":"Release notes: github.com"},{"id":139274,"url":"https://www.vulncheck.com/advisories/datamodel-code-generator-code-injection-via-x-python-type-annotation","title":"Third-party advisory: www.vulncheck.com","kind":"advisory","source":"nvd","publisher":"research","text":null,"published_at":null,"relation":"advisory","confidence":null,"note":"Third-party advisory: www.vulncheck.com"}],"disclosures":[],"exploit_sources":[],"notice":"Free to read, with fair use of about 60 pages a minute. For higher limits or API access: sales@infrastack.ai"}