1 00:00:00,000 --> 00:00:06,540 Well, my name is Esteban, and today I will be talking about hacking and protecting Oracle Database Vault. 2 00:00:08,980 --> 00:00:11,820 This is the outline of this presentation. 3 00:00:12,220 --> 00:00:16,280 First, we are going to see an introduction to Oracle Database Vault. 4 00:00:17,420 --> 00:00:22,580 This is quite a new topic for this kind of conferences, 5 00:00:22,860 --> 00:00:28,180 so I will be doing an introduction of what is Oracle Database Vault, 6 00:00:28,180 --> 00:00:33,680 what changes it introduces, and what are its elements. 7 00:00:34,240 --> 00:00:40,240 Then we're going to move to the most important part of this presentation, 8 00:00:40,560 --> 00:00:44,800 that are the attacks against Oracle Database Vault. 9 00:00:46,640 --> 00:00:51,640 We're going to see attacks that will look for operating system access 10 00:00:51,640 --> 00:00:58,100 in order to be able to compromise Oracle Database Vault and the Oracle Database. 11 00:00:58,980 --> 00:01:03,040 We are going to see how to impersonate the MaxSys user, 12 00:01:03,320 --> 00:01:07,020 that is the most important user in Oracle Database Vault, 13 00:01:07,620 --> 00:01:10,080 is the Database Vault owner user. 14 00:01:12,020 --> 00:01:16,940 Then we are going to see some special considerations for the Sys user, 15 00:01:18,180 --> 00:01:22,020 and how we can compromise Oracle Database Vault 16 00:01:22,720 --> 00:01:26,600 using SQL injection vulnerabilities in the Sys schema. 17 00:01:28,660 --> 00:01:37,900 After that, we are going to see some issues with native database auditing with the Sys user. 18 00:01:39,240 --> 00:01:44,340 Finally, we are going to see some additional protections and some conclusions. 19 00:01:48,460 --> 00:01:51,460 Well, what is Oracle Database Vault? 20 00:01:51,680 --> 00:01:56,020 It's important to know that it's an add-on to Oracle Database. 21 00:01:56,460 --> 00:01:58,160 It's not installed by Oracle Database Vault. 22 00:01:58,160 --> 00:02:03,620 By default, it's installed mainly to add security features 23 00:02:03,620 --> 00:02:08,920 that doesn't have the database and that are required, for example, 24 00:02:09,080 --> 00:02:14,100 for strict regulations such as Servant's Oxley or PCI 25 00:02:14,100 --> 00:02:21,320 that calls for a strict separation of duty inside the database. 26 00:02:21,760 --> 00:02:26,680 So Oracle Database Vault will allow for separation 27 00:02:26,680 --> 00:02:28,140 in the database. 28 00:02:28,160 --> 00:02:30,920 In the activities such as account management, 29 00:02:32,240 --> 00:02:35,360 database resource management, and data security. 30 00:02:39,440 --> 00:02:44,500 This add-on product protects against attacks 31 00:02:44,500 --> 00:02:47,820 that can be done by highly privileged users, 32 00:02:48,600 --> 00:02:50,800 such as database administrators. 33 00:02:53,220 --> 00:02:56,900 So now the DBA doesn't have the... 34 00:02:56,900 --> 00:02:58,140 and it doesn't have the... 35 00:02:58,140 --> 00:03:11,060 access to database data. After we install this add-on product, there are some 36 00:03:11,060 --> 00:03:18,420 changes in the configuration of the database instance. The first thing 37 00:03:18,420 --> 00:03:22,380 that you can notice is that initializations parameters are changed 38 00:03:22,380 --> 00:03:28,140 to more secure values. This is documented in the Oracle database vault 39 00:03:28,140 --> 00:03:37,820 documentation. The recycle bin feature is disabled. Some privileges are removed 40 00:03:37,820 --> 00:03:47,140 from default Oracle roles like DBA role, because some of these privileges could 41 00:03:47,140 --> 00:03:52,260 lead to the compromise of database vault security 42 00:03:52,260 --> 00:04:00,080 features. Also the database native audit is configured to include more 43 00:04:00,080 --> 00:04:07,680 actions, but actually the the auditing is not enabled. Also there are some 44 00:04:07,680 --> 00:04:14,360 architectural changes like the sysout$ table is moved to the system 45 00:04:14,360 --> 00:04:22,060 schema and instead of the sys schema. Well but all these changes are 46 00:04:22,060 --> 00:04:31,120 not... that doesn't add any security feature, it can be done just by any 47 00:04:31,120 --> 00:04:40,260 database administrator to any database instance. What are important changes are 48 00:04:40,260 --> 00:04:47,080 some protections that are added. For example, there are some schemas that are 49 00:04:47,080 --> 00:04:51,940 protected by default with realm. We are going to 50 00:04:52,060 --> 00:05:01,380 see later what is realm. So the sys and system schema are protected, as well as 51 00:05:01,380 --> 00:05:10,960 some sensitive commands like the commands that can... that are related to 52 00:05:10,960 --> 00:05:17,760 account management. For example, create user, alter user, etc. All these changes 53 00:05:17,760 --> 00:05:21,940 are incompatible with some operations, 54 00:05:21,940 --> 00:05:28,740 of the database, like installing patches. So it is required to disable database 55 00:05:28,740 --> 00:05:37,700 vault when we want to install patches. Oracle documentations state how to 56 00:05:37,700 --> 00:05:44,940 disable Oracle database vault in order to install the patches, and that is what 57 00:05:44,940 --> 00:05:50,180 is found in the documentation. For Windows we can rename a DLL file, 58 00:05:51,940 --> 00:05:54,200 as well as the DLL file, that's what should not be changed, and on Linux and Unix systems, 59 00:05:54,380 --> 00:06:00,300 we can... we should execute a couple of commands to disable database vault. 60 00:06:04,700 --> 00:06:11,720 There are some other changes that all the releases that were in place in all the 61 00:06:11,720 --> 00:06:20,020 releases like the operating system authentication to the database disabled, and that login 62 00:06:20,020 --> 00:06:29,760 logging with sysdba privileges were blocked. This, of course, had a lot of problems and 63 00:06:29,760 --> 00:06:37,060 incompatibilities with some of the tools like RMAN and some other Oracle command line utilities. 64 00:06:37,840 --> 00:06:49,400 But there is a parameter in our PWD tool to enable the sysdba access as well as overwrite 65 00:06:49,400 --> 00:06:52,180 the sys password. 66 00:06:53,440 --> 00:07:02,660 So as you can see, if we have operating system access as the Oracle user, we are able to 67 00:07:03,640 --> 00:07:13,760 first, we are able to disable database vault and also we can overwrite and enable the sysdba 68 00:07:13,760 --> 00:07:14,160 access. 69 00:07:16,880 --> 00:07:19,380 Well, now let's see what's happening. 70 00:07:19,380 --> 00:07:26,600 These are the elements that are provided by database vault to, that one can use to 71 00:07:26,600 --> 00:07:28,400 secure further the database. 72 00:07:28,700 --> 00:07:36,160 The most important concept probably are the realms that are functional grouping of database 73 00:07:36,160 --> 00:07:40,220 schemas and roles that we want to secure. 74 00:07:40,440 --> 00:07:44,100 For example, when they are related to accounting or employees. 75 00:07:45,280 --> 00:07:49,360 So you can use a realm to control the database. 76 00:07:49,360 --> 00:07:55,820 For example, the use of the system privileges to a specific account or role that are part 77 00:07:55,820 --> 00:07:56,780 of this realm. 78 00:07:58,980 --> 00:08:07,040 So we, even if we have, for example, a select any table privilege or update any table privilege, 79 00:08:07,380 --> 00:08:12,880 we won't be able to access an object that is protected by a realm. 80 00:08:14,840 --> 00:08:18,960 Then we also have the factors that are named. 81 00:08:19,060 --> 00:08:19,340 Okay. 82 00:08:19,360 --> 00:08:27,820 Variables or attributes such as IP addresses, user locations, or session usernames. 83 00:08:28,580 --> 00:08:34,540 These factors can be used to control the access to the database. 84 00:08:34,940 --> 00:08:45,260 This can be used to provide protections against application bypass, ad hoc database access. 85 00:08:47,620 --> 00:08:49,200 Then we also have. 86 00:08:49,200 --> 00:08:55,920 We have some other concepts that we can use to further protect the database. 87 00:08:59,780 --> 00:09:08,240 Also there are some schemas that are installed when we apply this, when we install this 88 00:09:08,240 --> 00:09:10,800 add-on database vault product. 89 00:09:11,520 --> 00:09:17,800 The most important one is DVCs that contains all the database vault objects such as the 90 00:09:17,800 --> 00:09:18,580 tables, views. 91 00:09:19,200 --> 00:09:25,740 We also have some PLCQL packages that we can use to administer and configure the database 92 00:09:25,740 --> 00:09:26,420 vault installation. 93 00:09:27,200 --> 00:09:34,720 This schema, of course, is protected by a realm so that administrators can't access 94 00:09:34,720 --> 00:09:35,240 it. 95 00:09:35,680 --> 00:09:46,080 The DVF schema that is also part of database vault is used to, for retrieve, to retrieve 96 00:09:46,080 --> 00:09:46,860 factor identities. 97 00:09:47,400 --> 00:09:48,760 It has functions to. 98 00:09:48,760 --> 00:09:52,820 To retrieve IP address, session username, et cetera. 99 00:09:55,660 --> 00:10:02,420 There are some roles that are provided by Oracle database vault that we can use to give 100 00:10:02,420 --> 00:10:07,260 the necessary authorization to administer or to use database vault. 101 00:10:07,940 --> 00:10:13,640 The most important role or the most full privileged role is DV owner. 102 00:10:15,840 --> 00:10:18,560 And we also have a DV realm owner. 103 00:10:18,640 --> 00:10:18,740 And we also have a DV realm owner. 104 00:10:18,740 --> 00:10:26,040 That is an owner of a realm, but DV owner is the owner of all the database vault. 105 00:10:27,300 --> 00:10:29,340 So it's the most privileged user. 106 00:10:31,320 --> 00:10:39,940 Then we have a DV account manager that is used to, for account managing, it can create 107 00:10:39,940 --> 00:10:43,500 users or alter user passwords. 108 00:10:46,260 --> 00:10:48,060 Then we have DV sec analyst. 109 00:10:48,060 --> 00:10:55,180 That is the role that allows to run reports of database vault. 110 00:10:57,380 --> 00:11:04,420 There are some users that are created when we install the database vault. 111 00:11:04,620 --> 00:11:12,760 This is asked that the user is asked for the user names and password when one is installing 112 00:11:13,340 --> 00:11:14,060 database vault. 113 00:11:14,940 --> 00:11:16,880 So actually the user name. 114 00:11:16,980 --> 00:11:17,260 In a. 115 00:11:17,260 --> 00:11:22,760 installation can be different than the ones that I use here in the presentation 116 00:11:22,760 --> 00:11:30,000 but these names are the ones that are used through the documentation. So we 117 00:11:30,000 --> 00:11:36,140 have an account for the the Mac account that is the account responsible for the 118 00:11:36,140 --> 00:11:42,280 administration of database account. We must use this account to create or 119 00:11:42,280 --> 00:11:49,600 manage users and then another important user is the Maxis user that is the as I 120 00:11:49,600 --> 00:11:57,560 said before is a the the database vault owner. So it has permissions over the 121 00:11:57,560 --> 00:12:04,660 database vault realm that is the one that protects the DVC schema that that 122 00:12:04,660 --> 00:12:11,020 contains all the database objects of database vault. Well there are some 123 00:12:11,020 --> 00:12:12,220 security considerations 124 00:12:12,220 --> 00:12:20,400 that are documented. Here I enumerate a few. This presentation is not going 125 00:12:20,400 --> 00:12:27,640 to focus on these documented considerations. There are some 126 00:12:27,640 --> 00:12:33,700 considerations with PL-SQL packages such as UTL file. One can imagine that this 127 00:12:33,700 --> 00:12:41,660 is because this can provide file system access to anyone that has a 128 00:12:41,660 --> 00:12:42,200 file system access to anyone that has a file system access to anyone that has a 129 00:12:42,200 --> 00:12:49,540 access to these PL-SQL packages. Also it is documented that there there are some 130 00:12:49,540 --> 00:12:54,480 privileges that can lead to the compromise of database vault such as the 131 00:12:54,480 --> 00:13:02,820 one that we that are related to shop management, the recycle bin and the 132 00:13:02,820 --> 00:13:10,040 external procedures and there are also some trusted accounts that must be 133 00:13:10,040 --> 00:13:10,700 secured. 134 00:13:12,420 --> 00:13:16,080 The documentation says that the Oracle 135 00:13:16,080 --> 00:13:22,200 software owner and the sysdba users are accounts 136 00:13:22,200 --> 00:13:23,980 that much be trusted. 137 00:13:26,500 --> 00:13:34,160 Well now let's see what are the attacks that we are going that we can do to 138 00:13:34,160 --> 00:13:39,220 compromise the database vault. First there 139 00:13:39,220 --> 00:13:39,580 are未來的 140 00:13:40,040 --> 00:13:47,560 systems attacks, the attacks that will look for operating system access, being a 141 00:13:47,560 --> 00:13:54,240 user connected to the database. So we're going to see some examples of this. 142 00:13:56,220 --> 00:14:01,380 Also we are going to see that it is possible with a couple of system 143 00:14:01,380 --> 00:14:07,700 privileges to create and execute a procedure in the Maxis schema and 144 00:14:07,700 --> 00:14:17,100 impersonate the Maxis user. We are going to see that the Sys user can 145 00:14:17,100 --> 00:14:23,460 bypass the database vault and we are going to see that impersonating the Sys 146 00:14:23,460 --> 00:14:35,340 user through SQL injection we can compromise database vault. Also we're 147 00:14:35,340 --> 00:14:36,300 going to 148 00:14:37,700 --> 00:14:39,860 see that as user meet, we can do the same to see some vulnerabilities that are 149 00:14:39,860 --> 00:14:49,580 specific to database vault. Let's see some ways to get operating system access 150 00:14:49,580 --> 00:15:00,480 these operating system access as the Oracle software or xXX ____ threw ____ 151 00:15:00,480 --> 00:15:06,760 network user in Windows, allows an attacker to disable database valt. inoto 152 00:15:06,760 --> 00:15:07,680 ddâm 153 00:15:07,700 --> 00:15:12,940 write the sys password and enable the CTVI connections if they are disabled. 154 00:15:14,520 --> 00:15:20,520 There are many ways in which an attacker could get operating system access. 155 00:15:21,040 --> 00:15:29,520 There is the external procedure call method, the following example is about this method. 156 00:15:29,520 --> 00:15:42,200 We are going to see also that exploiting a buffer overflow vulnerability can allow for operating system access and the disable of database vault. 157 00:15:43,600 --> 00:15:49,880 Also it is possible to use a Java store procedures to get operating system access. 158 00:15:50,440 --> 00:15:56,160 And also through external shoves and creating a directory object. 159 00:15:56,640 --> 00:15:59,500 It could also lead to... 160 00:15:59,520 --> 00:16:03,560 file system access and the compromise of database vault. 161 00:16:04,840 --> 00:16:11,860 In addition, if we don't have the required privileges to perform this kind of attacks, 162 00:16:12,100 --> 00:16:17,020 we can use SQL injection vulnerabilities and use one of these attacks. 163 00:16:18,540 --> 00:16:27,040 Well, let's see now the first example with a demonstration, the method using an external 164 00:16:27,040 --> 00:16:27,900 procedure call. 165 00:16:28,420 --> 00:16:29,500 An external procedure call could be used to acquire a database vault. 166 00:16:29,500 --> 00:16:38,140 procedure is a procedure that is stored in a dynamic link library, in a function 167 00:16:38,140 --> 00:16:45,480 in a dynamic link library, so we first need to create a library of object on 168 00:16:45,480 --> 00:16:54,940 the database that points to an external DLL file and then we create a procedure 169 00:16:54,940 --> 00:17:04,940 that points to a function in that library, so there are some restrictions 170 00:17:04,940 --> 00:17:11,180 in Oracle, we can't load libraries that are outside the Oracle home 171 00:17:11,180 --> 00:17:18,540 lib directory in Linux and Oracle home bin directory in Windows, but 172 00:17:19,100 --> 00:17:20,040 I found 173 00:17:24,940 --> 00:17:32,460 can lead to execute operating system commands so we have for Windows we have 174 00:17:32,460 --> 00:17:39,960 the Visual C runtime library that has the system function to execute operating 175 00:17:39,960 --> 00:17:46,180 system commands and also there is another library in Linux the libos 176 00:17:46,180 --> 00:17:53,200 utils library that has an exec function to execute operating system commands 177 00:17:53,900 --> 00:18:02,060 so to perform this attack we need to privileges the create library and create 178 00:18:02,060 --> 00:18:11,260 processes privileges ...we just need first to create the library 179 00:18:11,260 --> 00:18:15,380 object inside the database this is done with the 180 00:18:15,380 --> 00:18:16,120 create library 181 00:18:16,120 --> 00:18:28,460 statement. There are examples for Linux and Windows. After we create the library 182 00:18:28,820 --> 00:18:34,800 object we have to create the procedure that points to an exported function in 183 00:18:34,800 --> 00:18:42,300 that library. So here I create a procedure that points to the system 184 00:18:42,300 --> 00:18:53,660 function and now I can use this os-exec-to- store procedure inside a plsql 185 00:18:53,660 --> 00:19:00,420 program to execute the operating system command I passed as a parameter. 186 00:19:02,000 --> 00:19:11,080 So after I execute this to create library and create procedure statement I 187 00:19:11,080 --> 00:19:11,500 can 188 00:19:11,500 --> 00:19:18,740 execute operating system commands as the Oracle user or system authority in 189 00:19:18,740 --> 00:19:30,000 Windows. So to disable database vault we can execute these two statements that 190 00:19:30,000 --> 00:19:37,960 are the ones that you execute to disable database vault and for Windows we can 191 00:19:37,960 --> 00:19:44,460 execute this any of these two statements it is different if we are talking about 192 00:19:44,460 --> 00:19:53,880 Oracle 10g or Oracle 11g because the name has the name the DLL file name has 193 00:19:53,880 --> 00:20:02,160 the release version in its name so let's see an example let's see the 194 00:20:02,160 --> 00:20:02,600 demonstration 195 00:20:15,340 --> 00:20:27,040 this SQL script contains the statements that I just show you so we create a test 196 00:20:27,040 --> 00:20:33,520 user and grant create session create procedure and create library privileges 197 00:20:35,740 --> 00:20:37,020 so this 198 00:20:37,960 --> 00:20:45,720 user doesn't have any database vault role granted so it shouldn't be able to 199 00:20:45,720 --> 00:20:52,780 disable database vault or compromise database vault in any way after I create 200 00:20:52,780 --> 00:20:57,200 the user I create the library the store procedure and then call the 201 00:21:03,140 --> 00:21:07,940 procedure that I just created to rename the DLL file 202 00:21:07,960 --> 00:21:15,640 look that we can use this the environment variable so we even didn't 203 00:21:15,640 --> 00:21:27,400 need to know where the Oracle home is located so let's see let's execute this 204 00:21:29,380 --> 00:21:37,340 this is this VM has Oracle 11g installed with db vault 205 00:21:39,080 --> 00:21:42,360 let's see first how the protections works 206 00:21:49,820 --> 00:22:00,040 let's suppose we want to protect the HR schema I will connect a system that is a 207 00:22:00,040 --> 00:22:07,480 DBA user and select from that schema and I will get all the results because 208 00:22:07,480 --> 00:22:07,940 I 209 00:22:09,220 --> 00:22:16,920 the HR schema is not protected yet. But I will create now a realm to protect this schema 210 00:22:18,400 --> 00:22:26,380 with these statements. I connect as the Database Vault owner user and then create a realm. 211 00:22:27,420 --> 00:22:35,300 I give it a name. Then I have an authorized user for this realm, the HR user. 212 00:22:35,300 --> 00:22:43,480 Then I will say that it must protect the HR schema and all its objects in this schema 213 00:22:43,480 --> 00:22:55,940 and gives a description of the realm. So after I create this realm, I will no longer be able to 214 00:22:55,940 --> 00:23:05,080 select from any table, even if I am a database administrator, I will get insufficient 215 00:23:05,080 --> 00:23:18,960 privileges. Error. But let's now disable Database Vault using this exploit. 216 00:23:29,180 --> 00:23:31,340 We are going to see here is the 217 00:23:31,340 --> 00:23:32,260 error. 218 00:23:35,400 --> 00:23:46,880 Here is the DLL. It just got renamed with an underscore. So the next time the Oracle 219 00:23:47,600 --> 00:23:51,300 instance is started, Oracle Database Vault will be disabled. 220 00:23:58,860 --> 00:24:04,580 I will restart the instance and check again if now I can 221 00:24:04,580 --> 00:24:07,060 access the HR schema. 222 00:24:09,220 --> 00:24:15,880 Well, it will, let's continue. It will take a bit to restart the instance. 223 00:24:16,720 --> 00:24:22,480 So there are a couple of things that we can do to protect against this attack. 224 00:24:23,400 --> 00:24:30,520 First, we can avoid granting the create library and create procedure privileges to user. 225 00:24:31,400 --> 00:24:34,020 Especially the create library privileges 226 00:24:34,580 --> 00:24:44,460 that is the one that allows to associate a database library to an external dynamic link library. 227 00:24:46,320 --> 00:24:52,160 Or at least enable these privileges just for the period of time that is needed. 228 00:24:53,760 --> 00:25:04,560 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. 229 00:25:04,560 --> 00:25:12,500 what libraries can be loaded. So we can just name there the DLL files that we 230 00:25:12,500 --> 00:25:19,960 know are secure and that our applications need. And no other DLL 231 00:25:19,960 --> 00:25:30,440 files will be able to be loaded. Let's see. It is still restarting the database. 232 00:25:33,060 --> 00:25:41,060 So we are next attack example that will get operating system access is the Java 233 00:25:41,060 --> 00:25:48,960 attack. There are two approaches that I will be showing today. One that doesn't 234 00:25:48,960 --> 00:25:55,940 require special privileges and it uses the vulnerabilities discovered by 235 00:25:55,940 --> 00:26:00,260 David Litchfield this year and that are fixed 236 00:26:00,260 --> 00:26:11,040 in April 2010 CPU. Or another way to do it is that using the functionality that 237 00:26:11,040 --> 00:26:19,460 is available to privileged users. The privileged users that Database Vault 238 00:26:19,460 --> 00:26:29,980 is supposed to protect from. Well the database was restarted. Let's see now if 239 00:26:29,980 --> 00:26:30,160 the 240 00:26:30,160 --> 00:26:42,020 protections are still in place. I will connect a system and try to select from 241 00:26:42,020 --> 00:26:55,380 the HR. And as you can see now I can select from the HR schema so Oracle 242 00:26:55,380 --> 00:26:57,280 Database Vault was disabled. 243 00:27:02,900 --> 00:27:12,460 Let's enable it again so we can continue our demonstrations. 244 00:27:20,280 --> 00:27:27,260 So there are basically two steps for this attack, for this 245 00:27:27,260 --> 00:27:33,980 attack that we'll use the Oracle Java functionality in Oracle to get operating 246 00:27:33,980 --> 00:27:39,720 system access. First we need to grant the Java privileges that are required to 247 00:27:39,720 --> 00:27:48,280 access operating system resources. This can be done in two ways. One is using the 248 00:27:48,280 --> 00:27:56,160 grant permissions store procedure but this one requires the Java admin role. This is the 249 00:27:56,160 --> 00:28:05,760 like the official or documented way to do it. Or we can use the import JVM 250 00:28:05,760 --> 00:28:13,080 prompts store procedure that are the ones that are with the Oracle Java vulnerabilities 251 00:28:13,340 --> 00:28:23,160 fixed in April 2010 CPU. So this method doesn't require any privileges because this store procedure 252 00:28:23,160 --> 00:28:25,480 can be called by any user. 253 00:28:27,480 --> 00:28:35,520 Then after we have the required Java privileges, we can we should create the Java store 254 00:28:35,520 --> 00:28:41,720 procedure that will contain the Java instructions to execute and operating 255 00:28:41,720 --> 00:28:49,900 system commands. These Java instructions are the standard Java for execute and operating 256 00:28:49,900 --> 00:28:55,940 system commands that will use the Java functionality to do that. Or we can use 257 00:28:55,940 --> 00:29:03,680 instead of create this Java store procedure we can call an existing Java 258 00:29:03,680 --> 00:29:11,600 class that Oracle had the Oracle Aurora util wrapper class that contained a 259 00:29:12,940 --> 00:29:20,520 function to execute operating system commands this one a are not available if 260 00:29:20,520 --> 00:29:37,300 we have April 2010 CPU applied so let's first see an example of using they we if 261 00:29:37,300 --> 00:29:45,440 we want the Java admin role so we can use these statements to grant the 262 00:29:45,440 --> 00:29:50,020 necessary Java privileges with these statements 263 00:29:50,020 --> 00:30:05,560 here I grant the necessary permissions to the one DBA user, after that I create a 264 00:30:06,260 --> 00:30:14,080 Java source that will take one argument that is the command that we want to 265 00:30:14,080 --> 00:30:23,900 execute and then create a java store procedure that will call this Java 266 00:30:23,900 --> 00:30:34,180 method so we can use it in in a PLCQL standard program so we can we could 267 00:30:34,180 --> 00:30:43,180 execute this this statement to overwrite the sys password as any pass and to 268 00:30:43,180 --> 00:30:44,060 enable it. 269 00:30:44,060 --> 00:30:53,520 sys dba access or we can use this other statement to rename the DLL file to 270 00:30:53,520 --> 00:31:00,880 disable database vault. Let's see how it works 271 00:31:16,680 --> 00:31:23,380 well this script contains the the same instructions we just seen in the slides 272 00:31:30,620 --> 00:31:43,060 so we have the DLL file with the correct name we are going to execute exploit 273 00:31:49,680 --> 00:31:52,860 and we will see that the DLL file will be renamed 274 00:32:13,080 --> 00:32:14,040 and we will see that the DLL file will be renamed 275 00:32:14,040 --> 00:32:21,340 Well, the way to defend from this attack is to restrict the Java admin role. 276 00:32:21,540 --> 00:32:29,600 That is the role that is needed to grant the Java permissions needed to access operating 277 00:32:29,600 --> 00:32:38,940 system resources or to remove the Java support from Oracle database if we don't need it. 278 00:32:41,500 --> 00:32:48,040 Let's see if, well, as we can see now, the DLL files has an underscore. 279 00:32:51,740 --> 00:32:57,080 So the database vault will be disabled. 280 00:33:02,280 --> 00:33:08,720 So we were able to disable database vault having the Java admin role. 281 00:33:11,180 --> 00:33:15,840 Let's see now a way to do this with no privileges. 282 00:33:18,220 --> 00:33:21,900 It is needed just these two statements. 283 00:33:22,300 --> 00:33:25,300 The first one gives the necessary permissions. 284 00:33:27,400 --> 00:33:34,020 Grant the necessary permissions to the user that is exploiting this vulnerability. 285 00:33:34,640 --> 00:33:37,400 And then we just use this. 286 00:33:37,400 --> 00:33:48,080 This function to call the Oracle Aurora UtilWrapper class, the main method in that class. 287 00:33:48,880 --> 00:33:54,900 And we just execute the operating pass as argument the operating system command we 288 00:33:54,900 --> 00:33:55,540 want to execute. 289 00:34:01,320 --> 00:34:02,000 . 290 00:34:02,000 --> 00:34:02,980 . 291 00:34:02,980 --> 00:34:03,180 . 292 00:34:03,180 --> 00:34:03,480 . 293 00:34:03,480 --> 00:34:03,600 . 294 00:34:03,600 --> 00:34:03,720 . 295 00:34:03,720 --> 00:34:03,820 . 296 00:34:03,820 --> 00:34:04,020 . 297 00:34:05,920 --> 00:34:06,480 . 298 00:34:09,780 --> 00:34:10,340 . 299 00:34:10,340 --> 00:34:10,840 . 300 00:34:10,840 --> 00:34:15,820 We start again with. 301 00:34:16,100 --> 00:34:16,460 . 302 00:34:16,460 --> 00:34:16,600 . 303 00:34:16,600 --> 00:34:16,620 . 304 00:34:16,620 --> 00:34:16,680 . 305 00:34:16,680 --> 00:34:16,740 . 306 00:34:16,740 --> 00:34:16,780 . 307 00:34:16,780 --> 00:34:16,880 . 308 00:34:16,880 --> 00:34:16,900 . 309 00:34:18,000 --> 00:34:18,560 Fuer. 310 00:34:18,620 --> 00:34:18,860 . 311 00:34:18,860 --> 00:34:19,860 . 312 00:34:19,860 --> 00:34:20,020 . 313 00:34:32,940 --> 00:34:33,500 . 314 00:34:34,020 --> 00:34:38,300 So the DLL now has the correct name. 315 00:34:39,820 --> 00:34:50,320 After I execute this exploit, we can see that the DLL file 316 00:34:50,320 --> 00:34:50,900 got renamed. 317 00:35:00,820 --> 00:35:06,580 So to defend from this attack, the one that doesn't use any 318 00:35:06,580 --> 00:35:12,840 privileges, we should apply the April 2010 CPU that fixes the 319 00:35:12,840 --> 00:35:17,140 Java vulnerabilities that allow to grant the Java 320 00:35:17,140 --> 00:35:17,540 permissions. 321 00:35:18,610 --> 00:35:20,340 Even if we are not. 322 00:35:20,340 --> 00:35:22,900 We don't have the Java admin role granted. 323 00:35:26,900 --> 00:35:34,440 Or we could remove, revoke the privileges from this DBMS JVM 324 00:35:34,440 --> 00:35:40,780 experiments package that is the one that is used to grant the 325 00:35:40,780 --> 00:35:41,740 Java privileges. 326 00:35:48,090 --> 00:35:50,080 Well, let's see now an example. 327 00:35:50,080 --> 00:35:56,120 How we can get operating system access and disable the database 328 00:35:56,120 --> 00:35:58,800 vault with a buffer overflow attack. 329 00:36:00,900 --> 00:36:04,240 This buffer overflow is in a stored procedure. 330 00:36:04,500 --> 00:36:09,580 So we need execute permissions on a vulnerable stored procedure. 331 00:36:17,220 --> 00:36:19,520 Well, this is the exploit. 332 00:36:19,520 --> 00:36:22,600 I won't enter much into detail. 333 00:36:22,980 --> 00:36:28,960 The vulnerable parameter is the dirpath parameter. 334 00:36:29,480 --> 00:36:39,840 So when the buffer overflows, the EVX resistor points to the start of this dirpath buffer. 335 00:36:40,480 --> 00:36:48,920 So here I enter the instructions that I want to execute that basically are the 336 00:36:48,920 --> 00:36:55,780 call to the system function of C runtime library and then the