Exploit database

GH-d1ee921774cce6efeb23697803be60ae

timthebeastnl/nginx2root

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-123007

24 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files6
timthebeastnl/nginx2rootRevision 04c245fb0433

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

nginx2root-surface.sh

Shell · 5,963 bytes
#!/usr/bin/env bash
# nginx2root-surface.sh — EXTERNAL, non-exploitative surface scan for NGINX2Root.
#
# NGINX2Root is the set of five nginx vulnerabilities fixed in the
# 18 November 2026 security release (stable 1.30.7, mainline 1.31.9):
#
#   CVE-2026-123007  HTTP/2 flow-control memory corruption (RCE, "major")
#   CVE-2026-123633  HTTP/2 use-after-free when forwarding to an upstream
#   CVE-2026-121810  HTTP/3 (QUIC) use-after-free, proxied requests
#   CVE-2026-123634  resolver use-after-free (resolver + proxy_pass var + mirror)
#   CVE-2026-113425  mail-proxy use-after-free (auth_http, "major")
#
# This script checks, from outside, what attack surface a host exposes:
#   - nginx version from the Server header (if not hidden)
#   - whether HTTP/2 is offered (ALPN "h2")       -> CVE-2026-123007 / -123633 surface
#   - whether HTTP/3 is advertised (Alt-Svc "h3")  -> CVE-2026-121810 surface
#   - whether common mail-proxy ports answer       -> CVE-2026-113425 surface
#
# CVE-2026-123634 (resolver) is config-only and NOT externally detectable; it is
# also NOT mitigated by turning HTTP/2 off. Confirm it on the host with
# nginx2root-check.sh.
#
# This script does NOT send exploit traffic and does NOT attempt to trigger any
# bug. It reports EXPOSED SURFACE, not exploitability. Only run it against hosts
# you own or are explicitly authorised to test.
#
# Usage:  ./nginx2root-surface.sh host[:port] [host2 ...]
#         ./nginx2root-surface.sh example.com example.org:8443
set -u

RED=$'\e[31m'; GRN=$'\e[32m'; YLW=$'\e[33m'; BLU=$'\e[34m'; RST=$'\e[0m'
# Disable colour when stdout is not a terminal (e.g. piped to a file/CI).
if [ ! -t 1 ]; then RED=''; GRN=''; YLW=''; BLU=''; RST=''; fi

# verlt A B  -> true (0) if version A is strictly LESS THAN version B.
verlt() {
  [ "$1" = "$2" ] && return 1
  [ "$(printf '%s\n%s' "$1" "$2" | sort -V | head -n1)" = "$1" ]
}

# is_patched VER -> true (0) if VER contains the NGINX2Root fix.
# Fixed branches: mainline >= 1.31.9, or stable 1.30.7 <= VER < 1.31.0.
is_patched() {
  local v="$1"
  if ! verlt "$v" "1.31.9"; then return 0; fi
  if ! verlt "$v" "1.30.7" && verlt "$v" "1.31.0"; then return 0; fi
  return 1
}

