Spring Framework (Spring4Shell) — 1 vulnerability check

noctis ships 1 vulnerability check for Spring Framework (Spring4Shell), covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.

← All products · Feeds on GitHub

Spring Framework ClassLoader data binding (Spring4Shell, CVE-2022-22965)

CVECVE-2022-22965
Severitycritical · CVSS 9.8
Categoryrce — Remote code execution
Serviceshttp, https
Detectionscript, http_request, match · highest QoD 75
Feedtests/vulnerabilities/spring4shell/CVE-2022-22965.yaml

Checks whether Spring MVC request data binding reaches the web application's ClassLoader through class.module.classLoader parameters, the root cause of Spring4Shell. The feed sends four GET requests to /: a random parameter (baseline), an unknown property under class.module.classLoader (control), then class.module.classLoader.URLs[0]=0 and class.module.classLoader.DefaultAssertionStatus with an invalid value. Both values fail type conversion before anything is set, so nothing changes on the target. The finding is reported when the baseline and control are accepted with the same status while both probes are rejected with 400 Bad Request, which indicates that the binder resolved real ClassLoader properties. A fixed Spring Framework (5.3.18+, 5.2.20+) or a JDK 8 runtime ignores all four parameters. Only the root path is probed: an application that binds request parameters to an object on another path is not detected. The public exploit chain also needs a WAR deployment on Tomcat; a vulnerable Spring version in an executable jar is reported as well.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET /?{{rnd.p}}={{rnd.v}}
  3. HTTP(S) request GET /?class.module.classLoader.{{rnd.p}}={{rnd.v}}
  4. HTTP(S) request GET /?class.module.classLoader.URLs%5B0%5D=0
  5. HTTP(S) request GET /?class.module.classLoader.DefaultAssertionStatus={{rnd.v}}
  6. Checks assert_resp.status for ^400$ → finding QoD 75: Spring data binding reaches the ClassLoader on /: baseline ?…= → …, unknown class.module.classLoader.… → …, class.module.classLoader.URLs[0…

References:

Feed source — tests/vulnerabilities/spring4shell/CVE-2022-22965.yaml
# Spring Framework RCE via ClassLoader Data Binding — CVE-2022-22965 (Spring4Shell)
#
# Spring MVC / WebFlux on JDK 9+ lets request data binding walk
# `class.module.classLoader.*`. Spring 5.3.18 / 5.2.20 restrict the bean
# properties of java.lang.Class, so the binder no longer reaches the
# ClassLoader. The public exploit then rewrites Tomcat's AccessLogValve to drop
# a JSP; this feed does NOT do that (persistent change on the target).
#
# Non-writing differential check, every request on the same endpoint (/):
#   1. baseline  ?noctis<rand>=<rand>                                  → not 400
#   2. control   ?class.module.classLoader.noctis<rand>=<rand>        → same status
#      (unknown ClassLoader property: ignored by the binder; a filter that
#       rejects the `class.module.classLoader` keyword answers 400 here)
#   3. probe     ?class.module.classLoader.URLs[0]=0                   → 400
#   4. probe     ?class.module.classLoader.DefaultAssertionStatus=x    → 400
#      (both values fail type conversion before any setter runs: the binder
#       really resolved the ClassLoader's properties → BindException → 400)
# A fixed Spring (or JDK 8, where Class has no `module`) ignores the
# parameters and answers 400 to none of them.
#
# Verified on vulhub/spring-webmvc:5.3.17 (Tomcat 8.5.77, JDK 11): baseline 200,
# control 200, probes 400/400; same WAR with spring-beans 5.3.18: 200 everywhere.
# Limit: binding only happens on a handler taking a form-bound object; the
# check probes / (where such apps commonly bind), so an app binding only on
# another path is not seen.
uid: 4bc29be9-2bf5-48d1-8226-eb51f18334b0
name: "Spring Framework ClassLoader data binding (Spring4Shell, CVE-2022-22965)"
description: |
  Checks whether Spring MVC request data binding reaches the web application's
  ClassLoader through class.module.classLoader parameters, the root cause of
  Spring4Shell. The feed sends four GET requests to /: a random parameter
  (baseline), an unknown property under class.module.classLoader (control),
  then class.module.classLoader.URLs[0]=0 and
  class.module.classLoader.DefaultAssertionStatus with an invalid value. Both
  values fail type conversion before anything is set, so nothing changes on the
  target. The finding is reported when the baseline and control are accepted
  with the same status while both probes are rejected with 400 Bad Request,
  which indicates that the binder resolved real ClassLoader properties.
  A fixed Spring Framework (5.3.18+, 5.2.20+) or a JDK 8 runtime ignores all
  four parameters. Only the root path is probed: an application that binds
  request parameters to an object on another path is not detected. The
  public exploit chain also needs a WAR deployment on Tomcat; a vulnerable
  Spring version in an executable jar is reported as well.
cves: [CVE-2022-22965]
cvss: 9.8
severity: critical
category: rce
confidence_base: 0.20
tags: [spring, java, rce, classloader, data-binding, kev, spring4shell]
services: [http, https]
author: noctis
version: "2.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2022-22965"
  - "https://spring.io/blog/2022/03/31/spring-framework-rce-early-announcement"
  - "https://tanzu.vmware.com/security/cve-2022-22965"
  - "https://www.cisa.gov/known-exploited-vulnerabilities-catalog"

steps:
  - id: rand
    action: script
    code: |
      #{ p: "noctis" + rand_str(8), v: rand_str(10) }
    store_as: rnd

  # ── 1. Baseline: a random parameter the application does not know ─────────
  - id: baseline
    action: http_request
    method: GET
    path: "/?{{rnd.p}}={{rnd.v}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: base_resp

  # ── 2. Control: unknown property under class.module.classLoader ───────────
  - id: control
    action: http_request
    method: GET
    path: "/?class.module.classLoader.{{rnd.p}}={{rnd.v}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: ctrl_resp
    condition: "base_resp.status != 400"

  # ── 3. Probe: URLs[0] — URL conversion of "0" fails → 400 when bound ──────
  - id: probe-urls
    action: http_request
    method: GET
    path: "/?class.module.classLoader.URLs%5B0%5D=0"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: urls_resp
    condition: "base_resp.status != 400 && ctrl_resp.status == base_resp.status"

  # ── 4. Probe: DefaultAssertionStatus — boolean conversion fails → 400 ─────
  - id: probe-assert
    action: http_request
    method: GET
    path: "/?class.module.classLoader.DefaultAssertionStatus={{rnd.v}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: assert_resp
    condition: "urls_resp.status == 400"

  - id: classloader-binding
    action: match
    source: assert_resp.status
    pattern: "^400$"
    condition: "base_resp.status != 400 && ctrl_resp.status == base_resp.status && urls_resp.status == 400"
    on_match:
      finding:
        confidence_delta: 0.60
        qod: 75
        evidence: "Spring data binding reaches the ClassLoader on /: baseline ?{{rnd.p}}= → {{base_resp.status}}, unknown class.module.classLoader.{{rnd.p}} → {{ctrl_resp.status}}, class.module.classLoader.URLs[0]=0 → {{urls_resp.status}}, class.module.classLoader.DefaultAssertionStatus={{rnd.v}} → {{assert_resp.status}}"

View these feeds on GitHub