SpiderLabs Blog

Apache ActiveMQ Vulnerability Leads to Stealthy Godzilla Webshell

Written by Rodel Mendrez | Jan 18, 2024 1:00:00 PM

Trustwave has observed a surge in attacks exploiting vulnerabilities in Apache ActiveMQ hosts. In certain cases, these host malicious Java Server Pages (JSP) web shells.

The web shells are concealed within an unknown binary format and are designed to evade security and signature-based scanners. Notably, despite the binary's unknown file format, ActiveMQ's JSP engine continues to compile and execute the web shell.

 

ActiveMQ Vulnerability

Over the past few weeks, there has been a notable increase in malicious activity targeting a recent critical vulnerability in the Apache ActiveMQ software. This vulnerability is specifically linked to unsafe deserialization practices within the OpenWire protocol and has been designated as CVE-2023-46604. Exploiting this vulnerability enables threat actors to potentially gain unauthorized access to a target system by executing arbitrary shell commands. Since a PoC of the exploit was made publicly available in October 2023, threat actors have been using it to deploy crypto-miners, rootkits, ransomware, and remote access trojans.

 

Dropped Payload

Recently, our Global Threat Operations team identified a suspicious JSP file within a client’s server hosting a vulnerable instance of Apache ActiveMQ.

Figure 1 The suspicious file found by Trustwave Global Threat Operations team. Examining the .JSP file reveals that the malicious code is encapsulated within a binary structure of an unidentified file format, marked by the "FLR" magic header.

 

The malicious file was planted in the “admin” folder within the ActiveMQ installation directory. This folder contains the server scripts for the ActiveMQ administrative and web management console.

 

Figure 2 The malicious file was planted in the same directory of the Apache ActiveMQ admin page.

 

Upon further analysis, Trustwave SpiderLabs determined that this JSP code came from an open-source web shell known as the Godzilla Webshell. What makes these malicious files particularly noteworthy is how the JSP code appears to be concealed within an unknown type of binary. This method has the potential to circumvent security measures, evading detection by security endpoints during scanning.

Interestingly, the Jetty JSP engine which is the integrated web server in Apache ActiveMQ, actually parsed, compiled and executed the embedded Java code that was encapsulated in the unknown binary. Further examination of the Java code generated by Jetty showed that the web shell code was converted into Java code and therefore was executed.

 

Figure 3. Illustrates the Java code produced by the JSP engine, which is generated upon accessing the JSP file.

 

The unidentified data in the binary is then sent to the client's browser using “out.write()”, resulting in the display of unintelligible characters when accessing the web shell from a browser.

 

Figure 4. The unidentifiable data in the binary appears as an unintelligible string when accessing the JSP file in the browser. However, the web shell code is now absent, having been transformed into Java code and executed on the server side.

 

Godzilla Webshell

After a successful exploitation and deployment of the JSP payload, the threat actor can connect to the web shell through the Godzilla management user interface, gaining complete control over the target system.

Figure 5 Godzilla's management user interface available to the threat actor

 

Once deployed in the target websever, the Godzilla Web Shell features a wide range of functionalities including but not limited to:

  • Viewing network details
  • Conducting port scans
  • Executing Mimikatz commands
  • Running Meterpreter commands
  • Executing shell commands
  • Remotely managing SQL databases
  • Injecting shellcode into processes
  • Handling file management tasks

 

Affected Apache ActiveMQ Versions

The following Apache ActiveMQ versions are affected. Users are recommended to upgrade both brokers and clients to version 5.15.16, 5.16.7, 5.17.6, or 5.18.3 which fixes this the vulnerability. 

- Apache ActiveMQ 5.18.0 before 5.18.3

- Apache ActiveMQ 5.17.0 before 5.17.6

- Apache ActiveMQ 5.16.0 before 5.16.7

- Apache ActiveMQ before 5.15.16

- Apache ActiveMQ Legacy OpenWire Module 5.18.0 before 5.18.3

- Apache ActiveMQ Legacy OpenWire Module 5.17.0 before 5.17.6

- Apache ActiveMQ Legacy OpenWire Module 5.16.0 before 5.16.7

- Apache ActiveMQ Legacy OpenWire Module 5.8.0 before 5.15.16

 

IoC:

MD5:

  • 5e6993bba5e8e72a4899d6ddfb167972
  • f257b2669b15ca2792625d0bce00d907
  • 5b4871092491a51477a13af5030c76b7

 

SHA256:

  • 233adf5d3c754ead3f304a4891d367884dd615d74d9983119546bebb346b7bf7
  • 5da5796d407a0099aa624b1ea73a877a5197b3b31529d94f2467dce19fe3a74a
  • f97c6c820694a059c7b0b2f3abe1f614b925dd4ab233d11472b062325ffb67be

 

Godzilla’s Default Protocol Header:

User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2

 

 

YARA rule to detect Godzilla Webshell:

rule Godzilla_webshell {

   meta:

     description = "Detects Godzilla Webshell JSP Code"

   strings:

     $s1 = "String xc=" ascii wide

     $s2 = "String pass=" ascii wide

     $s3 = "String md5=md5(pass+xc)" ascii wide

     $s4 = "payload" ascii wide

     $s5 = "X(ClassLoader z)" ascii wide

   condition:

     all of them

}