RCE via Java RMI Injection
The application accepted an RMI URL and attempted to resolve the hostname, then loaded a remote Java class from an attacker-controlled RMI server. An attacker could execute arbitrary code on the server by hosting a malicious Java class and triggering its loading via the RMI URL.
medium.com
Published on medium.com
I don’t usually write write-ups except for specific vulnerabilities like injections. Today I want to share with you another injection vulnerability that I recently exploited.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the application allowed user-controlled RMI URLs and failed to restrict which remote classes could be loaded, leading to deserialization of attacker-supplied code.
Impact
An attacker could execute arbitrary code on the server, potentially leading to full system compromise.
What the attacker needed
Ability to send requests to the vulnerable endpoint; attacker-controlled server reachable from target
How it was found
- Identify a request parameter that accepts an RMI URL.
- Set up an RMI server on the attacker's machine.
- Create and compile a malicious Java class (Exploit.java) and host it on an HTTP server.
- Send a request with the RMI URL pointing to the attacker's server and the class name.
- Observe a DNS callback (e.g., via nslookup) to confirm code execution.
- Replace the test command with a reverse shell payload to gain a shell.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Remote Method Invocation (RMI) is a Java feature that lets one program call methods on another program over a network. The application took a user-supplied RMI address and tried to connect to it, which allowed the attacker to serve a malicious Java class that the server then executed. This gave the attacker control over the server.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.