# \`datamodel-code-generator\` vulnerable to code injection in via attacker-controlled \`default_factory\` schema field

Advisory record · `GHSA-386q-5hp3-95m9`

- **Identifiers:** `GHSA-386q-5hp3-95m9` · `CVE-2026-54653` · `PYSEC-2026-3555`
- **State:** Confirmed
- **Severity:** CVSS 8.8 High
- **Critical:** No
- **Weakness (CWE):** [CWE-94](https://cwe.mitre.org/data/definitions/94.html) · [CWE-1336](https://cwe.mitre.org/data/definitions/1336.html)
- **Tags:** [Code injection](https://agentprime.io/advisories/tag/code-injection.md)
- **Published:** 28 Jul 2026
- **Updated:** 10 Sept 2026
- **Reviewed by a person:** No

Published by the GitHub Advisory Database at 28 Jul 2026, 21:48 UTC. agentprime has not analysed this yet, so whether it affects any app is not known.

## Affected packages

- `datamodel-code-generator` (PyPI): affected `>=0.17.0, <0.60.2`; fixed in `0.60.2`

## Machine-written summary

Summary written by Claude Haiku from the source advisory. Not reviewed by a person.

> Versions 0.17.0 up to but not including 0.60.2 of datamodel-code-generator are affected. When a schema property includes a default_factory key, its value is inserted unchanged into the generated Python code, so an attacker who supplies a malicious schema can run arbitrary Python when the generated module is imported. No special flags are needed, though choosing the typing.TypedDict output model type avoids the issue. Upgrade to datamodel-code-generator 0.60.2 or later.

Written 1 Nov 2026.

## Not analysed yet

We haven’t published our analysis of this Advisory yet. Once a person has reviewed it, this page will say what’s vulnerable, what has to be true for your app to be affected, and how to check.

## Severity and exploitation

- 8.8 High, CVSS 3.1: `CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H`, from CNA (GitHub_M)

- **CISA KEV:** Not listed.
- **EPSS:** 0.0071, the 54th percentile, on 13 Nov 2026: FIRST’s estimate of the chance of exploitation in the next 30 days.

## Timeline

- 31 Oct 2026, 14:11 UTC: First seen by agentprime
- 31 Oct 2026, 14:11 UTC: [Confirmed by OSV](https://osv.dev/vulnerability/GHSA-386q-5hp3-95m9)

## Sources

- [GitHub Advisory Database: GHSA-386q-5hp3-95m9](https://github.com/advisories/GHSA-386q-5hp3-95m9)
- [OSV: GHSA-386q-5hp3-95m9](https://osv.dev/vulnerability/GHSA-386q-5hp3-95m9)
- <https://github.com/koxudaxi/datamodel-code-generator/security/advisories/GHSA-386q-5hp3-95m9>
- <https://github.com/koxudaxi/datamodel-code-generator/commit/17fc235e234cbcfaaadef8c74cb72c9687db0d1d>
- <https://github.com/koxudaxi/datamodel-code-generator>
- <https://github.com/koxudaxi/datamodel-code-generator/releases/tag/0.60.2>

Facts on this page come from the GitHub Advisory Database (CC-BY 4.0), OSV and the other sources listed, as published. We don’t reproduce full advisory descriptions, which can contain exploit code.

## Check whether this affects you

A Match means an installed version is in the affected range above. Most don’t affect the app; agentprime hasn’t analysed this one yet.

- With the agentprime MCP server (<https://api.agentprime.io/mcp>), ask your agent to check the project: `check_lockfile` sends a lockfile, `check_packages` a list of installed packages, and both return the Matches and the upgrades that clear them. `get_advisory` returns this record. Setup: <https://agentprime.io/mcp.md>
- In a browser: <https://agentprime.io/check/> reads your lockfile in the browser, never uploading it.
- Whether it touches your code, with file and line: the Claude Code plugin, <https://agentprime.io/plugin.md>
- As JSON: <https://api.agentprime.io/v1/advisories/GHSA-386q-5hp3-95m9>, or `POST https://api.agentprime.io/v1/match` with your packages (<https://agentprime.io/api.md>)

---

The web page: <https://agentprime.io/advisories/GHSA-386q-5hp3-95m9/>. Everything for agents: <https://agentprime.io/llms.txt>.
