Loubia: Weaponizing WebLogic's T3 Protocol Through Java Deserialization
Hook
A simple Python script can turn Oracle WebLogic—trusted by Fortune 500 companies to run mission-critical applications—into a remote code execution playground, all through a binary protocol most developers don't even know exists.
Context
In 2015, security researchers discovered that Oracle WebLogic Server's T3 protocol—a proprietary binary communication channel between WebLogic clients and servers—had a critical flaw: it deserializes untrusted Java objects without proper validation. This is roughly equivalent to accepting a USB drive from a stranger and immediately executing whatever executable is on it. The vulnerability, cataloged as CVE-2015-4852, affected virtually every WebLogic deployment because T3 is enabled by default on port 7001.
The T3 protocol itself dates back to WebLogic's early days in the late 1990s, designed for high-performance RMI (Remote Method Invocation) and JNDI lookups. It's optimized for Java-to-Java communication with built-in object serialization, clustering support, and connection multiplexing. Unfortunately, this performance optimization became a security nightmare when researchers realized they could craft malicious serialized payloads that, when deserialized by the server, would execute arbitrary code. Loubia emerged as one of the practical exploitation tools that made testing for this vulnerability accessible beyond just proof-of-concept research.
Technical Insight
Loubia's architecture is deceptively simple—a single Python script that acts as a T3 protocol client capable of sending weaponized Java serialized objects. The tool leverages the fact that WebLogic's T3 implementation will deserialize any Java object sent during the initial handshake, before authentication even occurs. This pre-authentication attack surface is what makes it particularly dangerous.
The exploitation flow works in three stages. First, Loubia establishes a T3 connection by sending the protocol header that WebLogic expects: the magic bytes t3 followed by version information and negotiation parameters. Second, it constructs a malicious Java serialized object using known gadget chains—sequences of existing Java classes that, when chained together during deserialization, result in arbitrary code execution. Third, it sends this payload over the established T3 connection, triggering deserialization and command execution on the server.
Here's a simplified example of how Loubia constructs its payload for a basic command execution:
import socket
import struct
def build_t3_handshake():
# T3 protocol header negotiation
header = b't3 12.2.1\nAS:255\nHL:19\nMS:10000000\n\n'
return header
def build_payload(command, target_os='unix'):
# Simplified payload construction
# Real implementation uses ysoserial-style gadget chains
if target_os == 'unix':
cmd_prefix = '/bin/bash -c '
else:
cmd_prefix = 'cmd.exe /c '
# Serialize malicious object with command
serialized = construct_gadget_chain(cmd_prefix + command)
return serialized
def exploit(target_ip, target_port, command):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((target_ip, target_port))
# Send T3 handshake
sock.send(build_t3_handshake())
response = sock.recv(1024)
# Send malicious payload
payload = build_payload(command)
sock.send(payload)
sock.close()
What makes Loubia particularly effective is its support for both T3 and T3S (SSL/TLS-encrypted T3) protocols. Many security tools struggled with T3S because they needed to properly handle SSL negotiation on top of the T3 protocol handshake. Loubia includes SSL context configuration that allows users to specify SSL/TLS versions, making it compatible with WebLogic servers that enforce encrypted communications.
The tool also includes a webshell deployment mode that's more sophisticated than simple command execution. Instead of running one-off commands, Loubia can inject a JSP/JSPX webshell into the WebLogic deployment directory, providing persistent access through HTTP requests. This works by using the deserialization vulnerability to write a file to disk at a location within the web application's directory structure, typically something like /tmp/loubia.jspx or a path under the deployed application's root.
The gadget chains Loubia employs are based on commons-collections classes that ship with WebLogic. These are similar to the chains popularized by tools like ysoserial but specifically tuned for WebLogic's classpath. The most common chain uses InvokerTransformer objects that can invoke arbitrary methods through reflection:
// Conceptual representation of the gadget chain
Transformer[] transformers = new Transformer[]{
new ConstantTransformer(Runtime.class),
new InvokerTransformer("getMethod",
new Class[]{String.class, Class[].class},
new Object[]{"getRuntime", new Class[0]}),
new InvokerTransformer("invoke",
new Class[]{Object.class, Object[].class},
new Object[]{null, new Object[0]}),
new InvokerTransformer("exec",
new Class[]{String.class},
new Object[]{command})
};
This chain essentially performs Runtime.getRuntime().exec(command) through a series of reflection calls that occur automatically during deserialization. The beauty—or horror, depending on your perspective—is that this code executes with the privileges of the WebLogic server process, often running as a powerful service account.
Gotcha
The most significant limitation is that Loubia only works against unpatched WebLogic instances. Oracle released patches in October 2015 that implement deserialization filters, essentially whitelisting which classes can be deserialized. Any WebLogic installation that's been updated in the last eight years is immune to Loubia's attacks. This dramatically narrows the tool's real-world applicability to legacy environments, abandoned test servers, or organizations with catastrophically poor patch management.
Another practical challenge is network accessibility. The T3 protocol typically runs on port 7001 and is often blocked at network perimeters because it's considered an internal administration protocol. Even in environments with vulnerable WebLogic versions, you'll frequently find that T3 isn't exposed to the internet or even to broad internal network segments. Penetration testers often discover vulnerable WebLogic servers through web interfaces on ports 80/443 but can't actually exploit them because T3 is firewalled. Additionally, modern security monitoring solutions have signatures for malicious T3 traffic patterns, meaning exploitation attempts may trigger alerts even if the vulnerability exists. Loubia includes no evasion techniques, obfuscation, or traffic manipulation capabilities—it's a straightforward exploit that will be highly visible to any competent security operations team.
Verdict
Use if: You're conducting authorized penetration tests or red team exercises against organizations with known legacy infrastructure, particularly in industries with long hardware lifecycles like manufacturing or government. It's also valuable for security researchers building lab environments to understand Java deserialization attacks or training junior security analysts on WebLogic-specific vulnerabilities. If you've already confirmed through reconnaissance that T3 is exposed and you're working in an environment where patches are years behind, Loubia provides a quick, reliable exploitation path. Skip if: You're targeting modern, maintained WebLogic deployments where patches are current—you'll waste time because the vulnerability simply won't exist. Also skip if T3 protocol access is firewalled or you need stealth; this tool generates obvious attack signatures that will alert any security monitoring. For production WebLogic environments in security-conscious organizations, look instead at newer vulnerability classes or misconfigurations rather than relying on eight-year-old deserialization bugs.