hacking and defending the big 4 databases€¦ · exploiting privilege escalation attack target:...

67
Application Security Inc. All rights reserved. Confidential 1 Hacking and Defending the Big 4 Databases Alexander Rothacker Director Security Research, TeamSHATTER Application Security Inc.

Upload: others

Post on 16-Jun-2020

12 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 1

Hacking and Defending the Big 4

Databases

• Alexander Rothacker

• Director Security Research, TeamSHATTER

• Application Security Inc.

Page 2: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 2

Why is this important?

– 40% Increase in 2012

– 56% Hacks

– Data is what hackers are after

– Credit Card info

– PII

– Proprietary company secrets

Page 3: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 3

Data, Databases, Data Theft

Over 90% of records stolen from databases

(Verizon DBIR)

Over 27,000,000 records stolen in

2012 alone (privacyrights.org)

Too many organizations have failed to take database security seriously.

Page 4: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 4

What Are the Risks for 2013?

Organizations have long focused their security efforts on the perimeter and endpoints

– This approach has left the data center highly vulnerable to

anyone who can gain access via:

1. SQL Injection 2. Password Attacks 3. Improper & Ineffective Access Controls 4. Database Java Exploits 5. Misconfigured Database Security Settings

Page 5: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 5

The Database Top 10

Page 6: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 6

Logins & Passwords

• Disable after setup if possible

• Change password to a strong secret password

Default accounts

• Password expiration, reuse, strength

• Account lockout

• Use Roles/Groups, don’t assign privileges directly

Login and Password policies

• Monitor login activity, especially failed logins

• Use 3rd party tools, or triggers

Database login activity seldom monitored

Page 7: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 7

Default Account Examples

Page 8: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 8

SQL Injection in the DBMS

• Specific functions in the DBMS are vulnerable to SQL injection

• Insert SQL code into parameter values, table names, etc

• Vulnerable database code then executes the SQL

Same concept as at Web App

Page 9: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 9

Exploiting SQL Injection

Attack Target: – SQL Server 2008

Privilege Level: CREATE DATABASE

Outcome: Full control of SQL Server – Attacker can run SQL as SA

Vulnerabilities Exploited: – Privilege Escalation via SQL Injection in

RESTORE function

Page 10: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 10

Attack requires CREATE DATABASE Not unusual for this privilege to be given out temporarily (upon request) when installing new Apps.

Page 11: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 11

Page 12: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 12

The name of the database we just backed up is:

‘, 0, 0, 0 exec sp_addsrvrolemember hackerharry, sysadmin--

Page 13: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 13

Page 14: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 14

Find the

database name in

the backup file

Change one byte

Page 15: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 15

Value changed

from 27 to 07

Page 16: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 16

Page 17: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 17

See more user

names and

password hashes

Grant any role,

access any DB

Page 18: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 18

Exploiting SQL Injection – Take 2

Attack Target: – Sybase ASE 15.7 ESD#1 (fixed in ESD#3)

Privileges Required: CREATE TABLE, CREATE INDEX

Outcome: Full control of SQL Server – Attacker is granted sa_role

Vulnerabilities Exploited: – Privilege Escalation via SQL Injection in

CREATE INDEX

Page 19: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 19

No special roles

Page 20: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 20

Page 21: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 21

sa_role & sso_role

Your database is

all mine now!

Page 22: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 22

SQL Injection in the DBMS

• Since the weaknesses are in the DBMS itself, vendor patches are required to fix

• Minimize the attack surface

• Least privileges

• Monitor database activity

• Log calls to known vulnerable functions

How to protect the DB

Page 23: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 23

Excessive User & Group Privileges

• Great in theory; “hard” in practice

Theory of least privilege

• Users can gain access by way of a role that is granted another role that is granted another role

• Often default database privilege grants are excessive and dangerous

Entitlements hard to manage

Page 24: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 24

Exploiting Excessive Privileges

• Attack Target:

– Oracle 11g Release 1

• Privilege Level:

