New Attack Exploits "Safe" Oracle Inputs
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."
It's an interesting piece but when he points out that there really is little chance of it being used in the real world, that is an understatement. Using this method in the real world wouldn't even make sense.
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.
It's hard to believe that's how Micronians are made. Why don't we see it right now by having you both kiss one another?
IF programmer_is_smart_and_validates_data THEN PRINT no_big_deal ELSE PRINT he_has_bigger_worries
Knowledge is how to play a game, intelligence is how to win, wisdom is knowing what game to play.
Come on, do I have to tag this myself?
Absolute power corrupts absolutely. indymedia
Interesting flaw.
However, don't ORMs (and database-independant abstraction layers like AdoDB) protect against this?
{{.sig}}
Isn't a central premise taught in database programming 101 about NEVER assuming any input valid, and doing your own validation even if it was validated prior by a supposedly trustworthy source? I've never taken any classes in programming, so I would have no idea.
The 3 minimum levels of validation:
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?
Ok, this may be barely on topic (and I've had more on-topic posts than this one modded "offtopic") but the summary describes David Litchfield as a "super-genius". Neither the dictionary nor Wikipedia has entries on "super-genius". Well actually wikipedia does have it listed (linked) but it describes "a flash cartoon flash game flash animation web portal channel and studio" and a rock and roll band.
The wikipedia entry on IQ does not contain the word "genius", let alone "super-genius".
So if someone (preferably the super-genius who wrote the summary) can tell me what a "super-genius" is, I'd appreciate it. Actually I'd appreciate it more if submitters and editors wouldn't use jargon that I'm unfamiliar with and can find neither in the dictionary nor wikipedia.
mcgrew's razor: Never attribute to stupidity that which can be explained by greedy self-interest
Type safety and "safe" data types are two different things. One is a language construct intended to prevent errors in code through compile-time checking (though you pay in flexibility), the other is types of data that theoretically can be used in a database without doing validation checks.
I'll leave it as an exercise for you to figure out which one is which.
Javascript + Nintendo DSi = DSiCade
delete from comments where 1");--
First Post!!!!!!!!!!
So, in order to pull this off, you must first already have elevated permissions and the ability to execute arbitrary code. In other words, if you've been compromised, you can be compromised in new and exciting (well, maybe not exciting) ways. Wow, what an earth-shattering revelation!
Your comment "he points out that there really is little chance of it being used in the real world, that is an understatement" is reminiscent of those who proclaimed no one would need more than one 360k floppy.
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 and ignorance.
I don't think so. This is dependent upon circumstances where the horse is already out of the barn so to speak.
It's hard to believe that's how Micronians are made. Why don't we see it right now by having you both kiss one another?
This makes it clear it's only a matter of time before xkcd predictions become reality.
Gonzo Granzeau
"Nothing the god of biomechanics wouldn't let you into heaven for.." -Roy Batty
First off, this isn't a new class of attack. This type of attack is already known as second order SQL injection. Second, as several people have noted, you need to be able to execute the ALTER SESSION command. That means you're already issuing SQL commands directly. So, this attack is really only useful when can already inject, but need SQL to run in the context of a more privileged stored procedure. Finally, this attack relies on a very abnormal statement form. All said, that's a whole lot of dominoes that need to line up for a simple elevated SQL privilege.
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.
And to think I wasted my mod points on trivialities in the "Developer" section. If only I'd known something important was coming.
Wile E. Coyote, Sooper Jeenyus -- I like the sound of that.
2*3*3*3*3*11*251
If an unbreakable server breaks, and everyone has their hands over their heads chanting the oracle "unbreakable" mantra whilst picking each other asses with their toes, did it actually break?
NO SIG
Honestly, I never understand the people that constantly trumpet "Validate! Validate! Validate!" whenever they're dealing with a web/database app. If you're escaping/sanitizing your inputs properly, then you don't need to chase your tail making sure your users haven't entered something "evil".
The specifics vary by platform, but if you're building a dynamic SQL statement in SQL Server, for instance, you'd use the Replace function on the concatenated values to change any occurrence of ' to ''. For MySQL, change ' to \'.
It's very simple, very consistent, and very safe. This is what any decent parameterized query API will do behind the scenes. It's like the old anecdote: you can either spend a lot of time building an exhaustive filter list of offensive words that you don't want showing up in your tracking/order/confirmation codes, or you can just not use any vowels and be done with it.
Oracle is poo. Next!
Of course this is prevented by the simplest way to prevent SQL injection in Oracle - USE BIND VARIABLES. Each of his examples is thwarted by binding the parameters, instead of simple string concatenation.
Why, oh why, didn't I take the Blue Pill?
You are missing the point of the attack. The validation IS done, but the attack subverts it.
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 points of vulnerability.
Or an "We told you so". This attack vector relies on dynamic SQL inside pl/sql procedures.
Something that EVERY developer I ever learned from, and EVERY knowledgeable person on every Oracle forum I have frequented will tell you to avoid like hell.
Since :
1. It is an attack vector (as was shown now again)
2. It breaks compile time syntax checks and might put unverifiable errors into production code.
3. It breaks the built-in package/function dependency checks of pl/sql.
4. It is pretty much impossible to debug.
5. Is a possible disastrous resource hog because of multiple additional context switches between SQL and PL/SQL.
In my 8 year career of programming in pl/sql I have use dynamic SQL exactly at TWO times, and both times I programmed it in a way that dynamic SQL was executed in a read-only schema and returned exactly one result which was put into a variable and then sanity checked.
We are not talking about using some kind of framework. We are talking about THE ACTUAL FRAMEWORK. You folks imagine that there is some magic perfect code down there that you just call to parse a date and you forget that it actually has to implemented somewhere. Oracle has been ported to roughly a zillion different platforms. Do you really think they are going to rely on the platform to parse their dates?
Your argument is compelling except for the fact that many Oracle customers are pretty clueless and will not program with the excellent rigor that you do. This is compounded by Oracle's overblown security claims, which gives a false sense of security to less skilled developers.
Why is it that every time I see a headline detailing a new attack thinking I might actually learn something new I take the bite only to be severly disappointed moments later when I realize the author is in fact an idiot or simply spouting what should have been common knowledge.
... I don't much care what your execuse is deserve everything you get. I can go on and on but you get the picture I hope.
I totally tuned out after seeing the line "execute immediate" and ALTER SESSION.. Anyone who doesn't keep their data tiers outside of their users grubby little hands deserves what they get especially concidering Oracles piss poor security record.
Anyone who builds strings in procedures that even go near user input and then has the audacity to execute them
I realize bulk portions of Oracles code base are older than time itself and in some respects Oracle is brain damaged beyond comprehension -- '' IS NOT NULL FOR THE LOVE OF EVERYTHING HOLY but none of this even remotely passes as an execuse to ever be succeptable to such a "new" technique.
That is unfortunately true.
I remember one case where I had a discussion with one "developer" on a discussion board who tried to change his application which :
to
And he claimed he made it "more secure by using bind variables"
Thats like making your front door more secure by buying a very sophisticated $1000 lock and then putting that lock on a pedestal beside your door and dusting it weekly. ;-)
s/extendend/extended/
It's better to be the foot on the boot than the face on the pavement. ~~ tkx Kadin2048
s/extendend/extended/
College-Pages.com - Online Colleges, Degrees, and Programs
Did anyone actually tried this vulnerability ? I tried it on one of our test systems (Oracle 10.2.0.3.0) but can't reproduce the examples (can't hack the SYSDATE function with ALTER SESSION). Has this been fixed in recent Oracle versions ?