/

CVE-2026-55391

Severity:

HIGH RISK

(7.5)

DNS Rebinding SSRF (CWE-918) in datamodel-code-generator

CVE-2026-55391

Analyzed

Vulnerability type

Category:

Server-Side Request Forgery (SSRF)

CWE:

CWE-350, CWE-367, CWE-918

Impact:

Access to internal network resources via SSRF

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A DNS rebinding flaw in datamodel-code-generator allows attackers to bypass URL host validation and reach internal services despite allow_private_network=False.

When the tool fetches remote schemas or documents over HTTP, an attacker-controlled domain can be used to pivot requests from public hosts to private network targets.

A DNS rebinding flaw in datamodel-code-generator allows attackers to bypass URL host validation and reach internal services despite allow_private_network=False.

When the tool fetches remote schemas or documents over HTTP, an attacker-controlled domain can be used to pivot requests from public hosts to private network targets.

Affected context

This vulnerability affects environments where datamodel-code-generator is used to fetch remote inputs (OpenAPI specs, JSON Schema, GraphQL schemas, etc.) over HTTP.

It becomes relevant when:

  • The tool is allowed to make outbound HTTP requests to user-specified URLs
  • allow_private_network=False is relied upon to block access to internal addresses
  • DNS resolution for the target host can be influenced by an attacker (e.g., attacker-controlled domains)

This vulnerability affects environments where datamodel-code-generator is used to fetch remote inputs (OpenAPI specs, JSON Schema, GraphQL schemas, etc.) over HTTP.

It becomes relevant when:

  • The tool is allowed to make outbound HTTP requests to user-specified URLs
  • allow_private_network=False is relied upon to block access to internal addresses
  • DNS resolution for the target host can be influenced by an attacker (e.g., attacker-controlled domains)

Exploit preconditions

  • Attack surface: HTTP-based schema/document fetching in datamodel-code-generator.
  • Required access: Ability to supply or influence the URL that datamodel-code-generator uses for fetching remote content.
  • Trigger point: The HTTP request issued by the internal httpx client after the initial host validation step.
  • Why exploitation is possible: The host is validated once using one resolution path, but httpx performs a separate DNS resolution at connection time. An attacker can leverage DNS rebinding to present a benign public IP during validation and then rebind the domain to an internal IP when the actual HTTP request is sent, bypassing allow_private_network=False.
  • Attack surface: HTTP-based schema/document fetching in datamodel-code-generator.
  • Required access: Ability to supply or influence the URL that datamodel-code-generator uses for fetching remote content.
  • Trigger point: The HTTP request issued by the internal httpx client after the initial host validation step.
  • Why exploitation is possible: The host is validated once using one resolution path, but httpx performs a separate DNS resolution at connection time. An attacker can leverage DNS rebinding to present a benign public IP during validation and then rebind the domain to an internal IP when the actual HTTP request is sent, bypassing allow_private_network=False.

Why this happens

The underlying bug is a mismatch between the security validation logic and the actual network resolution path.

datamodel-code-generator validates the URL host and checks IPs against private network rules using custom DNS resolution, but later delegates the connection to httpx, which performs its own host resolution.

This separation enables CWE-350: Reliance on DNS for Security and CWE-367: Time-of-check Time-of-use (TOCTOU) conditions, where the trusted result of a prior DNS lookup is no longer valid at the time of use.

The behavior manifests as CWE-918: Server-Side Request Forgery (SSRF) because an attacker can steer the tool into making HTTP requests to internal network services by manipulating DNS responses.

The underlying bug is a mismatch between the security validation logic and the actual network resolution path.

datamodel-code-generator validates the URL host and checks IPs against private network rules using custom DNS resolution, but later delegates the connection to httpx, which performs its own host resolution.

This separation enables CWE-350: Reliance on DNS for Security and CWE-367: Time-of-check Time-of-use (TOCTOU) conditions, where the trusted result of a prior DNS lookup is no longer valid at the time of use.

The behavior manifests as CWE-918: Server-Side Request Forgery (SSRF) because an attacker can steer the tool into making HTTP requests to internal network services by manipulating DNS responses.

Potential impact

  • May allow access to internal HTTP services that should not be reachable from the tool.
  • Could enable enumeration or probing of internal APIs and metadata endpoints.
  • Can expose sensitive configuration or schema data hosted on private services.
  • May facilitate further compromise if internal services trust the calling environment or lack authentication.
  • May allow access to internal HTTP services that should not be reachable from the tool.
  • Could enable enumeration or probing of internal APIs and metadata endpoints.
  • Can expose sensitive configuration or schema data hosted on private services.
  • May facilitate further compromise if internal services trust the calling environment or lack authentication.

