Skip to content

GHSA-cmhj-wh2f-9cgx CVE-2026-56676

9router: Image prefetch DNS rebinding allows SSRF to internal services

High npm
Severity
7.4 / 10
High · CVSS 3.1
Exploit chance (EPSS)
0.19%
Chance of exploitation in the next 30 days. Higher than 8.64% of scored vulnerabilities.
Known exploited
No
Not in CISA's catalog
Weakness
CWE-367 Time-of-check Time-of-use (TOCTOU) Race Condition
CWE-918 Server-Side Request Forgery (SSRF)
Fix
0.5.2
Upgrade 9router to this version or later

Description

Summary

9router validates image URLs by resolving the host before fetching, but the later server-side fetch performs a separate DNS resolution. An attacker-controlled DNS name can resolve to a public IP during validation and then rebind to an internal Docker/private IP during the fetch. This allows the server-side image prefetch to reach internal-only HTTP services (SSRF).

Details

  • Affected version / commit: 9router v0.4.80 @ b282f05.
  • Reachable through /v1/chat/completions with a vision-capable model and an image_url content part. A vision-capable model name is required so the image survives modality stripping and the server-side prefetch is armed.
  • The provider used in this reproduction is the bundled mock provider — no real API key and no real provider call.
  • internal-admin (the SSRF target) is not exposed to the host network; it is reachable only from inside the Docker network.
  • rebind-dns behaviour for rebind.9r.test:
    • first A response → 1.1.1.1 (public) to pass the public-host guard,
    • second A response → 172.29.0.10 (internal-admin) during the fetch.
  • internal-admin logs GET /ssrf-marker with peer=172.29.0.30 (the proxied-router container), proving the server-side fetch landed on the internal service.
  • mock-provider receives POST /api/chat and the flow completes with HTTP 200.
  • Root cause: DNS TOCTOU — the IP is not pinned between the validation resolution (the public-host guard) and the fetch resolution. The guard and the fetch each resolve the hostname independently, so a TTL-0 rebinding authority can return a public IP to the guard and an internal IP to the fetch.

Proof of Concept

This repository is a self-contained Docker Compose reproduction. No real provider is called and no real API key is required.

  1. Build and start the stack:
    docker compose up --build
    
  2. Confirm internal-admin is unreachable from the host:
    curl -i http://127.0.0.1:18083/ssrf-marker   # connection refused / fail
    docker compose ps                            # internal-admin has NO host port mapping
    
  3. Send the request named POST image-prefetch DNS rebinding trigger from requests.http, or with curl:
    curl -i -X POST http://127.0.0.1:18082/v1/chat/completions \
      -H "Content-Type: application/json" \
      -d '{
        "model": "ollama-local/gemma3",
        "messages": [{"role":"user","content":[
          {"type":"text","text":"reproduction image-prefetch trigger"},
          {"type":"image_url","image_url":{"url":"http://rebind.9r.test:8080/ssrf-marker?case=rebind-trigger"}}
        ]}],
        "stream": false
      }'
    

Impact

  • SSRF to internal HTTP services reachable from the 9router host/container.
  • Depending on the environment, this can reach cloud metadata endpoints, internal admin panels, or be used for internal service discovery.
  • Blind / semi-blind SSRF when the fetched response is not returned to the attacker; an exfil variant (pointing the image at an internal endpoint that returns valid image bytes) can return internal content base64-encoded to the upstream.
  • Requires a code path that prefetches/normalizes remote images for vision-capable providers.
  • No real credential is needed for the reproduction.

Suggested Fix

  • Pin the resolved IP after validation and connect to that IP (resolve once, then reuse the address for the fetch).
  • Block private, loopback, link-local, multicast, and cloud-metadata ranges at connect time, not only at validation time.
  • Perform DNS resolution and IP checks immediately before the request and against the address actually used to connect.
  • Disable redirects, or re-validate every redirect target with the same checks.
  • Enforce an allowlist for image-fetch domains where feasible.
  • Add a timeout, a response size limit, and a content-type check.

Affected versions

npm

PackageVulnerableFixed in
9router
< 0.5.2
0.5.2

How to fix

Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.

9router npm → 0.5.2

npm
npm install 9router@0.5.2
yarn
yarn add 9router@0.5.2
pnpm
pnpm add 9router@0.5.2

Severity breakdown

CVSS 3.1 7.4

CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:L

Attack vector
Network
Attack complexity
Low
Privileges required
Low
User interaction
None
Scope
Changed
Confidentiality
Low
Integrity
Low
Availability
Low

Weakness

CWE-367: Time-of-check Time-of-use (TOCTOU) Race Condition

The product checks the state of a resource before using that resource, but the resource's state can change between the check and the use in a way that invalidates the results of the check.

How to prevent it
  • Implementation: The most basic advice for TOCTOU vulnerabilities is to not perform a check before the use. This does not resolve the underlying issue of the execution of a function on a resource whose state and identity cannot be assured, but it does help to limit the false sense of security given by the check.
  • Implementation: When the file being altered is owned by the current user and group, set the effective gid and uid to that of the current user and group when executing this statement.
  • Architecture and Design: Limit the interleaving of operations on files from multiple processes.
  • Implementation, Architecture and Design: If you cannot perform operations atomically and you must share access to the resource between multiple processes or threads, then try to limit the amount of time (CPU cycles) between the check and use of the resource. This will not fix the problem, but it could make it more difficult for an attack to succeed.
  • Implementation: Recheck the resource after the use call to verify that the action was taken appropriately.
  • Architecture and Design: Ensure that some environmental locking mechanism can be used to protect resources effectively.
  • Implementation: Ensure that locking occurs before the check, as opposed to afterwards, such that the resource, as checked, is the same as it is when in use.

CWE-918: Server-Side Request Forgery (SSRF)

The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.

References

Timeline

  1. Published
  2. Last updated by the source
  3. Latest EPSS score
AdvisorySeverityWhy it's related
GHSA-32gc-64m7-hj7v
9Router has a Login Brute-Force Lockout Bypass via Spoofable X-9r-Real-Ip Header
Medium Also affects 9router
GHSA-5mj8-gf6m-fhw8
9Router has an Authentication Bypass in Public LLM API via Spoofable X-9r-Real-Ip Header
High Also affects 9router
GHSA-8g4w-4ffg-8vgx
9Router: Authenticated Server-Side Request Forgery (SSRF) via OIDC Provider Test Endpoint
High Also affects 9router
GHSA-vmjq-hvgq-2wv4
9router: Mass assignment in PATCH /api/settings allows authenticated authorization downgrade
High Also affects 9router
GHSA-6mwv-4mrm-5p3m
9router: Kiro region injection allows authenticated SSRF with Authorization header forwarding
Medium Also affects 9router
GHSA-x5c9-v98j-722r
9router /v1 APIs has unauthenticated access via reverse proxy locality collapse
High Also affects 9router
GHSA-86m2-fcxq-5q7c
9router: Unauthenticated `/v1` proxy access via `Host`-header spoofing → open AI relay + SSRF
High Also affects 9router
GHSA-8gmq-j984-vp4r
9router: Unauthenticated LLM proxy access via /codex rewrite authorization bypass
High Also affects 9router
Is this in your code?

MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.

Check your repos with MergeHarbor