How I found my first RCE?
A subdomain running Oracle WebLogic was vulnerable to CVE-2017-10271, allowing remote code execution. The author exploited it by sending a crafted XML request to a specific endpoint, achieving code execution and reading a system file.
Hello everyone, this is a story of how I found my first RCE on a bug bounty program. This is a private program and doesn't allow disclosure so let us assume that our target is redacted.com.
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.
Context
This is the story of my first remote code execution finding on a bug bounty program. The program is private and does not allow disclosure, so throughout this write-up the target is called redacted.com. It is a wide scope target, which is what made the approach below worthwhile: with a large enough surface, older and less maintained hosts tend to survive in the inventory.
The vulnerable host, which I will call vuln.redacted.com, was running Oracle WebLogic. The exposed endpoint was the Web Services Atomic Transaction coordinator port type, reachable at the path /wls-wsat/CoodinatorPortType (note the spelling in the URL as it appeared on the target). This component accepts XML requests, and the host was affected by CVE-2017-10271.
Setup
The tooling was deliberately simple and mostly automated for the discovery phase:
- Subdomain enumeration scripts, whose output was piped into
httpxto keep only live hosts. - Keyword filtering over the resulting hostnames for terms such as
internal,staging,stg,developerandadmin. - The
nucleitechnologies template against the live subdomains, to see which technologies each host was running. - The
nucleiCVE templates against the host that turned out to be WebLogic. - Burp Suite to intercept, edit and replay the request by hand.
After probing I had over 14k unique live targets.
Finding it
While testing the interesting hostnames manually, I also ran the nuclei technologies template across the live subdomains and parsed the output. One subdomain, vuln.redacted.com, came back as using Oracle WebLogic.
I knew there were CVEs for WebLogic, so I ran the CVE templates from nuclei against that host. As expected, nuclei detected CVE-2017-10271 and reported the vulnerable URL:
https://vuln.redacted.com/wls-wsat/CoodinatorPortType
At that point I started googling for a CVE-2017-10271 proof of concept, and I also already had the PoC from the nuclei template.
Exploitation
Step 1: intercept the request
I intercepted the request in Burp. The captured request was a GET to the vulnerable path.
Step 2: the first mistake, GET instead of POST
Without any second thoughts I attached the payload to the GET request and forwarded it. Of course the exploit did not work: the endpoint expects a POST request, and out of excitement at the prospect of my first RCE I had sent a GET instead.
Step 3: switch to POST
Realising the mistake, I changed the request method to POST and sent the request again. This should work, right? No, it did not. This time the server threw an error.
Step 4: the second mistake, the Content-Type header
The Content-Type entity header indicates the media type of the resource. We are sending XML data, but if you look carefully, Content-Type was set to application/x-www-form-urlencoded. For the exploit to work it has to be text/xml.
Step 5: the working request
The final, error-free POST request, the one that actually exploited the vulnerability, was the one with the method corrected and the content type set to text/xml.
On sending that request, the response came back with a delay of approximately 12 seconds, which proved I had Java code execution.
Step 6: reading a file
I then used the payload from the nuclei template to read /etc/passwd on the remote server.
Root cause
The host was running an Oracle WebLogic version affected by CVE-2017-10271, and the WLS Security component exposed through /wls-wsat/CoodinatorPortType was reachable without authentication. The report does not go into the internals of the deserialisation flaw beyond identifying the CVE, so the precise mechanism is best taken from the CVE itself.
On the client side, two conditions had to be met for the exploit to land, and both are easy to get wrong: the request must be a POST, and the Content-Type must be text/xml so that the XML body is handled as XML rather than as form data. Neither is a defence on the server; they are simply the shape the endpoint expects.
Impact
An attacker who can reach the endpoint can execute code on the WebLogic server. In this case the response delay of roughly 12 seconds proved Java code execution, and I read /etc/passwd from the remote server. From there, the impact is whatever the WebLogic process is permitted to do on the host and in the surrounding network. The report does not describe any further post-exploitation, lateral movement or data access.
Fix
The report does not state what the program changed.
Variants to test
- Run the
nucleitechnologies template across every live subdomain and look for Oracle WebLogic, then run the CVE templates against each hit. A positive result is a template match naming CVE-2017-10271 and a URL under/wls-wsat/. - Filter large subdomain lists for
internal,staging,stg,developerandadminand test those hosts by hand. A positive result is an old or unmaintained service still reachable from the internet. - When a PoC is published as a POST with an XML body, replay it exactly as published before improvising. A positive result is a response that differs from the error you get with the wrong method or the wrong
Content-Type. - If a request returns an error, check the method and the
Content-Typebefore assuming the target is patched. A positive result is the same body succeeding onceContent-Type: text/xmlis set. - Use a timing signal as a first confirmation of code execution, as I did with the roughly 12 second delay, then confirm with a file read such as
/etc/passwd. A positive result is a consistent delay followed by file contents in the response.
I hope you learn from the mistakes I made, which could have cost me my first RCE.
What happened, in plain words
A security researcher was taking part in a bug bounty programme: a scheme where companies invite people to look for weaknesses in their systems and pay for the ones they report. This particular programme is private and does not allow the researcher to name the company, so the target is called redacted.com throughout. It is a wide scope target, meaning the company allowed testing across a large number of its systems rather than a single website. That matters because the bigger the set of machines you are allowed to look at, the more likely it is that some old, forgotten server is still running outdated software.
The researcher found one such server, called vuln.redacted.com here, running Oracle WebLogic. WebLogic is a Java application server: a piece of software that runs web applications written in the Java programming language and answers requests from browsers and other programs. The exposed part was a feature called the Web Services Atomic Transaction coordinator port type, reachable at the path /wls-wsat/CoodinatorPortType (the spelling is exactly as it appeared on the target). This feature accepts XML, a text format for structured data, and the version in use had a known security flaw, CVE-2017-10271. A CVE is a public catalogue number for a specific security vulnerability, so anyone can look it up. This one is identified as CVE-2017-10271, a known WebLogic vulnerability. Remote code execution (RCE) here means an attacker who can reach the endpoint can run their own commands on the server.
Setting up
The tools were deliberately simple, and most of the discovery work was automated:
- Subdomain enumeration scripts. A subdomain is a name like
shop.example.comthat sits under a main domainexample.com. Enumeration means finding as many of these names as possible, because each one may point to a different machine. - The output was piped into
httpx, a tool that takes a list of hostnames and checks which ones actually respond, keeping only the live ones. - Keyword filtering over the resulting hostnames for words such as
internal,staging,stg,developerandadmin. These names often hint at test systems or administrative interfaces that were never meant to be public. - The
nucleitechnologies template against the live subdomains.nucleiis a scanner that runs ready-made checks, called templates, against a list of targets. The technologies template tries to work out what software each host is running. - The
nucleiCVE templates against the host that turned out to be WebLogic. These templates check for specific known vulnerabilities by their CVE number. - Burp Suite to intercept, edit and replay the request by hand. Burp is a tool that sits between your browser and the target, letting you see and change every request before it is sent.
After probing, there were over 14k unique live targets.
Finding it
While testing the interesting hostnames by hand, the researcher also ran the nuclei technologies template across the live subdomains and parsed the output. One subdomain, vuln.redacted.com, came back as using Oracle WebLogic.
WebLogic has had several CVEs over the years, so the next step was to run the CVE templates from nuclei against that host. As expected, nuclei detected CVE-2017-10271 and reported the vulnerable URL:
https://vuln.redacted.com/wls-wsat/CoodinatorPortType
Line by line: https:// is the secure web protocol; vuln.redacted.com is the host; /wls-wsat/CoodinatorPortType is the path on that host that leads to the vulnerable feature. The whole string is the address a browser or a tool would use to reach it.
At that point the researcher started googling for a CVE-2017-10271 proof of concept (PoC), a small example that demonstrates the vulnerability, and also already had the PoC from the nuclei template.
Exploitation
Step 1: intercept the request
The request was intercepted in Burp. The captured request was a GET to the vulnerable path. GET is the ordinary method a browser uses when you open a page: it asks the server to send something back. A request also has a method, a URL, headers (extra information such as the format of the body) and sometimes a body (data sent to the server).
Step 2: the first mistake, GET instead of POST
Without any second thoughts the payload was attached to the GET request and forwarded. Of course the exploit did not work: the endpoint expects a POST request. POST is the method used when you are sending data to the server, for example when you submit a form. Out of excitement at the prospect of a first RCE, a GET had been sent instead. The lesson is that the method is part of the contract: if the server expects data to be submitted, a request that only asks for a page will not carry the payload the way the server reads it.
Step 3: switch to POST
Realising the mistake, the method was changed to POST and the request was sent again. This should work, right? No, it did not. This time the server threw an error. An error message is useful: it tells you the server received something but could not process it, which is different from ignoring the request entirely.
Step 4: the second mistake, the Content-Type header
The Content-Type header tells the server what kind of data is in the body. We are sending XML data, but if you look carefully, Content-Type was set to application/x-www-form-urlencoded. That value means the body is a list of form fields, like the data a browser sends when you submit a login form. For the exploit to work it has to be text/xml, which tells the server to treat the body as XML. This is an observational mistake: the information was in front of the researcher, in the request headers, but was overlooked.
Step 5: the working request
The final, error-free POST request, the one that actually exploited the vulnerability, was the one with the method corrected and the content type set to text/xml.
On sending that request, the response came back with a delay of approximately 12 seconds, which proved there was Java code execution. A delay is a timing signal: the server took noticeably longer than usual, which the researcher took as proof of code execution. It is a common first confirmation when you cannot see the command output directly.
Step 6: reading a file
The payload from the nuclei template was then used to read /etc/passwd on the remote server. /etc/passwd is a standard file on Linux and Unix systems that lists user accounts. Reading it proves that you can read files on the server.
Root cause
The host was running an Oracle WebLogic version affected by CVE-2017-10271, and the WLS Security component exposed through /wls-wsat/CoodinatorPortType was reachable without authentication. The report does not go into the internals of the deserialisation flaw beyond identifying the CVE, so the precise mechanism is best taken from the CVE itself.
On the client side, two conditions had to be met for the exploit to land, and both are easy to get wrong: the request must be a POST, and the Content-Type must be text/xml so that the XML body is handled as XML rather than as form data. Neither is a defence on the server; they are simply the shape the endpoint expects.
Impact
An attacker who can reach the endpoint can execute code on the WebLogic server. In this case the response delay of roughly 12 seconds proved Java code execution, and I read /etc/passwd from the remote server. From there, the impact is whatever the WebLogic process is permitted to do on the host and in the surrounding network. The report does not describe any further post-exploitation, lateral movement or data access.
Fix
The report does not state what the programme changed. A reverse proxy is a server that sits in front of the application and forwards requests to it, so it is a natural place to block paths that should not be reachable from the internet.
Variants to test
- Run the
nucleitechnologies template across every live subdomain and look for Oracle WebLogic, then run the CVE templates against each hit. A positive result is a template match naming CVE-2017-10271 and a URL under/wls-wsat/. - Filter large subdomain lists for
internal,staging,stg,developerandadminand test those hosts by hand. A positive result is an old or unmaintained service still reachable from the internet. - When a PoC is published as a POST with an XML body, replay it exactly as published before improvising. A positive result is a response that differs from the error you get with the wrong method or the wrong
Content-Type. - If a request returns an error, check the method and the
Content-Typebefore assuming the target is patched. A positive result is the same body succeeding onceContent-Type: text/xmlis set. - Use a timing signal as a first confirmation of code execution, as I did with the roughly 12 second delay, then confirm with a file read such as
/etc/passwd. A positive result is a consistent delay followed by file contents in the response.
I hope you learn from the mistakes I made, which could have cost me my first RCE.
Glossary
- Bug bounty programme: a scheme where a company invites people to look for security weaknesses in its systems and pays for the ones they report.
- Private programme: a bug bounty programme that only invited researchers can take part in, and whose details are not public.
- Wide scope: a programme that allows testing across many of the company's systems, not just one website.
- Subdomain: a name like
shop.example.comthat sits under a main domainexample.comand may point to a different machine. - Subdomain enumeration: the process of finding as many subdomains of a domain as possible.
httpx: a tool that takes a list of hostnames and checks which ones actually respond.nuclei: a scanner that runs ready-made checks, called templates, against a list of targets.- Template: a packaged check in
nucleithat looks for a particular technology or vulnerability. - Oracle WebLogic: a Java application server, software that runs web applications written in Java and answers requests from browsers and other programs.
- Java: a programming language, and also the runtime environment that runs Java programs.
- Application server: software that hosts and runs web applications and handles requests to them.
- Web Services Atomic Transaction coordinator port type: a WebLogic feature that accepts XML requests, reachable at the path
/wls-wsat/CoodinatorPortTypeon the target. - XML: a text format for structured data, using tags to mark up the content.
- SOAP: a standard way of sending XML messages between programs over a network.
- CVE: a public catalogue number for a specific security vulnerability, so anyone can look it up.
- CVE-2017-10271: the identifier of the WebLogic vulnerability used in this report, an XML deserialisation issue in the WLS Security component that allows unauthenticated remote code execution.
- Deserialisation: the process of turning stored or transmitted data back into live objects in a program; if the data is attacker-controlled, it can lead to code execution.
- WLS Security component: the part of WebLogic that handles security for web services, and the part affected by CVE-2017-10271.
- Remote code execution (RCE): a vulnerability that lets an attacker run their own commands on a remote server.
- Unauthenticated: reachable without logging in or presenting any credential.
- Endpoint: a specific address on a server that accepts requests, such as a URL path.
- GET: the ordinary request method a browser uses when you open a page, asking the server to send something back.
- POST: the request method used when you send data to the server, for example when you submit a form.
- Request: a message a client sends to a server, with a method, a URL, headers and sometimes a body.
- Header: extra information attached to a request or response, such as the format of the body.
Content-Type: the header that tells the server what kind of data is in the body.application/x-www-form-urlencoded: aContent-Typevalue meaning the body is a list of form fields, like the data a browser sends when you submit a login form.text/xml: aContent-Typevalue meaning the body is XML.- Burp Suite: a tool that sits between your browser and the target, letting you see and change every request before it is sent.
- Intercept: to capture a request in Burp before it reaches the server, so you can edit it.
- Proof of concept (PoC): a small example that demonstrates a vulnerability.
- Payload: the crafted data sent to a server to trigger a vulnerability.
- Timing signal: using how long a server takes to respond as evidence that a command ran.
/etc/passwd: a standard file on Linux and Unix systems that lists user accounts, often read to prove file access.- Patch: an update from the software vendor that fixes a vulnerability.
- Reverse proxy: a server that sits in front of the application and forwards requests to it, and can block paths that should not be reachable from the internet.
- Lateral movement: moving from one compromised machine to other machines in the same network.