Pete Finnigan's Oracle Security Weblog
This is the weblog for Pete Finnigan. Pete works in the area of Oracle security and he specialises in auditing Oracle databases for security issues. This weblog is aimed squarely at those interested in the security of their Oracle databases.
A security issue with OPR version 1.1.7
Niall says Oracle 10gR2 should be out on June 30 - for Linux
Protecting network based storage
A new version of OPR is released
Changes from the previous release:
15-06-2005 1.1.7 J.Spit
* Oracle client libraries are now dynamically opened/closed only for those operations that require them.
This goes for all platforms. This means you can use OPR on systems without an Oracle installation to
e.g. list, retrieve and delete passwords from the repository.
* added -f flag to forcibly add a password entry without verification on the database
* bugfix: ocisessionend function was not initialized
* bugfix: when retrieving a password, schemaname was case sensitive.
* currently database is converted to uppercase, and schemaname to lowercase. OSuser is left
untouched.
* raised max. repository entries from 1024 to 4096
* minor cosmetic changes
17-06-2005 1.1.7 J.M.Spit
* Removed possible buffer overflow in askPassword.
As Jasper said, enjoy!
Installing Oracle Password Repository (OPR) - a walk through
----------
Example to create OPR Repository for 10g on RHEL3 LINUX.
----------
These are the notes we used to install OPR on multiple 10g hosts.
----------
Authors:
qnxodba@gmail.com
brian.a.smith@duke.edu
--
Brian analyzed and resolved the error while loading shared libraries: libclntsh.so.10.1
After testing and reviewing potential risks I chose the approach to
create a symbolic library link in /usr/lib rather than create a statically
compliled OPR. You must test for Oracle library version conflicts.
--
---
-- Setup OPR on host
---
login oracle @minke
---
-- Create opr LINUX account
---
su - root
groupadd oprinstall # group owner of OPR files
useradd -c "Oracle Password Recovery" -g oprinstall opr
passwd opr
--
Note:
useradd -m (create home directory) -g (initial group) -G (supplementary groups)
--
---
-- Test accounts
---
su - root
groups opr
id opr
id oracle
--
[root@minke root]# groups opr
opr : oprinstall
--
[root@minke opr]# id opr
uid=605(opr) gid=605(oprinstall) groups=605(oprinstall)
--
[root@minke opr]# id oracle
uid=600(oracle) gid=600(oinstall) groups=600(oinstall),601(dba)
--
-- shell
login opr @minke
vi .bash_profile
set | grep -i ora
--
Note: see below for example profile
--
---
-- Install OPR
---
login opr @minke
-- (1) directory
cd /home/opr
rm -rf /home/opr/data
rm -rf /home/opr/prog
mkdir /home/opr/data
mkdir /home/opr/prog
chmod 700 /home/opr/data
chmod 700 /home/opr/prog
ls -al
--
-- (2) program
cd /home/opr/prog
ftp opr-1.1.6beta.tar.gz to /home/opr/prog
tar zxvf opr-1.1.6beta.tar.gz
--
cd /home/opr/prog/opr
./configure
make
strip src/opr
cp /home/opr/prog/opr/src/opr /home/opr
--
cd /home/opr
opr -c
ls -l $OPRREPOS
chmod 755 /home/opr
chmod 511 /home/opr/opr
chmod u+s /home/opr/opr
ls -al /home/opr/opr
chmod 555 /home/opr/opr.sh
chmod u+s /home/opr/opr.sh
ls -al /home/opr/opr.sh
--
Note: In RAC cluster put the repository on drive shared by all nodes.
This supports one OPR repository per database concept.
--
-- (3) script
login opr @minke
vi /home/opr/opr.sh
#!/bin/bash
OPRREPOS=/home/opr/data/repos.opr;export OPRREPOS
opr ${1} ${2} ${3} ${4}
--
[opr@minke opr]$ ls -l $OPRREPOS
-rw------- 1 opr oprinstall 352 Jun 24 16:08 /home/opr/data/repos.opr
[opr@minke opr]$ ls -al /home/opr/opr
-r-s--x--x 1 opr oprinstall 20240 Jun 24 16:07 /home/opr/opr
[opr@minke prog]$ ls -al /home/opr/opr.sh
-r-sr-xr-x 1 opr oprinstall 74 Jun 24 16:11 /home/opr/opr.sh
--
-- (4) library /u01/app/oracle/product/10.1.0/db_1/lib/libclntsh.so.10.1
su - root
ls -al /usr/lib/libclntsh.so*
ln -s /u01/app/oracle/product/10.1.0/db_1/lib/libclntsh.so.10.1 /usr/lib/libclntsh.so.10.1
chown oracle.oinstall /usr/lib/libclntsh.so.10.1
ls -al /usr/lib/libclntsh.so*
--
Note: This works for Oracle 10g only. Hosts with multiple oracle versions
may require another strategy like statically compiled opr because of the
risk of library version conflicts. Test thoroughly before implementing.
Some of the risks of adding library to /usr/lib (libclntsh.so.10.1) are at:
http://www-106.ibm.com/developerworks/linux/library/l-sp3.html
E.g. The problem is that if an attacker can control the underlying libraries used by a program, the attacker can completely control the program. For example, imagine that the attacker could run /usr/bin/passwd (a privileged program that lets you change your password), but uses the environment variables to change the libraries used by the program. An attacker could write their own version of crypt(3), the password encryption function, and when the privileged program tries to call the library, the attacker can make the program do anything -- including allowing permanent, unlimited control over the system. Today's loaders counter this problem by detecting if the program is setuid/setgid, and if it is, they ignore environment variables such as LD_PRELOAD and LD_LIBRARY_PATH .
--
-- (5) oracle .bash_profile modification
ORACLE_BASE=/u01/app/oracle;export ORACLE_BASE
OPR_BASE=/home/opr;export OPR_BASE
ORACLE_HOME=$ORACLE_BASE/product/10.1.0/db_1;export ORACLE_HOME
PATH=/usr/sbin:/sbin:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$OPR_BASE:$PATH
--
Notes: There are a couple bugs in the source.
(1) Typo shows lack of Solaris testing -
[opr@minke src]$ grep unload *
opr.c: unloadOraLibs();
>> Fix should be:
opr.c: unLoadOraLibs();
--
(2) The libclntsh.so.10.1 error is caused by setuid limiting dynamically loaded
libraries to those under /usr/lib (et.al.) and excluding LD_LIBRARY_PATH libs.
One solution to this problem is to copy and chmod to /usr/lib/libclntsh.so.10.1
--
E.g. Typical error from oracle unix account
[oracle@minke oracle]$ opr -r cald sys
opr: error while loading shared libraries: libclntsh.so.10.1: cannot open shared object file: No such file or directory
--
(3) In RAC cluster put the repository on drive shared by all nodes.
This supports one OPR repository per database concept.
--
---
-- Configure commands OPR repository
---
Note: One OPR repository per database, which holds all/any accounts for one database
--
login opr @minke
--
-- minke
opr -a calprec calgb oracle
--
-- orca (cluster)
opr -a calp calgb oracle
--
-- narwhal (cluster)
opr -a calp calgb oracle {should fail as duplicate entry}
--
-- pilot
opr -a cald calgb oracle
--
Note: opr -a
--
---
-- Test OPR examples
---
login oracle @minke
sqlplus "calgb/`opr.sh -r CALPREC calgb`@cald"
--
login oracle @orca
sqlplus "calgb/`opr.sh -r CALP calgb`@calp"
--
login oracle @narwhal
sqlplus "calgb/`opr.sh -r CALP calgb`@calp"
--
login oracle @pilot
sqlplus "calgb/`opr.sh -r CALD calgb`@cald"
--
Note: All the databases are used in CAPS even though entered as lowercase.
--
----------
-- OPR UNIX ACCOUNT
----------
vi .bash_profile
--
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
##########
# Login Sequence - Check if behaviour unclear
# /etc/passwd
# /etc/shadow
# /etc/group
# /etc/profile
# /etc/profile.d/*.sh
# ~/.bash_profile
# ~/.bashrc
# /etc/bashrc
##########
# User specific environment and startup programs
##########
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
DB_HOME=$ORACLE_BASE/product/10.1.0/db_1; export DB_HOME
OPR_BASE=/home/opr;export OPR_BASE
OPRREPOS=/home/opr/data/repos.opr;export OPRREPOS
ORACLE_HOME=$ORACLE_BASE/product/10.1.0/db_1;export ORACLE_HOME
#
##########
#PATH=$PATH:$HOME/bin
#PATH=/usr/sbin:/sbin:$PATH
PATH=/usr/sbin:/sbin:$DB_HOME/bin:$ORACLE_HOME/OPatch:$OPR_BASE:$PATH
#
export PATH
##########
#LD_LIBRARY_PATH=$DB_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
#LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
LD_LIBRARY_PATH=$DB_HOME/lib:/lib:/usr/lib:/usr/local/lib; export LD_LIBRARY_PATH
#
##########
unset USERNAME
--
----------
----------
----------
----------
That is it, I hope that people find this useful, thanks again to Mike for sharing it.
Ed informs us that 10gR2 should be out this month
An excellent XSS cheatsheet
Frank talks about Bruce Schneier's book "secrets and lies"
Grant talks about patch 2 for 9.0.4 for certified Linux and Mac clients
Doug followed up on DBA_REGISTRY
Orablogs seems to be down - or maybe not!
The problem seems to be with DNS servers. But first some security background. I like my posts to at least have some security content! - I thought I would check into Brian's site and see if i could see where the problem lies. I did a ping from my PC on www.orablogs.com and got no results. I then tried tracert, to see if I could see where the problem lies, again no result. So I next thought about accessing orablogs by using instead the IP Address instead of the domain name. First I need the IP address. I like the Netcraft site as it gives some great info about sites. Kevin Mitnick mentions this site in his book The Art of Intrusion : The Real Stories Behind the Exploits of Hackers, Intruders & Deceivers - this is where i found it from a while ago. Netcraft.com has a search box in the top left corner where you can check out a site’s hosting details. I entered orablogs.com and found out the IP address and also noted that orablogs has had its server details changed a few times this year. It is interesting to note that the nameserver, DNS admin and reverse DNS are marked as not known. I checked my own site and saw these details are present. This confirmed my suspicions. So i tried to access orablogs with http://83.170.75.145/orablogs/ and found that it works. I was able to view orablogs. Then i thought about DNS issues and used the site www.dnsreport.com and entered orablogs.com, the report shows some warnings and failures. As I said I have asked Brian what the problems are.
This is a good issue to look into; the moral of the story is that there are plenty of sites out there on the net that can divulge huge amounts about your own site or about anyone else’s. This information is effectively public. If you run a site or host an Oracle database to the Internet then beware of what can be found out about it.
Pete Finnigan is now a member of the Oaktable network
The three Oaktable books are :- PeopleSoft for the Oracle DBA (Oaktable Press) by David Kurtz, which I have not read but will buy and do so when I get chance. There is also Mastering Oracle PL/SQL: Practical Solutions by Connor et al. This book I have got and have read, it is excellent and worth reading. Finally the third book is Oracle Insights: Tales of the Oak Table which is also an excellent read. I am looking forward to seeing more books released by the Oak Table press.
An issue with DBA_REGISTRY
10gR2 adds a "wrap" package procedure, TDE and makes DBMS_OUTPUT output unlimited
Another particularly interesting paper is Arup Nanda's paper Part 1: SQL and PL/SQL Features which is to be part one of a set of papers in the Oracle Database 10g: Top Features for DBAs - Release 2 Features Addendum. This paper is very very interesting for those of us interested in security. The paper includes a description of how Transparent Data Encryption (TDE) will work in 10gR2. Arup also shows that TDE can be used to encrypt the columns in external tables. The most interesting part of this paper for me is the item about the new wrap database package. This is a new function is DBMS_DDL.CREATE_WRAPPED which will allow dynamic PL/SQL to be create wrapped in the database. Arup gives examples. There is also another function DBMS_DDL.WRAP that will output the convert PL/SQL code passed as an argument in a wrapped form. This can then be spooled to a file and created later in the database wrapped.
Arup then goes on to discuss another great new feature, conditional compilation in PL/SQL. This is a feature that I have wished for many times in the past. This feature works like the pre-processor in C. This means that conditional code can be added at compilation time rather than at run time. This is a great addition and Arup gives some examples. A good use for this would be to conditionally compile debug code in to your source to instrument the PL/SQL code as Arup shows.
The final interesting addition in 10gR2 is the fact that the package DBMS_OUTPUT can now have unlimited output and each line of text can now be of any length. I have had this issue many times in the past. The source for this package used to be shipped in earlier version 7 databases so it was possible to see roughly how it worked and implement your own version in a local schema to get around the issue in earlier versions but this is a useful addition to 10gR2.
Have a look at the rest of the links in Justin's post for more information on new additions in 10gR2.
Security is a major force in the new 10g Release 2 database
The item talks about the fact that Oracle have been releasing information about 10g R2 today and security is high on the agenda for Oracle's new release. Self management and increased XML support are also included. The writer talks about Sarbanes Oxley being a requirement for many firms now and that means that data has to be kept. This is an issue for companies, to be able to keep that data secure. 10g R2 will bring new encryption technology in the database that will allow transparent encryption of data without any developer intervention. This will make it easier for companies to encrypt the huge swathes of clear text data that they have stored that should be encrypted. This is particularly relevant where legacy applications are involved and re-development would be cost restrictive.
There are third party encryption solutions such as Application Security Inc's DBEncrypt product that allow data to be encrypted with relative ease in current versions of the database. The 10gR2 enhancements will make things easier of course. The new feature in 10gR2 allows the DBA to simply change a column definition to allow the data to be transparently encrypted.
The article goes on to talk about some of the other new functions / features set to be available in the 10gR2 database.
OT: RSS fixes just done
Changed my RSS feed to spit out the first 20 words and a link to the entry
Anyway I have changed my blog to output just the first 20 words to the RSS file and to also add a [read more] link at the end. This was the tricky bit to do. I use greymatter for my blog and greymatter doesn't support RSS file generation natively. I used the gm-rss perl script to create my RSS file. They offer some advice as to how to just add a specific number of words to the blog RSS file but they didn't give any clues on how to add a [read more] link at the end of the 20 words (or how ever many words you want). I managed to work this out for myself after a bit of revision on greymatter template variables. Anyway I hope that those who take my RSS feed like the new method!
Here goes with the first test run!
An interesting alternative technique to crack passwords
Britain's hi-tech crime wave
Oracle unveils its identity management suite
Another great Windows internals site
Sysinternals is a site run, created and maintained by Mark Russinovich and Bryce Cogswell. It includes a good array of free tools, source code and technical information useful to those exploring Windows itself or those wanting to monitor what a program is doing whilst it is running. This is something hackers and crackers do so you should be aware of the tools that hackers could use. Of course most if not all of these tools are also valid options for general monitoring and maintenance..:-)
The site includes a very impressive array of utilities including file and disk tools, security tools, networking tools, process and thread tools, system information tools and miscellanious tools. There is also a lot of source code for utilities, http://www.sysinternals.com/Information.html - (broken link) information, forums, newsletters etc. This is again a superb site for the depth of information and the large collection of free tools.
A nice Windows internals website
This, as I said is a slightly dated site but there are some useful tools and papers on there. The most useful is the APISpy32 utility that can be downloaded as a zip file called APISpy32. This utility can be used to spy on the internal structure of applications or the operating system itself. APISpy32 gets around some of the problems of similar tools such a breaking when used with large pieces of code. APISpy32 also monitors all API calls made by all active processes. It is dated and marked as supporting Windows 9x/NT/2000 and ME but I have had it running on XP.
There is also a good paper on how spying programs work. This paper is called "API Spying Techniques for Windows 9x, NT and 2000" and covers different methods for hooking API and DLL imported functions. This is an excellent detailed paper, again if a little dated.
Brian talks about why JPasswordField.getText() is deprecated
Whilst this is a Java specific issue example wise it is a good example for those writing code in any language that handles application or database passwords. As Brian points out passwords could be grabbed from memory on the machine or from swap files. Nice post!
A book on Peoplesoft for the Oracle DBA
I have not seen the book, just the descriptions, when I next get a chance to look in Borders I will check if its in else probably will order it.
Shay talked about version control through JDeveloper
OT: Another Apple post
Back to the plot... As I said I was in Borders looking for the Apple 1 replica book and by chance came across another book about Apple called Revolution in The Valley which I picked up with interest. I have read most books on the personal computer revolution and its history. My favourite being Steven Levy's Hackers: Heroes of the Computer Revolution but I also liked his book on the history of Apple and Macintosh - Insanely Great: The Life and Times of Macintosh, the Computer That Changed Everything. The new Andy Herzfeld book is very well laid out and designed and looks like a very interesting read. There is a forward by Steve Wozniak that says this is the best and most true book that he has read about the history of Apple and the Mac. The book includes loads of photos and even copies of Andy's notebooks from the time. The book is based around short stories that Andy had written down and published on a website www.folklore.org about Apples history and the history and memories of creating the Mac. There are a number of other authors that have now written for the site and you can search and add comments. This is a good website. The book -
Revolution In The Valley: The Insanely Great Story of How the Mac Was Made
- is based on the site and includes key events and stories mostly written by Andy. Anyway i bought it and will read it mostly because I like these types of history books.
Of interest this evening i also note that Mark is also talking Apple in his post Apple Move To Intel Processors From 2006. This is an interesting post by Mark and could prove a good alternative platform for Oracle in the future.
OK, that is it, back to Oracle security now..:-)
Interesting post in Amis about "who called me"
A truss like tool for IBM AIX and a file undelete program
If you are interested in security then you need to be aware of the techniques that hackers can use to find out how your applications work.
Thinking about trace methods made me remember my good friend Phil's program libtrace that was written a few years ago. Phil wrote the C and PowerPC assembler code to hook calls made to functions in dynamic link libraries for IBM AIX 4.3 and higher. This enabled Phil to get truss like functionality for the IBM. The code is available on Phil's companies page Useful Programs and Scripts. libtrace is included along with some other useful programs, for instance inf_vgda that Phil wrote to allow the manipulation of the VGDA area of a LVM managed physical disk. This all means that you can hot swap disks (as Phil says, "if you know what you ar doing").
Another program that is of interest is rsb also written by Phil that allows the superblock of a jsf file system to be read and dumped. This includes inodes of files that have been deleted. If this is the case and the physical space has not be overwritten it allows files to be "undeleted". This can be useful if something is deleted and you need it. But also remember that someone else could "undelete" files or data that you thought had been deleted.
Oracle reinforces their identity management software offerings
Default passwords for Oracle BPEL Process manager
I am always interested in default accounts and their default passwords. These are always a useful addition to an auditor’s toolkit. I have a good list of database usernames and passwords on my page
Oracle Default Password List and also a check tool on my page Oracle Default Password Auditing Tool.
Debu talked about EJB security hole
In the post Debu talks about how some customer’s complain that OC4J does not support anonymous EJB lookup and execution of EJB methods. Debu says
"In my opinion security is a practice that starts during development and I view this as a big security hole in the applications because you are leaving your EJBs in ?ejb30slsb? Applications to be executed by anyone and I will advise against doing this."
he goes on to say that many people have been doing similar for years with other application servers and that they had been looking at this for years but did not allow it out of the box. He then goes on to show an example of how to do it for those who do not care about security. He finishes with
"THINK twice before you do this!"
This is an interesting post because it shows a good lesson. In general if something is not possible or available out of the box and it’s a security risk then do not enable it. There are good reasons not to do so. If the product you are using is internet or Intranet facing then the risks are very high. People do love to have things made easy, including not having to authenticate or go through hoops to use something. If something that is a security risk is disabled then don't enable it!
Wait even enhancements in 10g
ooops forgot the link
DBA Audit 2.5 - An interesting audit product.
This looks like an auditing interesting product. Setting up and auditing Oracle can be very complex as it is a huge area to get to grips with. I wrote a paper for Security Focus some time back called "An Introduction to simple Oracle Auditing" - A link is available on my Oracle security papers page. DB Audit 2.5 works for other database products such as Sybase, DB2, MS SQL Server as well as Oracle and it’s a centralised tool that allows access to a set of built in reports. I have not had a chance to look at this software yet so cannot recommend it BUT from viewing the website and the product details it is certainly worth a look. There are a number of players in this product space now but this tool looks quite comprehensive. There is a free trial download available and also a white paper called DB Audit white paper.
OT: A book on how to build an Apple 1 replica
This post is off topic but for me very interesting. I have always been interested by the computer revolution and have read most of the classic books on the history of it, including Accidental Empires by Robert X Cringely and of course Hackers: Heroes of the Computer Revolution by Steven Levy of which I have 3 copies of, one of which has circumvented the globe twice with me.
The Apple book looks great and I will probably order it, whether I would build an Apple 1 or not is another thing. I did build a Microtan 65 around 1980 - which I still have in my loft along with an oscilloscope I built from scratch in 1979 / 1980. It would be great to see a detailed book like Apple 1 book for some of the other classic computers such as the MITS Altair 8800 - regarded as the first real micro-computer. Great idea for a book though, how to build a classic computer.
SANSFIRE is coming up very soon
I wrote the new 6 day hands on Securing Oracle track that is being presented there this year. The track is called SECURITY 509: Securing Oracle and will be taught by Josh Wright. Links for each course day give details of what is covered each day. Here they are:
Day 1 - Securing Oracle Foundations
Day 2 - Securing Oracle's Authentication Process
Day 3 - Oracle Access Controls - Configuration
Day 4 - Auditing Oracle
Day 5 - Networking, Backups and SQL*Plus
Day 6 - Securing Applications and an Introduction to 9ias
If you want to know more about Oracle security and securing your Oracle database then SANS is the best place to go for good training on Oracle security and for many other security courses.
A good book on reverse engineering
This looks like a great book, I will let you know when I have read it if it really is. The obvious question is why read a book like this? - Well for me because I am interested in anything security related and also as you know Oracle related. Reverse engineering is normally not something a DBA or anyone managing an Oracle system and applications should be concerned with but if you want to secure your applications then its is worth knowing what hackers get up to. If you understand the threats then you can better secure your applications and data. As Reg Holdsworth used to say on Cornonation Street "Knowledge is power". (For those not in the UK, Coronation Street is one of the most popular and long running soap operas here).
Steve has improved his Custom JDBC URL example
Thanks for the update Steve and for the clarification.
An interesting post about PeopleSoft and Oracle
The site then details some of the items that they feel Oracle should do to make Fusion a success. The whole list makes interesting reading but the one item that interested me was the one related to security. The author states that security integration is the key to success. Security companies such as Oblix and Netegrity are mentioned as companies familiar with securing ERP solutions. The suggestion is that industry standard tools if added to the product would make it an industry winner. As the author says, companies that are able to keep client data secure will triumph.
Interesting sentiments.
Steve has added an undocumented sample for fixed JDBC credentials
I am never convinced about hard coding usernames and passwords inside application source code that is then deployed into a number of locations that are under less control than the configuration file could be - Yes I know that in a lot of clients neither the file or the Java will probably be secured. The Java source can be either reversed quite easily or a string utility or binary editor used to extract the password quite easily. Of course a configuration file does not need to be reversed!, it can be simply read if access is gained. BUT, as I am not an expert in Steve's Java areas it is harder for me to know about the whole security landscape used. My opinion would be that if presented with two choices of either hard coding the password in a configuration file or in the source code, I would choose the configuration file as there are better potentials for securing the file as there is a better chance of centralising it rather than having the password in multiple deployments of the Java classes. That said neither solution is great for strong security - This is no reflection on Steve's example.
If you are concerned with good security then look at password repository solutions, or do not store the password, have it passed in if possible or use solutions such as LDAP. Of course always use the least privilege principle. This means ensuring that the privileges assigned to the user who's password is stored or hard coded is set to the minimums possible, this is sometimes hard to do especially with existing systems but it is worth the effort. If you seriously reduce the privileges to only what is necessary you lessen the risk of an attacker being able to do anything with an account if he learns its password.