- 10.2.0.4 (1)
- 11g (3)
- Allgemein (11)
- BEA (1)
- checkpwd (4)
- CPUApr2008 (3)
- CPUJan2008 (2)
- CPUJul2007 (3)
- CPUOct2007 (1)
- CPUOct2008 (1)
- Data Vault (1)
- Database Vault (2)
- David Litchfield (4)
- Exploit (4)
- Forensics (3)
- Inguma (2)
- MacOS (1)
- Mary Ann (1)
- Oracle (2)
- Oracle Security (49)
- passwords (3)
- Podcast (1)
- rootkits (1)
- Security (9)
- Security Book (1)
- Sentrigo (1)
- software (2)
- Source Code Analysis (1)
- source code audit (3)
- SQL Injection (4)
- Tools (1)
- Trainings (1)
- 21 Nov 2008: Oracle Database Vault Privilege Escalation Exploit published
- 14 Okt 2008: Oracle Critical Patch Update October 2008 is out
- 20 Aug 2008: New Oracle bugs and BSQL Hacker
- 9 Aug 2008: July 2008 CPU Advisory - Windows Patch update for Oracle 10.1.0.5
- 29 Jul 2008: Exploit for Oracle Bea Weblogic - Apache Connector published
- 8 Mai 2008: Checkpwd 1.23 for MacOS Intel native released
- 16 Apr 2008: Oracle CPU April 2008 - Update
- 15 Apr 2008: Oracle Critical Patch Update April 2008 is out
- 11 Apr 2008: Looking Glass and Oracle 11g
- 11 Apr 2008: Oracle Critical Patch Update Pre-Release Announcement - April 2008
Oracle, white spaces and unexpected behaviour
Last week I saw the blog entry “select 1.x from t1” from Laurent concerning white spaces in select statements and Tom Kyte’s answer with a short explanation. Tanel Poder wrote a blog entry “Can you write a working SQL statement without using any whitespace?” too.
In my opinion and from the security perspective making whitespaces optional in SQL statements is a bad idea because it’s an unexpected behavior. And this is always a bad idea.
Here a real life example from Oracle itself:
Two years ago I found a SQL Injection Vulnerability in the web component of XMLDB.
The exploit was looking like:
http://url/xmldb?param1=’||(select sysdate from dual)||’
The result was a HTTP page containing the current date in an Oracle error message, a common exploit technique used by attackers.
The bugfix from the Oracle developer responsible for this component was to filter the URL for white spaces. Whenever a whitespace was part of the URL, the query was rejected. That’s why it was still possible to use functions (e.g. SYS_CONTEXT, …) but select statements were refused.
At that time I was not aware that SQL statements can be constructed without white spaces.
But with the knowledge from Laurent’s and Tanel’s blog entries I could rewrite the exploit
http://url/xmldb?param1=’||(select/**/sysdate/**/from”DUAL”)||’
A quick check in the Oracle PL/SQL code shows that some Oracle packages are using whitespaces as token separator (with the function instr()). I was also able to create a buffer overflow with alter session (11g) in SQL*Plus using this technique. I will digg deeper…
Quick question to my readers: Is this just an Oracle behavior or also possible in other databases like SQLServer or DB2.
3 Antworten auf “Oracle, white spaces and unexpected behaviour”
Antwort schreiben
Sie müssen als angemeldet sein, um einen Kommentar schreiben zu können.
15 Jan 2008 bei 13:25
mysql> select/**/current_user;
+—————-+
| current_user |
+—————-+
| root@localhost |
+—————-+
1 row in set (0.00 sec)
Best regards
Maxim
15 Jan 2008 bei 21:25
From SQl Server 2005 SQLCMD
1> select/*a*/count(*)/*b*/from/*c*/information_schema.tables
2> go
———–
559
(1 rows affected)
1> select top 3 1.x from information_schema.tables
2> go
x
—
1
1
1
(3 rows affected)
1>
15 Jan 2008 bei 21:27
Maxim and Gary,
thank you for the update.
Regards
Alex