Skip to content

nginx2root: detectors for the five nginx CVEs fixed in 1.31.9 / 1.30.7 - #9

Closed
diptendukar wants to merge 2 commits into
semgrep:mainfrom
diptendukar:nginx2root-detectors
Closed

diptendukar wants to merge 2 commits into
semgrep:mainfrom
diptendukar:nginx2root-detectors

Conversation

@diptendukar

@diptendukar diptendukar commented Nov 18, 2026 •

Copy link
Copy Markdown

Host and fleet detectors for the five nginx bugs disclosed on 2026-11-18 as "nginx2root" and fixed in nginx 1.31.9 and 1.30.7 (nginx.org advisories).

What it does

Run one script on a host and it tells you, for every nginx it finds, whether that nginx is exposed to each of the five CVEs, and why.

  • Finds every running nginx, including nginx inside containers, and every nginx installed on disk. OpenResty, Tengine and Angie are recognised too.
  • For each one, checks three things per CVE: is the version affected, has the package been patched, and does the configuration switch the vulnerable feature on.
  • Prints a status for each CVE (impacted, not impacted or unknown) with the reason, then one line per CVE for the whole host and an overall verdict.
  • Returns an exit code fleet tooling can act on: 0 not impacted, 1 impacted, 2 unknown, 3 usage error.
  • Is read-only. It does not run nginx, reload it, or send it traffic.

Wrappers run the same script across a fleet over SSH, Ansible or Kubernetes.

CVE What it is Affected
CVE-2026-123007 HTTP/2 flow-control window overflow 1.9.5 to 1.31.8
CVE-2026-123633 HTTP/2 use-after-free 1.19.7 to 1.31.8
CVE-2026-121810 HTTP/3 use-after-free 1.25.0 to 1.31.8
CVE-2026-123634 DNS resolver use-after-free 0.6.18 to 1.31.8
CVE-2026-113425 Mail proxy use-after-free 0.5.33 to 1.31.8

Sample output

A real run: two containers with the same configuration (HTTP/2 on, requests proxied to a backend), one on the official nginx:1.31.8 image and one on nginx:1.31.9.

$ sudo ./linux/detect-nginx2root.sh --no-disk
nginx2root check: the five CVEs fixed in nginx 1.31.9 and 1.30.7
Each nginx gets a status per CVE: impacted, not impacted or unknown (could not check).
host: Linux x86_64

