/

CVE-2026-54690

Severity:

HIGH RISK

(8.2)

SSRF via Remote JSON Schema $ref (CWE-918) in Tool

CVE-2026-54690

Analyzed

Vulnerability type

Category:

Server-Side Request Forgery (SSRF)

CWE:

CWE-918

Impact:

Server-Side Request Forgery against internal services

Severity:

HIGH RISK

(8.2)

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

datamodel-code-generator dereferences attacker-controlled JSON Schema $ref URLs over HTTP/HTTPS, enabling server-side requests from the host running the generator.

When untrusted schemas are processed, this behavior may allow an attacker to trigger server-side request forgery (SSRF) against internal services reachable from the environment where code generation occurs.

datamodel-code-generator dereferences attacker-controlled JSON Schema $ref URLs over HTTP/HTTPS, enabling server-side requests from the host running the generator.

When untrusted schemas are processed, this behavior may allow an attacker to trigger server-side request forgery (SSRF) against internal services reachable from the environment where code generation occurs.

Affected context

This vulnerability appears when datamodel-code-generator processes JSON Schemas that include $ref values pointing to external HTTP or HTTPS URLs.

It is most relevant in environments where schema input can be influenced by external users or supply-chain sources, and where the generator runs with network access to internal or cloud-metadata endpoints.

The risk increases if warnings from options like --allow-remote-refs are not treated as hard failures and if generated code is produced in CI/CD systems or backend services with broad egress permissions.

This vulnerability appears when datamodel-code-generator processes JSON Schemas that include $ref values pointing to external HTTP or HTTPS URLs.

It is most relevant in environments where schema input can be influenced by external users or supply-chain sources, and where the generator runs with network access to internal or cloud-metadata endpoints.

The risk increases if warnings from options like --allow-remote-refs are not treated as hard failures and if generated code is produced in CI/CD systems or backend services with broad egress permissions.

Exploit preconditions

  • Attack surface: JSON Schema input consumed by datamodel-code-generator (CLI, build pipelines, or automated tooling).
  • Required access: Ability to provide or modify schemas containing crafted $ref URLs, directly or via upstream specification sources.
  • Trigger point: Execution of the code generation process that dereferences $ref fields over HTTP/HTTPS.
  • Why exploitation is possible: The generator automatically follows remote $ref URLs and issues outbound HTTP requests without strict origin controls or robust blocking of remote references, enabling an attacker to pivot requests from the generator's network context.
  • Attack surface: JSON Schema input consumed by datamodel-code-generator (CLI, build pipelines, or automated tooling).
  • Required access: Ability to provide or modify schemas containing crafted $ref URLs, directly or via upstream specification sources.
  • Trigger point: Execution of the code generation process that dereferences $ref fields over HTTP/HTTPS.
  • Why exploitation is possible: The generator automatically follows remote $ref URLs and issues outbound HTTP requests without strict origin controls or robust blocking of remote references, enabling an attacker to pivot requests from the generator's network context.

Why this happens

The underlying bug is an over-trusting of remote JSON Schema references within the parsing pipeline.

By design, $ref is used to modularize schemas, but the implementation in jsonschema.py and associated HTTP utilities treats HTTP/HTTPS $ref targets as safe to fetch, even when they originate from potentially untrusted specifications.

This aligns with CWE-918: Server-Side Request Forgery (SSRF), where server-side components make network calls on behalf of user-controlled inputs, lacking adequate validation, allowlisting, or isolation of egress routes.

The underlying bug is an over-trusting of remote JSON Schema references within the parsing pipeline.

By design, $ref is used to modularize schemas, but the implementation in jsonschema.py and associated HTTP utilities treats HTTP/HTTPS $ref targets as safe to fetch, even when they originate from potentially untrusted specifications.

This aligns with CWE-918: Server-Side Request Forgery (SSRF), where server-side components make network calls on behalf of user-controlled inputs, lacking adequate validation, allowlisting, or isolation of egress routes.

Potential impact

  • The generator may issue HTTP requests to internal network services that are not directly reachable by an attacker.
  • Attackers could probe internal hostnames, ports, or paths for responsiveness via controlled $ref URLs.
  • Sensitive endpoints (such as cloud metadata services or admin APIs) could be queried, potentially leaking configuration or credential-like data depending on responses.
  • Internal service behavior and timing may be observable, enabling further attack planning or lateral movement.
  • The generator may issue HTTP requests to internal network services that are not directly reachable by an attacker.
  • Attackers could probe internal hostnames, ports, or paths for responsiveness via controlled $ref URLs.
  • Sensitive endpoints (such as cloud metadata services or admin APIs) could be queried, potentially leaking configuration or credential-like data depending on responses.
  • Internal service behavior and timing may be observable, enabling further attack planning or lateral movement.

