CVE-2026-55391: Server-Side Request Forgery Bypass via DNS Rebinding in datamodel-code-generator
Vulnerability ID: CVE-2026-55391
CVSS Score: 7.5
Published: 2026-07-28
CVE-2026-55391 is a server-side request forgery (SSRF) bypass vulnerability in the datamodel-code-generator package. The vulnerability occurs due to a Time-of-Check to Time-of-Use (TOCTOU) race condition during DNS resolution, combined with a failure to inspect embedded IPv4-in-IPv6 address mappings. By deploying a malicious DNS server with a low Time-To-Live (TTL) configuration, an attacker can bypass private address blocklists and coerce the application to connect to internal services or local endpoints.
TL;DR
A Time-of-Check to Time-of-Use (TOCTOU) DNS vulnerability in datamodel-code-generator allows remote attackers to bypass SSRF protections using DNS rebinding or IPv6-mapped IPv4 addresses, exposing internal networks.
⚠️ Exploit Status: POC
Technical Details
- CWE ID: CWE-918 (SSRF), CWE-367 (TOCTOU)
- Attack Vector: Network
- Attack Complexity: High
- CVSS v3.1 Score: 7.5
- Exploit Status: Proof-of-Concept
- CISA KEV Status: Not Listed
Affected Systems
- datamodel-code-generator python package
-
datamodel-code-generator: >= 0.50.0, < 0.63.0 (Fixed in:
0.63.0)
Code Analysis
Commit: 25c8b7e
Implement socket-level DNS pinning and embedded IPv4 unwrapping in fetch modules.
--- a/src/datamodel_code_generator/http.py
+++ b/src/datamodel_code_generator/http.py
@@ -8,24 +8,119 @@
-def _get_httpx() -> Any:
+def _get_httpx() -> _HTTPXModule:
+class _PinnedNetworkBackend:
+ def connect_tcp(...) -> httpcore.NetworkStream:
+ if _normalize_dns_host(host) != self._pinned_host:
+ raise OSError(...)
+ for ip in self._pinned_ips:
+ return self._backend.connect_tcp(str(ip), ...)
Mitigation Strategies
- Implement DNS pinning at the socket or transport layer to prevent independent DNS resolution passes.
- Unwrap IPv6-encapsulated IPv4 configurations to detect hidden private addresses.
- Use isolated container networks with egress rules to block private IP space connections.
Remediation Steps:
- Update the datamodel-code-generator dependency to version 0.63.0 or greater.
- Ensure validation protocols explicitly block legacy IP notations and IPv6 mapping formats.
- Configure cloud host firewalls to restrict local loopback and metadata access from worker environments.
References
Read the full report for CVE-2026-55391 on our website for more details including interactive diagrams and full exploit analysis.
Top comments (0)