/usr/sbin/nginx (pid 10969, container web-1)
  version: nginx/1.31.8, package nginx=1.31.8-1~trixie: affected range, unpatched resolver code in the binary
  CVE-2026-123007: impacted (http/2 enabled: listen 8443 http2)
  CVE-2026-123633: impacted (http/2 with proxy_pass http://127.0.0.1:9)
  CVE-2026-121810: not impacted (no quic listener)
  CVE-2026-123634: not impacted (no resolver in http{})
  CVE-2026-113425: not impacted (no mail{} servers)
  => impacted (CVE-2026-123007, CVE-2026-123633)

/usr/sbin/nginx (pid 11042, container web-2)
  version: nginx/1.31.9, package nginx=1.31.9-1~trixie: has the fixes
  CVE-2026-123007: not impacted (has the fixes)
  CVE-2026-123633: not impacted (has the fixes)
  CVE-2026-121810: not impacted (has the fixes)
  CVE-2026-123634: not impacted (has the fixes)
  CVE-2026-113425: not impacted (has the fixes)
  => not impacted

host kernel 6.18.58.1-microsoft-standard-WSL2 (the separate, unpatched root step; not part of the verdict)
  sctp: reachable: sctp is not loaded but loads on demand (no "install sctp /bin/false" in modprobe.d)

this host
CVE-2026-123007: impacted
CVE-2026-123633: impacted
CVE-2026-121810: not impacted
CVE-2026-123634: not impacted
CVE-2026-113425: not impacted

impacted

Exit code 1. With -q only the five this host lines and the verdict are printed.

The host kernel block is extra information. The nginx bugs give code execution as the nginx worker; becoming root needs a separate Linux kernel SCTP bug that has no fix yet. The line says whether SCTP is reachable on this kernel and does not change the verdict.

What counts as impacted

Per CVE, all three must hold:

  • Version in that CVE's range. OpenResty is judged on its nginx core. Forks with their own numbering are unknown.
  • No fix recorded for the package. The package changelog names the CVE (dpkg, rpm), or the package is listed in NGINX2ROOT_FIXED_PKGS.
  • Configuration switches the feature on:
CVE Switched on when
CVE-2026-123007 HTTP/2 is enabled
CVE-2026-123633 HTTP/2 is enabled and requests are passed to a backend (proxy_pass, grpc_pass, fastcgi_pass, ...)
CVE-2026-121810 a listen ... quic directive and requests passed to a backend
CVE-2026-123634 resolver, a *_pass target with a variable, and a subrequest directive (mirror, ssi, auth_request, ...)
CVE-2026-113425 a mail {} block with at least one server

How it reads an nginx

  • Version, build options and a patch marker are read as strings from the binary. For a running nginx that is /proc/PID/exe, so a binary replaced on disk but not restarted is judged on the code that is running.
  • The configuration is read from disk, following includes, wildcards and symlinks. nginx -t / nginx -T are not run.
  • Containers are read through /proc/PID/root. The detector executes nothing from an nginx installation and enters no namespace.

Relation to #8

#8 checks three of the five: the two HTTP/2 CVEs and the resolver one. This checks all five, so a host with HTTP/2 off but an HTTP/3 listener or a mail proxy is still reported. The two overlap and should not both land as they are.

Where they differ on the CVEs both cover:

#8 has things this does not: a mapping of NGINX Plus releases to fixes, recognition of nginx.org packages, macOS support and a CI workflow. Those could be ported here.

Files

Everything is in a new nginx2root/ directory, plus one row in the root README table.

  • linux/detect-nginx2root.sh: host detector.
  • linux/ssh-nginx2root.sh, linux/ansible-nginx2root.yml, linux/k8s-nginx2root.yaml, linux/k8s-exec-nginx2root.sh: fleet wrappers adapted from the JDK ones. The DaemonSet is privileged by design, as before, but needs no extra packages.
  • linux/tests/run-tests.sh: test harness.
  • README.md: usage, output, coverage, fleet runs and what to do if a host is impacted.

Tests

Run locally on Ubuntu 22.04 under WSL, bash 5.1, x86_64: 117 checks pass, and shellcheck -S warning is clean on all four scripts.

  • Version, fork, patch-marker, package and changelog branches, with stand-in binaries.
  • Every per-CVE configuration branch and tokenizer edge cases (comments, quotes, escapes, ${var}, Lua blocks, includes).
  • Real processes: masters with -c / -p, workers ignored, a binary replaced on disk, single-process mode.
  • Real nginx 1.31.8 and 1.31.9 built from source, started and scanned.
  • The official nginx:1.31.8 image, scanned from a privileged --pid=host container, as the DaemonSet does.
  • The same decisions with busybox tools in place of GNU ones.
  • The SSH wrapper against a stand-in ssh.
  • By hand: the official nginx:1.31.9 image (sample above), the distribution packages of Ubuntu 24.04, Alpine 3.20 and AlmaLinux 9, and OpenResty 1.31.8.1.

Not yet verified

  • No live Kubernetes cluster, no real SSH fleet, and the Ansible playbook was not run (both YAML files parse).
  • No real NGINX Plus, Angie, Tengine or freenginx binary; those paths are covered by stand-ins.
  • No distribution package that carries the fixes existed yet, so the changelog path is covered by stand-ins.
  • Not run on bash 3.2.
  • No CI workflow is included in this PR.

🤖 Generated with Claude Code

…30.7

Host detector and fleet wrappers for CVE-2026-123007, CVE-2026-123633,
CVE-2026-121810, CVE-2026-123634 and CVE-2026-113425.

The detector reports a status per CVE for every running or installed
nginx, then one line per CVE for the host and an overall verdict, with
the same exit-code contract as the other directories (0 not impacted,
1 impacted, 2 unknown, 3 usage).

It reads the version, build options and a patch marker from the nginx
binary as strings and reads the configuration from disk, through
/proc/PID/root for containers. It does not execute nginx and enters no
namespace.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
metadata:
labels:
app: nginx2root
spec:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Low severity issue identified in your code:

The detect container can run as root and is already privileged with host PID visibility. A compromise of its image or command could therefore expose or tamper with sensitive data and processes on every node running this DaemonSet.

More details about this

The pod template spec for the nginx2root DaemonSet does not require its detect container to run as a non-root user. The container uses debian:stable-slim, whose command runs /bin/sh -c and then bash /scripts/detect-nginx2root.sh; without an effective non-root restriction, those processes can run as UID 0. This is especially dangerous here because detect is also privileged: true and the pod enables hostPID: true, so a compromise has unusually broad visibility and host-level access.

A plausible attack path is:

  1. An attacker compromises the debian:stable-slim image, the /scripts/detect-nginx2root.sh content, or any service that can execute commands in this DaemonSet pod.
  2. The attacker runs kubectl exec-equivalent code in detect and executes id, observing uid=0(root) because no container-level non-root requirement is present.
  3. From the privileged detect container, the attacker inspects host processes through the shared PID namespace (ps or /proc) and accesses privileged kernel/device interfaces available to the container.
  4. The attacker uses that root-level, privileged position on every node where the nginx2root DaemonSet runs to read sensitive host or workload data, tamper with processes, or establish persistence.

The finding is on the pod-template spec because its containers list lacks a runAsNonRoot: true security setting for detect.

To resolve this comment:

💡 Follow autofix suggestion

Suggested change
spec:
spec:
securityContext:
runAsNonRoot: true #:
View step-by-step instructions
  1. Add a pod-level security context under the workload's spec.template.spec:

    spec:
      template:
        spec:
          securityContext:
            runAsNonRoot: true
  2. If securityContext already exists at that location, add runAsNonRoot: true without removing the existing settings.

  3. Confirm that the debian:stable-slim image and its startup commands work as a non-root user. If they require root, update the image or commands to use a dedicated non-root user before enabling this setting.

Alternatively, if this manifest is intentionally insecure Semgrep test data, add its specific path to .semgrepignore rather than weakening the rule for production manifests.

💬 Ignore this finding

Reply with Semgrep commands to ignore this finding.

  • /fp <comment> for false positive
  • /ar <comment> for acceptable risk
  • /other <comment> for all other reasons

Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by run-as-non-root.

You can view more details about this finding in the Semgrep AppSec Platform.

labels:
app: nginx2root
spec:
hostPID: true

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium severity issue identified in your code:

The privileged detect container shares each node's process namespace, allowing a container compromise to inspect or tamper with host processes via ptrace.

More details about this

hostPID: true makes every nginx2root pod share the node's process ID namespace instead of seeing only container processes. This DaemonSet also runs the detect container as privileged: true on every Linux node (including tainted nodes), so code execution in detect—for example through a compromised debian:stable-slim image or /scripts/detect-nginx2root.sh—can target host processes with ptrace.

A plausible attack is:

  1. An attacker gains a shell in the detect container and runs ps -ef; because of hostPID, the output includes node processes such as PID 1, kubelet, and workloads outside this pod.
  2. The attacker selects a host PID and reads /proc/<pid>/environ or attaches with strace -p <pid>. With the container's privileged security context, they can use ptrace to inspect or manipulate that process rather than being limited to the container's own processes.
  3. The attacker extracts credentials or tokens from a host process, or alters a privileged host process to execute commands on the node. Since this is a DaemonSet with an Exists toleration, the same attack surface is deployed across the cluster's Linux nodes.

Summary: hostPID: true exposes node processes to the privileged detect container. A compromised container could use ptrace to read secrets from or tamper with host processes across every node running this DaemonSet.

To resolve this comment:

✨ Commit fix suggestion
  1. Remove hostPID: true from the DaemonSet pod template at spec.template.spec.
  2. Update /scripts/detect-nginx2root.sh or any related logic that depends on host process IDs to use container-local process IDs or a supported node-monitoring API instead.
  3. Keep the pod in its default process namespace so it cannot inspect or interact with processes running outside the container.
💬 Ignore this finding

Reply with Semgrep commands to ignore this finding.

  • /fp <comment> for false positive
  • /ar <comment> for acceptable risk
  • /other <comment> for all other reasons

Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by hostpid-pod.

You can view more details about this finding in the Semgrep AppSec Platform.

- name: detect
image: debian:stable-slim
securityContext:
privileged: true

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium severity issue identified in your code:

The detect container is privileged and shares the host PID namespace, allowing an attacker with command execution in the pod to take control of the underlying Linux node. The DaemonSet deploys this exposure across matching nodes.

More details about this

The detect container in the nginx2root DaemonSet runs with securityContext.privileged: true. Because this DaemonSet tolerates all taints and targets Linux nodes, an attacker who gains the ability to execute commands in detect can abuse host-level privileges on every Linux node where it runs; hostPID: true also exposes host processes.

A plausible attack is:

  1. An attacker obtains workload-execution access and runs kubectl -n nginx2root exec -it <detect-pod> -- /bin/sh.
  2. Inside detect, they use the host process namespace exposed by hostPID: true, for example nsenter -t 1 -m -u -i -n -p -- /bin/sh.
  3. The resulting shell can inspect or alter host processes, read host files such as /etc/shadow, install persistence, or access credentials used by services on that node. Since this is a DaemonSet, the same compromise path is available on each matching Linux node.

To resolve this comment:

✨ Commit fix suggestion
  1. Remove privileged: true from the container’s securityContext.

  2. If a security context is required, set it explicitly to least privilege:

    securityContext:
      privileged: false
      allowPrivilegeEscalation: false
      capabilities:
        drop:
          - ALL
      seccompProfile:
        type: RuntimeDefault
  3. Add runAsNonRoot: true if the detection script works without root:

    securityContext:
      runAsNonRoot: true
  4. Update the script so it does not depend on host-level capabilities. If it requires a specific capability, add only that capability under capabilities.add instead of enabling privileged mode.

💬 Ignore this finding

Reply with Semgrep commands to ignore this finding.

  • /fp <comment> for false positive
  • /ar <comment> for acceptable risk
  • /other <comment> for all other reasons

Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by privileged-container.

You can view more details about this finding in the Semgrep AppSec Platform.

containers:
- name: detect
image: debian:stable-slim
securityContext:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium severity issue identified in your code:

The detect container is privileged and shares the host PID namespace, but its securityContext does not restrict privilege escalation. A compromised script or process could abuse setuid/setgid binaries to access host processes and sensitive node resources.

More details about this

The detect container uses debian:stable-slim with securityContext.privileged: true, but does not explicitly restrict privilege escalation. It also runs with hostPID: true at the pod level, so a process launched through the container's command/args—including bash /scripts/detect-nginx2root.sh—can potentially use setuid/setgid binaries or other privilege-escalation paths to access host processes and sensitive node resources.

A plausible attack path is:

  1. An attacker gains control of the detect process, for example by compromising the script mounted from the detect ConfigMap or by exploiting a command it invokes.
  2. The attacker runs a setuid utility inside the debian:stable-slim container, such as find / -perm -4000 -type f, and executes one of the discovered binaries to obtain elevated process privileges.
  3. Because the container is already configured with privileged: true and the pod shares the node process namespace through hostPID: true, the attacker can inspect or interfere with host processes and use the container's node-level access to read sensitive data or further compromise the Kubernetes node.

The finding is specifically on the container's securityContext because it lacks an allowPrivilegeEscalation setting, leaving this escalation path unrestricted.

To resolve this comment:

✨ Commit fix suggestion

Suggested change
securityContext:
securityContext:
allowPrivilegeEscalation: false #:
View step-by-step instructions
  1. Remove privileged: true from the container unless the detector can run without full host privileges. A privileged container can still escalate even when allowPrivilegeEscalation is set to false.

  2. Set the container security context to disable privilege escalation and drop unnecessary Linux capabilities:

    securityContext:
      allowPrivilegeEscalation: false
      privileged: false
      capabilities:
        drop:
          - ALL
  3. Remove hostPID: true if the detector does not need to inspect host processes. If host access is required, redesign the detector to use the smallest required permissions and avoid running the container as privileged.

  4. Ensure the detector does not require setuid or setgid binaries. If it does, replace those operations with explicitly granted, narrowly scoped capabilities rather than enabling privileged.

💬 Ignore this finding

Reply with Semgrep commands to ignore this finding.

  • /fp <comment> for false positive
  • /ar <comment> for acceptable risk
  • /other <comment> for all other reasons

Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by allow-privilege-escalation.

You can view more details about this finding in the Semgrep AppSec Platform.

…gured

With a resolver and Lua or njs handlers but no *_pass containing a
variable, CVE-2026-123634 was reported "not impacted". Lua cosockets and
njs fetch resolve names through the same resolver while a request runs,
and both can make subrequests, so that case is now "unknown".

Also clear the two shellcheck warnings (an eval-assigned variable in the
SSH wrapper, an unused "$@" in a test helper) and add tests for the
resolver cases.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
@diptendukar

Copy link
Copy Markdown
Author

Closing this in favour of a smaller change. #8 is merged and already covers three of the five CVEs, so rather than add a second nginx detector next to it, I will open a PR that adds the remaining two (CVE-2026-121810, HTTP/3, and CVE-2026-113425, mail proxy) to the merged script.

The branch stays on my fork in case any of this is useful later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant