While looking into PL/SQL Developer – a very popular tool for working with Oracle databases, to see how it encrypts passwords I noticed something interesting. When testing Windows applications, I make it a habit to have Fiddler running, to see if there is any interesting traffic – and in this case, there certainly was.
PL/SQL Developer has an update mechanism which retrieves a file containing information about available updates to PL/SQL Developer and other components; this file is retrieved via HTTP, meaning that an attacker in a privileged network position could modify this file.
This file is retrieved each time the application starts, and if a version listed in the file is greater than the version installed, the user will be prompted to upgrade (default behavior; otherwise user not prompted until they select Help | Check Online Updates). They have the following options:
- Update: If a URL is provided, the application will download a file (also over HTTP), and apply the update. If no URL is provided, the option is not presented to the user.
- Download: Executes the URL provided, so that the user’s browser will open, and immediately download the file. This is typically an executable (*.exe); as is the case elsewhere, the file is retrieved over HTTP, and no validation is being performed.
- Info: If a URL, it’s executed so that the user’s browser opens to the specified URL; otherwise content is displayed in a message box.
The are (at least) two issues here:
- Redirect to malicious download; as the user is likely unaware that they shouldn’t trust the file downloaded as a result of using the Download option, an attacker could replace the URL and point to a malicious file, or simply leverage their privileged position to provide a malicious file at the legitimate URL.
- Command Execution; when the user selects the Download option, the value in the file is effectively ShellExecute’d, without any validation – there is no requirement that it be a URL. If a command is inserted, it will be executed in the context of the user.
This means that a user believing that they are downloading an update, can actually be handing full control over to an attacker – this is a case where not bothering to use HTTPS to secure traffic, can provide multiple methods for an attacker to gain control of the user’s PC. This is a great example of the importance of using HTTPS for all traffic – it’s not just about privacy, it’s also critical for integrity.
The tested version of PL/SQL Developer was 11.0.4, though the issue likely well predates that version. The vendor reports that this issue has been addressed by enforcing HTTPS on their website, and application changes made in version 11.0.6. It is recommended that all users update to the latest version.
The update file is retrieved from http://www.allroundautomations.com/update/pls.updates – the request issued by the application looks like this:
GET http://www.allroundautomations.com/update/pls.updates HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko
Accept-Encoding: gzip, deflate
Here’s what a response looks like – it’s a INI-like file, the
Download value is the item we care about most here:
HTTP/1.1 200 OK
Date: Thu, 04 Feb 2016 21:50:18 GMT
Cache-Control: no-store, no-cache, must-revalidate, max-age=0
Last-Modified: Fri, 11 Sep 2015 09:10:32 GMT
Keep-Alive: timeout=5, max=99
WhatsNew=Fixed "List index out of bounds" error during document generation
WhatsNew=Upgraded to work with PL/SQL Developer 9.0
WhatsNew=Improved download and Installation of Red Gate products from within Plug-In
WhatsNew=New version with Timezone correction and some bugfixes.
WhatsNew=New: allow columns to be included/excluded from export, allow first column (Line No) always include/exclude from export
WhatsNew=New: Updated for PL/SQL Developer 7.1
By changing the returned file, replacing this line:
When the user selects the Download option,
calc.exe will be executed.
Here is an example of a
pls.updates file that demonstrates this flaw (the key changes are increasing the Version, so that the user will see it as an update, clearing the Update value, so the only option is Download, and setting Download to the command that you wish to be executed):
Thanks to Garret Wassermann of CERT/CC for his assistance and Allround Automations for addressing the issue.