General mitigation guidance

Effective mitigation focuses on aligning host validation with the actual network connections and reducing trust in DNS for enforcing security boundaries.

Common defensive patterns include:

  • Ensuring that the same resolved IPs used for security checks are also used for the outbound HTTP connections (e.g., binding connections to pre-resolved addresses).
  • Applying strict IP-based allow/deny logic rather than relying solely on hostname checks for private network protection.
  • Isolating schema/document fetching into a sandboxed environment with no access to sensitive internal networks.
  • Restricting or pre-approving remote URLs that the tool is allowed to access, instead of accepting arbitrary user-supplied endpoints.
  • Applying least-privilege principles to network egress for tools that perform automatic HTTP fetches.

Effective mitigation focuses on aligning host validation with the actual network connections and reducing trust in DNS for enforcing security boundaries.

Common defensive patterns include:

  • Ensuring that the same resolved IPs used for security checks are also used for the outbound HTTP connections (e.g., binding connections to pre-resolved addresses).
  • Applying strict IP-based allow/deny logic rather than relying solely on hostname checks for private network protection.
  • Isolating schema/document fetching into a sandboxed environment with no access to sensitive internal networks.
  • Restricting or pre-approving remote URLs that the tool is allowed to access, instead of accepting arbitrary user-supplied endpoints.
  • Applying least-privilege principles to network egress for tools that perform automatic HTTP fetches.

How teams detect issues like this

Detection typically involves examining how network requests are validated and executed within the codebase.

Helpful strategies include:

  • Static analysis rules that flag separate validation and connection resolution paths, especially when different libraries handle each step.
  • Code review focused on SSRF patterns: user-controlled URLs, indirect access to internal hosts, and reliance on DNS checks for security decisions.
  • Policy-based checks ensuring that tools performing remote fetches do not have unrestricted access to internal network ranges.
  • Runtime monitoring that alerts when developer tools or code generators attempt to connect to private IP ranges or sensitive internal endpoints.

Detection typically involves examining how network requests are validated and executed within the codebase.

Helpful strategies include:

  • Static analysis rules that flag separate validation and connection resolution paths, especially when different libraries handle each step.
  • Code review focused on SSRF patterns: user-controlled URLs, indirect access to internal hosts, and reliance on DNS checks for security decisions.
  • Policy-based checks ensuring that tools performing remote fetches do not have unrestricted access to internal network ranges.
  • Runtime monitoring that alerts when developer tools or code generators attempt to connect to private IP ranges or sensitive internal endpoints.

Sources

SourceLink
github.comgithub.com/koxudaxi/datamodel-code-generator/commit/25c8b7e497419eb20b230fa3318c04f9bebc5a6f
github.comgithub.com/koxudaxi/datamodel-code-generator/releases/tag/0.63.0
github.comgithub.com/koxudaxi/datamodel-code-generator/security/advisories/GHSA-vx7x-vcc2-c44g
gist.github.comgist.github.com/thegr1ffyn/c1d54dd6ff2a4c0d7d0dabe00c4985f4

Frequently asked

questions

Yes, if an attacker can supply or influence the URL that datamodel-code-generator uses to fetch remote content. They do not need direct access to the internal network; they leverage the tool as a proxy.

It depends on how the tool is integrated. If only authenticated users can trigger remote fetches, then attacker access to that interface is required. In CI pipelines or automated workflows, any party that can modify configuration or inputs may be able to exploit it.

The safest pattern is to ensure that host/IP validation and network connections share the same resolution outcome, and to treat DNS results as untrusted. Binding the outbound connection to pre-validated IPs and enforcing strict private-network blocking are key approaches.

Design network-facing features so that user-controlled URLs are tightly constrained, avoid using DNS as a sole security control, apply IP-based allow/deny policies, and include SSRF-focused checks in code review and automated security testing for any component that issues HTTP requests on behalf of users.

Yes, if an attacker can supply or influence the URL that datamodel-code-generator uses to fetch remote content. They do not need direct access to the internal network; they leverage the tool as a proxy.

It depends on how the tool is integrated. If only authenticated users can trigger remote fetches, then attacker access to that interface is required. In CI pipelines or automated workflows, any party that can modify configuration or inputs may be able to exploit it.

The safest pattern is to ensure that host/IP validation and network connections share the same resolution outcome, and to treat DNS results as untrusted. Binding the outbound connection to pre-validated IPs and enforcing strict private-network blocking are key approaches.

Design network-facing features so that user-controlled URLs are tightly constrained, avoid using DNS as a sole security control, apply IP-based allow/deny policies, and include SSRF-focused checks in code review and automated security testing for any component that issues HTTP requests on behalf of users.

Find out what's already
exploitable in your codebase.