– Anyone with CREATE SESSION privilege

• Outcome:

– Gain DBA access & complete OS control

• Vulnerabilities Exploited:

– Default PUBLIC privilege to execute DBMS_JVM_EXP_PERMS.IMPORT_JVM_PERMS

Page 25: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 25

No users have ‘ALL

FILES’ - full OS

access

Attempt to execute

OS command fails

Page 26: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 26

The attack in action.

PUBLIC can import JVM

permissions!

Setup the JVM

access control

policy

Page 27: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 27

OS commands

run successfully

New OS file created by our exploit

USER1 has full OS access

Page 28: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 28

Freely Available Exploit Code!

Page 29: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 29

Excessive User & Group Privileges

• Never grant permissions to a user directly

• Always grant permissions through roles or groups

• Don’t cast the net to wide. Keep the roles specific

• Regularly audit role memberships

Best practices

Page 30: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 30

Unnecessary Enabled DBMS Features

• Attackers will only have more to use against you

Minimize Attack Surface

• Integrated Java and other extensible languages

• Various levels of OS access available

Powerful Features are Good and Bad

Page 31: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 31

Exploiting Java in the Database

Attack Target: – Sybase ASE 15.7 ESD#1 on Windows

Privileges Required: CREATE TABLE, CREATE INDEX

Outcome: Execution of OS shell code – Attacker can run local as well as remote executable

Vulnerabilities Exploited: – Arbitrary code execution via Java in Sybase ASE

Page 32: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 32

Page 33: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 33

Page 34: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 34

Page 35: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 35

Page 36: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 36

Minimize Attack Surface

• xp_cmdshell

• OLEDB Ad Hoc Query OPENROWSET

• OPENDATASOURCE

• CREATE_NOT_FENCED

Built-in features

• Oracle Spatial – Replace with Locator

• Java

• Oracle Enterprise Manager Grid Control

Add-on modules

Page 37: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 37

Broken Configuration Management

• Beginning – Name the instance, choose the data storage location

• Now – Advanced feature sets, add-on modules, specific security settings, etc.

Configuration Option Overload

• 1st – What is our current configuration?

• 2nd – What should be our configuration?

What’s the right configuration?

Page 38: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 38

Misconfigurations Are Potential Threats

Page 39: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 39

Exploiting Listener Misconfiguration

• Attack Target:

– Oracle 11g Release 2

• Privilege Level:

– Anyone on the network

• Outcome:

– Listen to traffic, or full database takeover

• Vulnerabilities Exploited:

– Oracle Listener TNS Poisoning

Page 40: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 40

Listener

TNS Poisoning Attack – Step By Step

Proxy

Page 41: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 41

Target DB on 192.168.0.193

Page 42: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 42

Client makes DBA connection

to Target DB (orcldb)

DBA reads sensitive data

Page 43: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 43

Starting the TNS Proxy Remote IP = Target DB

Page 44: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 44

Manually registering proxy with same name as target DB

Page 45: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 45

Client connects to Target DB

again

DBA reads sensitive data

again

Page 46: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 46

Page 47: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 47

Configuration Changes

Standalone Databases

Disable remote registration in the TNS Listener – ‘dynamic_registration = off’ in listener.ora

Only allow secure connections – $IPC instead of $TCP

RAC Clusters

Use ASO (Now free for RAC users) and REQUIRE SSL – Certificate authentication will stop attackers from

registering new instances

Page 48: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 48

Buffer Overflows

• Simple: crash the server

• Advanced: load and run malicious code

Crash or Exploit

• Like a SQL Injection vulnerability – Need vendor fix

Only a vendor patch fixes the issue

Page 49: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 49

Exploiting Buffer Overflows

Attack Target: – IBM DB2 LUW 9.1 Fix Pack 8

Privilege Level: – Any database user

Outcome: – Crash database server

Vulnerabilities Exploited: – Heap buffer overflow in built-in scalar function REPEAT

Page 50: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 50

Run the exploit.

No privileges