scan() {
  local target="$1" host port
  host="${target%%:*}"; port="${target##*:}"; [ "$port" = "$host" ] && port=443
  printf '\n%s== %s:%s ==%s\n' "$BLU" "$host" "$port" "$RST"

  # --- Server header / version ---------------------------------------------
  local hdr server ver
  hdr="$(curl -sS -m 10 -I -k "https://$host:$port/" 2>/dev/null)"
  if [ -z "$hdr" ]; then
    hdr="$(curl -sS -m 10 -I "http://$host/" 2>/dev/null)"
  fi
  server="$(printf '%s' "$hdr" | grep -i '^server:' | head -n1 | tr -d '\r' | cut -d' ' -f2-)"
  ver="$(printf '%s' "$server" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -n1)"

  if [ -z "$server" ]; then
    printf '%s[?]%s  No Server header returned (host down, filtered, or header stripped).\n' "$YLW" "$RST"
  else
    printf '  Server: %s\n' "$server"
    if [ -z "$ver" ]; then
      printf '%s[?]%s  Version hidden (server_tokens off or fronted by proxy/CDN). Confirm on the host itself.\n' "$YLW" "$RST"
    elif is_patched "$ver"; then
      printf '%s[ OK ]%s   nginx %s is a patched build (>= 1.31.9 mainline, or 1.30.7+ stable).\n' "$GRN" "$RST" "$ver"
    else
      printf '%s[EXPOSED]%s  nginx %s predates the NGINX2Root fix. Fixed: 1.30.7 (stable) / 1.31.9 (mainline).\n' "$RED" "$RST" "$ver"
    fi
  fi

  # --- HTTP/2 via ALPN ------------------------------------------------------
  local alpn
  if command -v openssl >/dev/null 2>&1; then
    alpn="$(printf 'Q' | timeout 10 openssl s_client -connect "$host:$port" -alpn h2 -servername "$host" 2>/dev/null | grep -i 'ALPN protocol')"
    if printf '%s' "$alpn" | grep -qi 'h2'; then
      printf '%s[EXPOSED]%s  HTTP/2 negotiated (ALPN h2) -> CVE-2026-123007 (core RCE) surface; -123633 if it proxies upstream.\n' "$RED" "$RST"
    elif curl -sS -m 10 -k -o /dev/null -w '%{http_version}' --http2 "https://$host:$port/" 2>/dev/null | grep -q '^2'; then
      printf '%s[EXPOSED]%s  HTTP/2 negotiated (curl) -> CVE-2026-123007 surface.\n' "$RED" "$RST"
    else
      printf '%s[ OK ]%s   HTTP/2 not offered.\n' "$GRN" "$RST"
    fi
  else
    printf '%s[?]%s  openssl not found; skipping ALPN check.\n' "$YLW" "$RST"
  fi

  # --- HTTP/3 via Alt-Svc ---------------------------------------------------
  if printf '%s' "$hdr" | grep -i '^alt-svc:' | grep -qi 'h3'; then
    printf '%s[EXPOSED]%s  Alt-Svc advertises h3 -> CVE-2026-121810 surface (HTTP/3 upstream).\n' "$RED" "$RST"
  else
    printf '%s[ OK ]%s   No HTTP/3 (h3) advertised in Alt-Svc (may still be enabled without advertising).\n' "$GRN" "$RST"
  fi

  # --- mail-proxy ports -----------------------------------------------------
  local p open=""
  for p in 25 465 587 143 993 110 995; do
    if timeout 3 bash -c "exec 3<>/dev/tcp/$host/$p" 2>/dev/null; then
      open="$open $p"; exec 3>&- 2>/dev/null
    fi
  done
  if [ -n "$open" ]; then
    printf '%s[WARN]%s   Mail ports reachable:%s -> if nginx mail proxy (proxy on + auth_http) sits here, CVE-2026-113425 surface. Verify on host.\n' "$YLW" "$RST" "$open"
  else
    printf '%s[ OK ]%s   No common mail-proxy ports reachable.\n' "$GRN" "$RST"
  fi
}

# Run the scan loop only when executed directly. When this file is sourced
# (e.g. by the test suite) the functions above load without side effects.
if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
  [ $# -ge 1 ] || { echo "usage: $0 host[:port] [host ...]"; exit 2; }
  for t in "$@"; do scan "$t"; done
  printf '\n%sNotes:%s\n' "$BLU" "$RST"
  printf '  - Surface != exploitability. A patched build or a fronting proxy/CDN can still show open ports/protocols.\n'
  printf '  - CVE-2026-123634 (resolver) is config-only, NOT shown here, and NOT fixed by disabling HTTP/2.\n'
  printf '  - Run nginx2root-check.sh on the host itself to confirm the exact package version and config.\n'
fi