Slashdot Log In
New Attack Exploits "Safe" Oracle Inputs
Posted by
Soulskill
on Fri Apr 25, 2008 02:26 PM
from the it's-safe-until-it-isn't dept.
from the it's-safe-until-it-isn't dept.
Trailrunner7 writes "Database security super-genius David Litchfield has found a way to manipulate common Oracle data types, which were not thought to be exploitable, and inject arbitrary SQL commands. The new method shows that you can no longer assume any data types are safe from attacker input, regardless of their location or function. 'In conclusion, even those functions and procedures that don't take user input can be exploited if SYSDATE is used. The lesson here is always, always validate and prevent this type of vulnerability getting into your code. The second lesson is that no longer should DATE or NUMBER data types be considered as safe and not useful as injection vectors: as this paper (PDF) has proved, they are,' Litchfield writes."
Related Stories
This discussion has been archived.
No new comments can be posted.
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
Full
Abbreviated
Hidden
Loading... please wait.
heh (Score:5, Interesting)
In order to pull this off you need to have alter session priveleges. And you need to already have injected sql into the database- which means there is absolutely no point to taking the extra steps to modify some other data type to allow you to do what you have already done.
It's an interesting mental exercise but I don't think it really has an practical ramifications. If you've already handed out alter session to anyone using a form you've hosed yourself so many times over, playing with sysdate or number is the least of your worries.
Anything that reminds people to be careful about how they handle input is good, but I think a lot of people are going to think this is a bigger deal than it is.
Re:heh (Score:5, Insightful)
The only time when lack of validation is good practice is at extreme low level where you control the input. Otherwise, it usually signifies a coder that lacks the ability to think outside his own procedures.
Regards,
--
*Art
Parent
Re: (Score:2)
I don't know enough about sysadmin to make a good comparison, but my dba brain thinks this is like, saying 'hey you might think ls is pretty safe- but not if you give people root privileges before they use it.' But that might be a bad example.
Re: (Score:2)
SELinux is a good example of this -- unless something is explicitly permitted and happens in a permissible context, it's forbidden. Even for root.
The downside is that the more draconian the measures, the more likely it is that laziness or lack of understanding will win. Instead of taking five steps to securely opening a window slot, someone w
Re: (Score:2)
Re: (Score:2, Informative)
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Re: (Score:3, Informative)
In this case setting NLS_DATE_FORMAT can be done by ANYONE regardless of whether they have ALTER SESSION granted.
some observations:
1. in most web apps you wont have access to the database, just the webserver...the database should be
Thats what they said about cross site scripting. (Score:3, Insightful)
It best concluding non vulnerability without time and personal investment is naive and at best considering the large volume new security measurements in evidence prove that statements like these are foolish usually false and cause much more damage by breeding a false sense of security and complacency
Re:Thats what they said about cross site scripting (Score:2)
Re:heh (Score:5, Insightful)
Drives me nuts, because I'm the exact opposite, you don't get any (yes including read) access except a few stored procedures you need to read/write data.
Parent
Re: (Score:2, Informative)
Also
Re: (Score:3, Informative)
Reminds me of a webapp I worked on once. The programmer, in his infinite wisdom, would "SELECT * FROM TABLENAME", then stuff all 2500 records into a PHP array. Then he would promptly iterate over this array, selecting only two columns (of about thirty) he wanted from the desired rows matching his criteria.
I held my gag reflex long enough to perform only the requested change and make it functional. Then I declined all work after that.
Re:heh (Score:5, Insightful)
Parent
Re: (Score:2)
What does that have to do with anything? It's unlikely to be used not because it's unlikely to succeed, but because it's just a neat trick you can do with an already compromised system.
There's a big difference between "difficult to pull off" and "not worth bothering".
Re: (Score:2)
Re: (Score:3, Informative)
No, you don't. What you need is to somehow be able to modify NLS_NUMERIC_CHARACTERS or NLS_DATE_FORMAT. This is easily demonstrated with ALTER SESSION. But there might be a bug/exploit somewhere down the road that allows this in some other manner. Each of the two exploits are unusable, but combined ...
M.
Itsatrap! (Score:2, Offtopic)
Use ORMs (Score:3, Informative)
However, don't ORMs (and database-independant abstraction layers like AdoDB) protect against this?
Re:Use ORMs (Score:4, Informative)
Something like (pseudocode, the following wouldn't even pass syntax check, obviously, but its stupid hard to find a working case)
DECLARE @blah SOMEVULNERABLETYPE
Exec "select * from stuff where stuff.Blah =" + @blah;
If @blah was a string, everyone would realise its vulnerable...but in this case, numbers, dates, etc, would be assumed safe (how do you put code in a number??), when it supposingly was discovered its not safe.
However, if you went through a database driver (not even an ORM!), and made a prepared statement, passed a Java (for example) variable as parameter to a query, well, no invalid input will be able to get through. If you add an ORM layer on top of that which does extra validation, then even if all of the types (both java and database) were vulnerable, it wouldn't go through either...
This is really more of a theoritical vulnerabilty than a real one... it can't realistically be exploited in the wild, and its hard to even -imagine- a scenario in a well coded app.
Parent
Re: (Score:2)
I agree with the rest of your point, however.
nTier validation (Score:5, Insightful)
Validate at the client tier. (To save a return trip)
Validate at the application server tier. (to save a database trip)
Validate at the data tier. (to save your data)
Why is this so hard for developers to understand?
Re: (Score:2)
Re: (Score:2, Offtopic)
Re:nTier validation (Score:4, Insightful)
Preaching to the choir, I'm sure!
I was recently criticized for taking the time to do something "right" (i.e. verify and understand the problem and the technology needed to create a reliable solution). My boss indicated that his (crappy) code was meant as an "emergency fix". But come on, we all know that if his code had accomplished the job (however terribly), he'd have left it right there and never attempted to improve it.
Parent
Re: (Score:3, Interesting)
1. User validation = stupid "have you filled out these fields" validation
2. Application validation = application logic validation
3. Data
No no no (Score:2)
Validating dates, especially international ones, is enormously complex, and the validation process itself is extremely prone to errors and undesired behavior. If you expect all database clients to do full validation of all input data before passing it on to the database, you are going to see some really miserably performing clients, and not a lot of extra security. Each validation step would also have its own poin
Does it look like this? (Score:2, Funny)
First Post!!!!!!!!!!
From comic to reality (Score:5, Funny)
Re: (Score:2)
This is not merit a whitepaper (Score:4, Interesting)
This whole thing just sounds like an odd bug that someone at NGS found somewhere. It's certainly clever, but it's not a common pattern or new class of bug--and definitely not worthy of a white paper. What I find really odd is that Litchfield and the NGS guys used to do really impressive work. This is way below the bar of what they've produced in the past.
Zen Quote (Score:2)
Re: (Score:2)
Simpler prevention (Score:2)
Re:To all you type safe ninnies (Score:5, Informative)
I'll leave it as an exercise for you to figure out which one is which.
Parent
Re: (Score:2)
Re: (Score:2)
Just because it's not rigourously defined it doesn't mean you can't use it. You clearly know what they intended, and that's what is important here.
Re: (Score:2)
Exaggeration and spice belong in entertainment, not news. News should be factual and concise.
to what would otherwise be a fairly boring news piece.
If it's too boring to read it's too boring to post. However, the submitter (IINM) commented with a link.
Re: (Score:2, Informative)
http://en.wikipedia.org/wiki/Operation:_Rabbit [wikipedia.org]
MOD PARENT UP... (Score:2)
Wile E. Coyote, Sooper Jeenyus -- I like the sound of that.
Re:DB Programming 101? (Score:5, Insightful)
Parent
Re:DB Programming 101? (Score:5, Insightful)
Still cracks me up how in every interview I pass, I always get asked "Ok, so can you explain to me the difference between an inner and an outer join?" or "What is the main benefit of an index on a database table?". Shows the state of the workforce...
Parent
Re: (Score:2)
But then I'm an embedded realtime systems guy, not a database guy.
Re: (Score:2)
Its (for databases) on the same level as "Whats the difference between a WHILE and a FOR loop". Since the basics aren't taught, well...you have 500000 servers getting hacked (see article a couple notch down in today's list).
I'm sure there's a lot of th
Re: (Score:3, Informative)
Inner and outer joins always have a join condition.
An INNER JOIN only returns the records that satisfy the join condition.
An OUTER JOIN always returns all the results of one (LEFT or RIGHT) or both (FULL) tables, returning nulls for all the requested data in the other table when the join condition is not met.
Maybe that's not clear enough. I'll make a pair of contrived tables to demonstrate.
Re: (Score:2)
Re:Why validate when you can sanitize? (Score:5, Insightful)
Escaping/sanitizing is just one step up from validating. Let the -driver- do it for you, not the language or the framework. The database itself is the only one who truly knows how to handle itself, and drivers tap into that in prepared statements. -THAT- will protect you. Parameterized query APIs do -not- simply escape stuff in the back. Things are done at the level of the connection, chatting with the database API to create a cached/compiled version of the query, then plug in parameters -after- the query was parsed (so at that point its impossible to modify it).
That is -much- safer than just cleaning up a string (because it cannot abuse encoding/string related features), and has the extra advantage in many DBMS to also allow you to reuse query plan cache, thus improving performance and making it easier to benchmark and profile queries.
Parent