needed!

Connect to

the database

Page 51: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 51

No more

database.

Page 52: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 52

Freely Available Exploit Code

Page 53: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 53

Privilege Escalation

• Vulnerabilities can lead to low privileged users becoming DBA

I am now DBA

• Risk management when considering patch rollout

Only a vendor patch fixes the issue

Page 54: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 54

Exploiting Privilege Escalation

Attack Target: – Oracle11g Release 2

Privilege Level: – CREATE PROCEDURE and EXEC on

MDSYS.RESET_INPROG_INDEX

Outcome: – Full control of the database (assume DBA role)

Vulnerabilities Exploited: – Privilege escalation in MDSYS.RESET_INPROG_INDEX

Page 55: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 55

The Attack – Step by Step

1. Setup a) Create procedure myproc containing code to grant my

account DBA

b) Create function myfn containing code to create a trigger in the system schema. The trigger calls myproc.

2. Exploit a) Exploit the vulnerability, causing MDSYS to run myfn.

Creates the trigger.

3. Reap Rewards a) Use PUBLIC privileges to run a SQL statement that

causes the trigger to fire. System runs the trigger, which calls myproc which grants my account DBA.

Page 56: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 56

Setup step 1: Create attack

code (myproc) to grant DBA

privileges to user1

Page 57: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 57

Setup Step 2: Create a

function (myfn) that

creates an evil trigger that

calls the attack code

(myproc)

Page 58: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 58

Run the exploit. Causes

MDSYS to run myfn

and create the evil

trigger.

Insert statement causes

the evil trigger to run

myproc and grants DBA

Page 59: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 59

Attacker is now DBA

Page 60: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 60

Google Told Me All About It…..

Page 61: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 61

Privilege Escalation

• Since the weaknesses are in the DBMS itself, vendor patches are required to fix

• Minimize the attack surface

• Least privileges

• Monitor database activity

• Log calls to known vulnerable functions

• Baseline privileges and role memberships – Audit on regular basis

How to protect the DB

Page 62: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 62

Unpatched Database

• Exploit/POC code emerges quickly

• Patches can be reverse engineered

Vulnerable the day the patch is released

• Critical business systems? Low risk systems?

• Have a patch plan in place

• Don’t forget low risk systems

• Audit/monitor vulnerable functions

• Know what’s vulnerable

What do we patch first?

Page 63: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 63

Unencrypted Data – At Rest and In Motion

• File system encryption

• Transparent Data Encryption (TDE)

• http://www.teamshatter.com/topics/general/team-shatter-exclusive/encrypting-data-at-rest/

Data at Rest

• SSL

• Oracle ASO

• Kerberos

• http://www.teamshatter.com/topics/general/team-shatter-exclusive/network-encryption-in-modern-relational-database-management-systems/

Data In Motion

Page 64: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 64

Scared yet? Paralysis setting in?

Page 65: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 65

Not Doing Anything

• Does Not Work

• Sony, Epsilon, etc.

Reliance on Perimeter Protection Only

• Who are the stakeholders?

• DBA? Security?

Who’s responsible for DB Security?

Page 66: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 66

Credits

David Litchfield

Esteban Martinez Fayo

Martin Rakhmanov

Evgeny Legerov

Page 67: Hacking and Defending the Big 4 Databases€¦ · Exploiting Privilege Escalation Attack Target: –Oracle11g Release 2 Privilege Level: –CREATE PROCEDURE and EXEC on MDSYS.RESET_INPROG_INDEX

Application Security Inc. All rights reserved. Confidential 67

References

Team SHATTER: http://www.teamshatter.com/

Database Top 10: http://www.teamshatter.com/topics/general/team-shatter-exclusive/top-10-database-vulnerabilities-and-misconfigurations/

TNS Poisoning: http://www.teamshatter.com/topics/general/team-shatter-exclusive/oracle-0-day-tns-listener-poison-attack/

Vulnerability Disclosures: http://www.securityfocus.com/vulnerabilities