General mitigation guidance

Mitigation generally focuses on restricting where $ref can point and how remote references are handled during schema processing.

Secure patterns include:

  • Treating all externally supplied schemas as untrusted input and enforcing strict policies that disallow or tightly constrain remote $ref URLs.
  • Implementing allowlists for permitted domains or schemes and rejecting or sandboxing any other outbound requests originating from schema resolution.
  • Running code generation in isolated environments with minimal network access, particularly avoiding connectivity to sensitive internal segments or metadata endpoints.
  • Using configuration options and internal wrappers that enforce "fail closed" behavior when remote references are encountered, rather than converting them to non-blocking warnings.

Mitigation generally focuses on restricting where $ref can point and how remote references are handled during schema processing.

Secure patterns include:

  • Treating all externally supplied schemas as untrusted input and enforcing strict policies that disallow or tightly constrain remote $ref URLs.
  • Implementing allowlists for permitted domains or schemes and rejecting or sandboxing any other outbound requests originating from schema resolution.
  • Running code generation in isolated environments with minimal network access, particularly avoiding connectivity to sensitive internal segments or metadata endpoints.
  • Using configuration options and internal wrappers that enforce "fail closed" behavior when remote references are encountered, rather than converting them to non-blocking warnings.

How teams detect issues like this

Detection efforts can focus on both configuration and runtime behavior.

Common approaches include:

  • Static review of build scripts, CI/CD pipelines, and generator configurations to identify where datamodel-code-generator processes untrusted or external schemas and whether remote $ref resolution is enabled.
  • Network monitoring and egress filtering that flags or blocks unexpected outbound HTTP requests sourced from code generation environments, especially targeting internal hostnames or known sensitive endpoints.
  • Policy-based checks in repository and pipeline tooling to ensure schema files do not contain remote $ref URLs, or that such references conform to a vetted allowlist.
  • Use of automated security scanners or linters that detect SSRF-prone patterns in infrastructure code and script-based tooling that orchestrates schema-driven code generation.

Detection efforts can focus on both configuration and runtime behavior.

Common approaches include:

  • Static review of build scripts, CI/CD pipelines, and generator configurations to identify where datamodel-code-generator processes untrusted or external schemas and whether remote $ref resolution is enabled.
  • Network monitoring and egress filtering that flags or blocks unexpected outbound HTTP requests sourced from code generation environments, especially targeting internal hostnames or known sensitive endpoints.
  • Policy-based checks in repository and pipeline tooling to ensure schema files do not contain remote $ref URLs, or that such references conform to a vetted allowlist.
  • Use of automated security scanners or linters that detect SSRF-prone patterns in infrastructure code and script-based tooling that orchestrates schema-driven code generation.

Sources

SourceLink
github.comgithub.com/koxudaxi/datamodel-code-generator/commit/5fdba4a09f2d7a9996a504975b7ef7d63e3715bb
github.comgithub.com/koxudaxi/datamodel-code-generator/releases/tag/0.61.0
github.comgithub.com/koxudaxi/datamodel-code-generator/security/advisories/GHSA-954p-556p-r752

Frequently asked

questions

Yes, if an attacker can influence the JSON Schemas consumed by datamodel-code-generator and the generator has network access, they can cause it to make HTTP/HTTPS requests from the host or environment where it runs.

They must be able to supply or modify schemas used for code generation—this could be direct file access, control over an upstream API delivering schemas, or influence in a shared specification repository consumed by build pipelines.

The most resilient pattern is to disallow remote $ref URLs in untrusted schemas, enforce strict domain allowlists for any permitted references, and ensure that code generation runs in environments with tightly constrained outbound network permissions.

Treat any tooling that issues network requests based on user-controlled configuration or specifications as a potential SSRF surface, require threat modeling for such features, enforce egress controls in CI/CD and build systems, and incorporate checks that block unsafe remote references before they reach generation tools.

Yes, if an attacker can influence the JSON Schemas consumed by datamodel-code-generator and the generator has network access, they can cause it to make HTTP/HTTPS requests from the host or environment where it runs.

They must be able to supply or modify schemas used for code generation—this could be direct file access, control over an upstream API delivering schemas, or influence in a shared specification repository consumed by build pipelines.

The most resilient pattern is to disallow remote $ref URLs in untrusted schemas, enforce strict domain allowlists for any permitted references, and ensure that code generation runs in environments with tightly constrained outbound network permissions.

Treat any tooling that issues network requests based on user-controlled configuration or specifications as a potential SSRF surface, require threat modeling for such features, enforce egress controls in CI/CD and build systems, and incorporate checks that block unsafe remote references before they reach generation tools.

Find out what's already
exploitable in your codebase.