Well, my name is Esteban, and today I will be talking about hacking and protecting Oracle Database Vault. This is the outline of this presentation. First, we are going to see an introduction to Oracle Database Vault. This is quite a new topic for this kind of conferences, so I will be doing an introduction of what is Oracle Database Vault, what changes it introduces, and what are its elements. Then we're going to move to the most important part of this presentation, that are the attacks against Oracle Database Vault. We're going to see attacks that will look for operating system access in order to be able to compromise Oracle Database Vault and the Oracle Database. We are going to see how to impersonate the MaxSys user, that is the most important user in Oracle Database Vault, is the Database Vault owner user. Then we are going to see some special considerations for the Sys user, and how we can compromise Oracle Database Vault using SQL injection vulnerabilities in the Sys schema. After that, we are going to see some issues with native database auditing with the Sys user. Finally, we are going to see some additional protections and some conclusions. Well, what is Oracle Database Vault? It's important to know that it's an add-on to Oracle Database. It's not installed by Oracle Database Vault. By default, it's installed mainly to add security features that doesn't have the database and that are required, for example, for strict regulations such as Servant's Oxley or PCI that calls for a strict separation of duty inside the database. So Oracle Database Vault will allow for separation in the database. In the activities such as account management, database resource management, and data security. This add-on product protects against attacks that can be done by highly privileged users, such as database administrators. So now the DBA doesn't have the... and it doesn't have the... access to database data. After we install this add-on product, there are some changes in the configuration of the database instance. The first thing that you can notice is that initializations parameters are changed to more secure values. This is documented in the Oracle database vault documentation. The recycle bin feature is disabled. Some privileges are removed from default Oracle roles like DBA role, because some of these privileges could lead to the compromise of database vault security features. Also the database native audit is configured to include more actions, but actually the the auditing is not enabled. Also there are some architectural changes like the sysout$ table is moved to the system schema and instead of the sys schema. Well but all these changes are not... that doesn't add any security feature, it can be done just by any database administrator to any database instance. What are important changes are some protections that are added. For example, there are some schemas that are protected by default with realm. We are going to see later what is realm. So the sys and system schema are protected, as well as some sensitive commands like the commands that can... that are related to account management. For example, create user, alter user, etc. All these changes are incompatible with some operations, of the database, like installing patches. So it is required to disable database vault when we want to install patches. Oracle documentations state how to disable Oracle database vault in order to install the patches, and that is what is found in the documentation. For Windows we can rename a DLL file, as well as the DLL file, that's what should not be changed, and on Linux and Unix systems, we can... we should execute a couple of commands to disable database vault. There are some other changes that all the releases that were in place in all the releases like the operating system authentication to the database disabled, and that login logging with sysdba privileges were blocked. This, of course, had a lot of problems and incompatibilities with some of the tools like RMAN and some other Oracle command line utilities. But there is a parameter in our PWD tool to enable the sysdba access as well as overwrite the sys password. So as you can see, if we have operating system access as the Oracle user, we are able to first, we are able to disable database vault and also we can overwrite and enable the sysdba access. Well, now let's see what's happening. These are the elements that are provided by database vault to, that one can use to secure further the database. The most important concept probably are the realms that are functional grouping of database schemas and roles that we want to secure. For example, when they are related to accounting or employees. So you can use a realm to control the database. For example, the use of the system privileges to a specific account or role that are part of this realm. So we, even if we have, for example, a select any table privilege or update any table privilege, we won't be able to access an object that is protected by a realm. Then we also have the factors that are named. Okay. Variables or attributes such as IP addresses, user locations, or session usernames. These factors can be used to control the access to the database. This can be used to provide protections against application bypass, ad hoc database access. Then we also have. We have some other concepts that we can use to further protect the database. Also there are some schemas that are installed when we apply this, when we install this add-on database vault product. The most important one is DVCs that contains all the database vault objects such as the tables, views. We also have some PLCQL packages that we can use to administer and configure the database vault installation. This schema, of course, is protected by a realm so that administrators can't access it. The DVF schema that is also part of database vault is used to, for retrieve, to retrieve factor identities. It has functions to. To retrieve IP address, session username, et cetera. There are some roles that are provided by Oracle database vault that we can use to give the necessary authorization to administer or to use database vault. The most important role or the most full privileged role is DV owner. And we also have a DV realm owner. And we also have a DV realm owner. That is an owner of a realm, but DV owner is the owner of all the database vault. So it's the most privileged user. Then we have a DV account manager that is used to, for account managing, it can create users or alter user passwords. Then we have DV sec analyst. That is the role that allows to run reports of database vault. There are some users that are created when we install the database vault. This is asked that the user is asked for the user names and password when one is installing database vault. So actually the user name. In a. installation can be different than the ones that I use here in the presentation but these names are the ones that are used through the documentation. So we have an account for the the Mac account that is the account responsible for the administration of database account. We must use this account to create or manage users and then another important user is the Maxis user that is the as I said before is a the the database vault owner. So it has permissions over the database vault realm that is the one that protects the DVC schema that that contains all the database objects of database vault. Well there are some security considerations that are documented. Here I enumerate a few. This presentation is not going to focus on these documented considerations. There are some considerations with PL-SQL packages such as UTL file. One can imagine that this is because this can provide file system access to anyone that has a file system access to anyone that has a file system access to anyone that has a access to these PL-SQL packages. Also it is documented that there there are some privileges that can lead to the compromise of database vault such as the one that we that are related to shop management, the recycle bin and the external procedures and there are also some trusted accounts that must be secured. The documentation says that the Oracle software owner and the sysdba users are accounts that much be trusted. Well now let's see what are the attacks that we are going that we can do to compromise the database vault. First there are未來的 systems attacks, the attacks that will look for operating system access, being a user connected to the database. So we're going to see some examples of this. Also we are going to see that it is possible with a couple of system privileges to create and execute a procedure in the Maxis schema and impersonate the Maxis user. We are going to see that the Sys user can bypass the database vault and we are going to see that impersonating the Sys user through SQL injection we can compromise database vault. Also we're going to see that as user meet, we can do the same to see some vulnerabilities that are specific to database vault. Let's see some ways to get operating system access these operating system access as the Oracle software or xXX ____ threw ____ network user in Windows, allows an attacker to disable database valt. inoto dd âm write the sys password and enable the CTVI connections if they are disabled. There are many ways in which an attacker could get operating system access. There is the external procedure call method, the following example is about this method. We are going to see also that exploiting a buffer overflow vulnerability can allow for operating system access and the disable of database vault. Also it is possible to use a Java store procedures to get operating system access. And also through external shoves and creating a directory object. It could also lead to... file system access and the compromise of database vault. In addition, if we don't have the required privileges to perform this kind of attacks, we can use SQL injection vulnerabilities and use one of these attacks. Well, let's see now the first example with a demonstration, the method using an external procedure call. An external procedure call could be used to acquire a database vault. procedure is a procedure that is stored in a dynamic link library, in a function in a dynamic link library, so we first need to create a library of object on the database that points to an external DLL file and then we create a procedure that points to a function in that library, so there are some restrictions in Oracle, we can't load libraries that are outside the Oracle home lib directory in Linux and Oracle home bin directory in Windows, but I found can lead to execute operating system commands so we have for Windows we have the Visual C runtime library that has the system function to execute operating system commands and also there is another library in Linux the libos utils library that has an exec function to execute operating system commands so to perform this attack we need to privileges the create library and create processes privileges ...we just need first to create the library object inside the database this is done with the create library statement. There are examples for Linux and Windows. After we create the library object we have to create the procedure that points to an exported function in that library. So here I create a procedure that points to the system function and now I can use this os-exec-to- store procedure inside a plsql program to execute the operating system command I passed as a parameter. So after I execute this to create library and create procedure statement I can execute operating system commands as the Oracle user or system authority in Windows. So to disable database vault we can execute these two statements that are the ones that you execute to disable database vault and for Windows we can execute this any of these two statements it is different if we are talking about Oracle 10g or Oracle 11g because the name has the name the DLL file name has the release version in its name so let's see an example let's see the demonstration this SQL script contains the statements that I just show you so we create a test user and grant create session create procedure and create library privileges so this user doesn't have any database vault role granted so it shouldn't be able to disable database vault or compromise database vault in any way after I create the user I create the library the store procedure and then call the procedure that I just created to rename the DLL file look that we can use this the environment variable so we even didn't need to know where the Oracle home is located so let's see let's execute this this is this VM has Oracle 11g installed with db vault let's see first how the protections works let's suppose we want to protect the HR schema I will connect a system that is a DBA user and select from that schema and I will get all the results because I the HR schema is not protected yet. But I will create now a realm to protect this schema with these statements. I connect as the Database Vault owner user and then create a realm. I give it a name. Then I have an authorized user for this realm, the HR user. Then I will say that it must protect the HR schema and all its objects in this schema and gives a description of the realm. So after I create this realm, I will no longer be able to select from any table, even if I am a database administrator, I will get insufficient privileges. Error. But let's now disable Database Vault using this exploit. We are going to see here is the error. Here is the DLL. It just got renamed with an underscore. So the next time the Oracle instance is started, Oracle Database Vault will be disabled. I will restart the instance and check again if now I can access the HR schema. Well, it will, let's continue. It will take a bit to restart the instance. So there are a couple of things that we can do to protect against this attack. First, we can avoid granting the create library and create procedure privileges to user. Especially the create library privileges that is the one that allows to associate a database library to an external dynamic link library. Or at least enable these privileges just for the period of time that is needed. Also, there is an interesting setting in Listener Aurora file. The xproc DLL setting can be used to restrict the user to the database library. what libraries can be loaded. So we can just name there the DLL files that we know are secure and that our applications need. And no other DLL files will be able to be loaded. Let's see. It is still restarting the database. So we are next attack example that will get operating system access is the Java attack. There are two approaches that I will be showing today. One that doesn't require special privileges and it uses the vulnerabilities discovered by David Litchfield this year and that are fixed in April 2010 CPU. Or another way to do it is that using the functionality that is available to privileged users. The privileged users that Database Vault is supposed to protect from. Well the database was restarted. Let's see now if the protections are still in place. I will connect a system and try to select from the HR. And as you can see now I can select from the HR schema so Oracle Database Vault was disabled. Let's enable it again so we can continue our demonstrations. So there are basically two steps for this attack, for this attack that we'll use the Oracle Java functionality in Oracle to get operating system access. First we need to grant the Java privileges that are required to access operating system resources. This can be done in two ways. One is using the grant permissions store procedure but this one requires the Java admin role. This is the like the official or documented way to do it. Or we can use the import JVM prompts store procedure that are the ones that are with the Oracle Java vulnerabilities fixed in April 2010 CPU. So this method doesn't require any privileges because this store procedure can be called by any user. Then after we have the required Java privileges, we can we should create the Java store procedure that will contain the Java instructions to execute and operating system commands. These Java instructions are the standard Java for execute and operating system commands that will use the Java functionality to do that. Or we can use instead of create this Java store procedure we can call an existing Java class that Oracle had the Oracle Aurora util wrapper class that contained a function to execute operating system commands this one a are not available if we have April 2010 CPU applied so let's first see an example of using they we if we want the Java admin role so we can use these statements to grant the necessary Java privileges with these statements here I grant the necessary permissions to the one DBA user, after that I create a Java source that will take one argument that is the command that we want to execute and then create a java store procedure that will call this Java method so we can use it in in a PLCQL standard program so we can we could execute this this statement to overwrite the sys password as any pass and to enable it. sys dba access or we can use this other statement to rename the DLL file to disable database vault. Let's see how it works well this script contains the the same instructions we just seen in the slides so we have the DLL file with the correct name we are going to execute exploit and we will see that the DLL file will be renamed and we will see that the DLL file will be renamed Well, the way to defend from this attack is to restrict the Java admin role. That is the role that is needed to grant the Java permissions needed to access operating system resources or to remove the Java support from Oracle database if we don't need it. Let's see if, well, as we can see now, the DLL files has an underscore. So the database vault will be disabled. So we were able to disable database vault having the Java admin role. Let's see now a way to do this with no privileges. It is needed just these two statements. The first one gives the necessary permissions. Grant the necessary permissions to the user that is exploiting this vulnerability. And then we just use this. This function to call the Oracle Aurora UtilWrapper class, the main method in that class. And we just execute the operating pass as argument the operating system command we want to execute. . . . . . . . . . . . We start again with. . . . . . . . . Fuer. . . . . So the DLL now has the correct name. After I execute this exploit, we can see that the DLL file got renamed. So to defend from this attack, the one that doesn't use any privileges, we should apply the April 2010 CPU that fixes the Java vulnerabilities that allow to grant the Java permissions. Even if we are not. We don't have the Java admin role granted. Or we could remove, revoke the privileges from this DBMS JVM experiments package that is the one that is used to grant the Java privileges. Well, let's see now an example. How we can get operating system access and disable the database vault with a buffer overflow attack. This buffer overflow is in a stored procedure. So we need execute permissions on a vulnerable stored procedure. Well, this is the exploit. I won't enter much into detail. The vulnerable parameter is the dirpath parameter. So when the buffer overflows, the EVX resistor points to the start of this dirpath buffer. So here I enter the instructions that I want to execute that basically are the call to the system function of C runtime library and then the