Synopsis
Tenable Research discovered a Remote Code Execution (RCE) vulnerability (now remediated) in Oracle Cloud Infrastructure’s (OCI) Code Editor - a service designed for developers working within Oracle’s Cloud Shell ecosystem. By chaining together subtle misconfigurations, we demonstrated how an attacker could silently 1-click hijack a victim’s Cloud Shell environment and potentially pivot across OCI services. Attackers could also abuse the vulnerability to exploit Code Editor’s integrated services such as Resource Manager, Functions and Data Science.
The vulnerability is achieved through CSRF (Cross-site request forgery) on the Cloud Shell’s router domain. By abusing the vulnerability, attackers can deploy or overwrite the victim’s Cloud Shell files with a malicious payload to then take over the victim’s service.
Attack details:
- The router upload works with cookie authentication, and the “CS-ProxyChallenge” cookie’s same-site attribute is set to None under the router.cloudshell.us-ashburn-1.oci.oraclecloud.com domain. The Same-Site attribute is a browser security feature introduced in 2016; its default value is set to "Lax". The purpose of the Same-Site attribute is to protect against cross-origin information leakage/attacks, e.g. cross-site request forgery (CSRF). According to the request for comments (RFC), the "None" value in the Same-Site attribute provides no protection against cross-origin attacks.
- The upload works with a multipart/form-data content type which is one of the 3 content types accepted by the browser for a cross-origin request.
- The request is an http “POST” request which is also valid by the browser with a cross-origin request, and does not require any additional custom headers.
- With this kind of an http request and not any additional defenses against a cross-origin/CSRF attack, attackers can abuse this request to upload malicious files to Cloud Shell on behalf of the victim.
Steps to reproduce:
- Host a server
- Create a malicious HTML file that sends a request with javascript to the vulnerable file-upload endpoint (see our example code below)
- The authenticated victim navigates to your payload on the hosted server then works with Oracle’s Cloud Shell regularly
- The .bashrc file runs on shell initialization and you can run code on the victim’s Cloud Shell
- Optional: use the OCI CLI to abuse the correlated Oracle Cloud’s identity and laterally move to other cloud services
POC code:
We are publishing this report ahead of Oracle’s scheduled July CPU as we have observed and confirmed with Oracle that the issue is fixed.
Solution
In response to this discovery, Oracle Cloud fixed the vulnerability by requiring a custom header x-csrf-token:csrf-value.
Disclosure Timeline
All information within TRA advisories is provided “as is”, without warranty of any kind, including the implied warranties of merchantability and fitness for a particular purpose, and with no guarantee of completeness, accuracy, or timeliness. Individuals and organizations are responsible for assessing the impact of any actual or potential security vulnerability.
Tenable takes product security very seriously. If you believe you have found a vulnerability in one of our products, we ask that you please work with us to quickly resolve it in order to protect customers. Tenable believes in responding quickly to such reports, maintaining communication with researchers, and providing a solution in short order.
For more details on submitting vulnerability information, please see our Vulnerability Reporting Guidelines page.
If you have questions or corrections about this advisory, please email [email protected]