본문 바로가기

Security_Study

Advisory: XXE Injection in Oracle Database (CVE-2014-6577)

728x90

The XML Parser module in Oracle Database is vulnerable to XML External Entity (XXE) Injection.

Affected versions: 11.2.0.3, 11.2.0.4, 12.1.0.1 and 12.1.0.2

Privilege required: CREATE SESSION

Technical Details

Due to the security features in Oracle’s XML parser, the external schema is resolved, but not parsed. This prevents certain XXE injection attacks, such as reading local files on the remote database server. However, an attacker could send a specially-crafted SQL Query to trigger the XML Resolver, tricking the server into connecting to a remote resource via HTTP or FTP channels. This makes it possible to exfiltrate data via Out-Of-Band channels, perform port-scanning on remote internal systems, perform Server-Side Request Forgery (SSRF) attacks or cause a Denial-of-Service (DoS) condition.

Vulnerable URI handlers:

  • http:
  • ftp:

Oracle’s XML Parser can be triggered by calling the extractvalue() function for an xmltype object. Below is an example query with a vanilla XXE injection payload:

Executing the above query will produce the following error:

This is due to the FILE URI handler being converted to an XDB Repository path. However, changing the query to use the HTTP URI handler produces a different error. Example query:

Database Server error:

This error suggests that FTP and HTTP URI handlers may be accepted by the XML Parser. Note that the query above will not send any HTTP request to the attacker’s system. Let’s examine another XXE injection payload that references a Parameter Entity instead of a Document Entity:

When executing this query, the Database Server will produce the same error as above (ORA-31020). This time, however, the server is tricked into submitting an HTTP request for the resource “test”. Below is the HTTP log from the attacker’s server:

Traditionally, an attacker would need privileged access to UTL_HTTP package in order to force the server to make HTTP requests to an external resource. Since extractvalue() is available for all database users, XXE injection presents another way to trigger out-of-band HTTP requests without the said privilege.

The FTP URI handler (ftp:) can also be used to trigger Oracle’s XML Resolver. Example query that sends the database username as an FTP username:

Database Server error (note that the error code is different because the supplied credentials could not be used to login to the remote FTP server):

The database’s username is included in the FTP traffic sent to the attacker’s server as the FTP username:

KT_Oracle_Vulnerability

Recommendation

Apply Oracle’s CPUJan2015.

Timeline

July 03, 2014: vulnerability reported to Oracle.

January 20, 2015: patch released.

References

http://www.oracle.com/technetwork/topics/security/cpujan2015-1972971.html

http://vsecurity.com/download/papers/XMLDTDEntityAttacks.pdf

https://media.blackhat.com/eu-13/briefings/Osipov/bh-eu-13-XML-data-osipov-slides.pdf

http://docs.oracle.com/cd/B12037_01/appdev.101/b10790/xdb18res.htm

http://docs.oracle.com/cd/A97630_01/appdev.920/a96620/xdb17fol.htm#1039066

728x90