New Attack Exploits "Safe" Oracle Inputs 118
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."
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
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:1, Insightful)
This is IT security equivalent of a strawman argument.
Re: (Score:1)
This is IT security equivalent of a strawman argument.
[OT] yes, I saw the typo (too late) (Score:1)
Re: (Score:2)
string_var
vs
string_var
I've always contende
Re: (Score:1, Offtopic)
This is why assuming a datatype, even the ones advertised as constant, or immutable (strongly typed), are bad.
I might be missing some DBA jargon here though, about schema types, instead of language.
Re: (Score:2, Informative)
Re: (Score:1)
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Layne
Re: (Score:2)
Re: (Score:2)
Consider this pseudo-code at the app layer.
Select ROWSET from DB
Foreach row, perform some update
Update ROWSET in DB
now consider that call as a proc call that does a single, paramterized UPDATE.
And most nightly batches should live on the DB for that same reason.
And in order t
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
Re: (Score:2)
In this case setting NLS_DATE_FORMAT can be done by ANYONE regardless of whether they have ALTER SESSION granted.
</quote>
Still, you need to be already able to inject in order to issue a modified "ALTER SESSION".
<quot
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.
Re: (Score:2, Informative)
Also
Re: (Score:1)
While I do try to use stored procedures for all projects, parameterised queries is a very good second choice. I don't understand why they're not used as much.
When you get into unvalidated inserts and selects, that's what drives me nuts.
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: (Score:1)
Re: (Score:2)
Re:heh (Score:5, Insightful)
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)
It has everything to do with exploits. It means that if there is the slightest chance that something will be exploited then it will be exploited even if the attacker has to rely on brute force methods to find the right entry.
Re: (Score:2)
Re: (Score:2)
And while the doc doesn't say it, you could put an anonymous block in there, so you don't need privs to create anything....you just rely on the privs of the connection to execute cod
Re: (Score:1, Informative)
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.
nothingforyoutoseehere (Score:1)
Re: (Score:1)
noob.
SELECT decode( programmer_is_smart_and_validates_data, 1, 'no_big_deal', 'he_has_bigger_worries' ) FROM dual;
Re: (Score:2)
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.
Re: (Score:1)
Re: (Score:1)
I can't think of a reason why anyone would want to use a stored procedure that builds dynamic SQL. For this type of thing, you should use a parameterized SQL query with a good provider like the Oracle Data Provider for .NET. If you always use the Parameter objects instead of concatenating them to the query text, you should be ok.
This seems to only really affect poorly written code. If developers were trained in best practices, we would have more secure software. Sadly, a lot of the books out there tha
Re: (Score:2)
I agree with the rest of your point, however.
DB Programming 101? (Score:1)
Re:DB Programming 101? (Score:5, Insightful)
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...
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: (Score:2)
Something like: "Have you ever had to work as a backend database developer?" "Yeah, I did in a 2 year contract at company XYZ" "Sweet, can you describe to me what you were doing?"
Re: (Score:1)
There might be schools that graduate folks without that knowledge, but I'd sure hope there wouldn't be many of them.
Re: (Score:2)
I can't say I've surveyed all of the schools, but I know enough people from various schools to beleive its the monitory that requires it (and that ironically, the lower rated schools are more likely to have it as mendatory, go figure!).
I r
Re: (Score:2)
I think the main reason that most CS courses don't require it is that CS is a very broad discipline that could be used for embedded programming, OS programming, game programming, etc.
Re: (Score:1)
I'm very skeptical of any MIS class having adequately covered the fundamentals -- schema normalization rather than form building, for example. That might just be a symptom of the school where I went to, OTOH, where the MIS courses (in the view of the CS department, at least) had nothing which in any way could be associated with "rigor".
Frankly, I think that inadequate coverage of a topic is worse than none at all -- if folks have the impression th
Re: (Score:2)
Layne
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: (Score:1, Offtopic)
Brother, can you spare a decent PM?
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.
Re: (Score:3, Interesting)
1. User validation = stupid "have you filled out these fields" validation
2. Application validation = application logic validation
3. Data
Re: (Score:2)
One method that I used that worked amazingly well was to use stored procedures with strict validation for all data access to/from the databases. No one had any access except explicit execute access to the stored procedures. Yeah, it was harder to design, but it flew. Porting to other app servers was really easy too, the procedures did all of the data work.
Some de
Re: (Score:2)
DB backend <--> DB API on app server #1 <--> Apps on app server #2 <--> GUI/web/whatever
The DB API is the general glue between your apps and the server. But then on most apps you can just stick that in the DB as stored procedures, as you've done.
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
Re: (Score:2)
So get the culture from the request, parse the date, if it throws an exception, return an error, otherwise pass the -datetime object- (not the string!) to the database API, and there really isn't anything that can happen. Even if an invalid date was
Again you miss the point (Score:2)
Re: (Score:2)
the database isn't. This is the perfect example of something that
can be easily done in parallel. The real problem is that you
have distributed enforcement of business rules and the
possibility that rules aren't properly enforced when they are
pushed out away from the database.
Although even this is fairly easy to manage.
Bog down the database and you bog down everyone.
Re: (Score:1)
That being said, I might be spoiled using SQL server. I've done some setups where a SQL server (sometimes MSDE) runs on the app server and enforces the rules (with some server caching tables as well) and passes data out to a SQL server cluster which holds the actual data. (It's really hard to explain without showing diagrams and violating my NDA, but it worked well f
security super-genius (Score:1, Offtopic)
The wikipedia entry on IQ does not contain the word "genius", let alone "super-genius".
So if someone (preferabl
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: (Score:2)
Does it look like this? (Score:2, Funny)
First Post!!!!!!!!!!
It's like Vulnerable Squared! (Score:1)
From comic to reality (Score:5, Funny)
Re: (Score:1)
The real question is:
Would that be illegal?
Re: (Score:2)
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)
Why validate when you can sanitize? (Score:1)
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, cha
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.
Re: (Score:2)
find(
Ruby on Rails will *replace* ? with the my_test that it escapes! I have no idea what they were thinking. And I do agree with you that parameterized queries are the only safe way, and should be the ONLY way to actually query databases. Heck, it is faster for recurring queries because all you have to do is pass the parameters and
Re: (Score:2)
Re: (Score:2)
You're still using dynamic SQL; you should use parametrized queries.
Re: (Score:1)
Simpler prevention (Score:2)
This is either "Nothing to see here, move along." (Score:2)
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
Re:This is either "Nothing to see here, move along (Score:2)
Re: (Score:2)
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
Does it work on Oracle 10.2.0.3 ? (Score:1)
Re: (Score:1)
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.