Kaminsky Offers Injection Antidote
ancientribe passes along this excerpt from DarkReading.com: "Life's too short to defend broken code. That's the reason renowned researcher Dan Kaminsky says he came up with a brand-new way to prevent pervasive SQL injection, cross-site scripting, and other injection-type flaws in software — a framework that lets developers continue to write code the way they always have, but with a tool that helps prevent them from inadvertently leaving these flaws in their apps. The tool, which he released today for input from the development and security community, basically takes the security responsibility off the shoulders of developers. Putting the onus on them hasn't worked well thus far, he says. Kaminsky's new tool is part of his new startup, Recursive Ventures."
As soon as I hit "deliverable" in the first paragraph, warning bells went off. When "productize" appeared as a verb in the second paragraph, I closed the browser window. Sorry, but my experience tells me that the article is simply not worth reading.
Shutting down free speech with violence isn't fighting fascism. It IS fascism!
Parameterized SQL, or prepared statements, completely prevent SQL injection attacks. They might also speed things up in some circumstances. Why not simply use them exclusively?
Forget magic. Any technology distinguishable from divine power is insufficiently advanced.
might like what formal verification guru Adam Chlipala (http://adam.chlipala.net/) has been doing: http://impredicative.com/ur/
This is a very cool special purpose language that generates fast native code for web pages, and statically guarantees
the absence of injection and xsrf attacks, and also of broken links and other sorts of errors that plague lots of web sites.
This sounds an awful lot like a special version of mysql_real_escape_string() with extra buzzwords.
# cat
Damn, my RAM is full of llamas.
There is a slideshow at http://www.scribd.com/doc/33001026/Interpolique on the product. At this time having problems accessing it, so have not read the full thing.
What the product does is go through your code and change in-line SQL to code like this
select * from table where fname=b64d("VEhJUyBJUyBUSEUgU1RPUlkg QUxMIEFCT1VUIEhPVyBNWSBMSUZFIEdPV CBUVVJORUQgVVBTSURFIERPV04=")
Then when called in the database you get inject safe code.
how is it ground breaking ?
dude, it's a renowned researcher, and he's got a shovel.
/greger
Apparently all you have to do is include "Kaminsky" in the summary to get a Slashdot article to the front page. This post has zero real content and TFA uses the word "productize", for science's sake. Looks like Kaminsky has become the nearest thing to a rock star that the security industry has.. which is too bad, because he's sort of a douche bag in real life.
Jesus, what is with the grammar nazis on this?! Let it go already. True IT geeks write and comment code, they don't write fucking novels.
More excuses for hiring developers who can produce bad code by metric ton without understanding what it actually is what they are doing. And that they don't even need to understand. Sigh... It waould be better to ban your developers off SQL and into an abstraction layer that puts the queries together behind the scenes and hire a competent developer to develop that.
the essence is this:
Which means he enforces a convention on developers that aims to improve code security. Sounds smart.
NB: The message above might reflect my opinion right now, but not necessarily tomorrow or next year.
Linky linky?
Karma: Excellent (My Karma? I wish...:-( )
Great, let's keep offering a crutch to crappy programmers instead of letting them be shamed out of the industry when they cock up something that nowadays is quite well understood.
Why would a code-monkey write erotic novels?
It doesn't say anything about how this actually works and how it differs from existing solutions. And, hey, most developers aware of SQL injection / XSS etc already protect their apps. Rails has got both, PHP frameworks have, Java had it since like for ever (2001?). What's the point of this article?
Seems to me that this is just perl's taint mode, implemented in a less elegant fashion (one that relies on variable name prefixes, ugh).
From perldoc perlsec:
You may not use data derived from outside your program to affect
something else outside your program--at least, not by accident. All
command line arguments, environment variables, locale information (see
perllocale), results of certain system calls ("readdir()",
"readlink()" [snip - "and other stuff" ] and all file input are marked as "tainted".
Tainted data may not be used directly or indirectly in any command that
invokes a sub-shell, nor in any command that modifies files,
directories, or processes, with the following exceptions:
http://www.webreference.com/programming/perl/taint/
In short, it's not that interesting, although if people pick it up and actually use it, it could do some good.
It is not possible to solve security problems only with passive measures.
The role of the Internet in business and in social life is increasing and will continue to increase. The next step of this revolution is robotics. It will overshadow everything we saw until now.
Schools and universities, which train police officers, judges, correction institution officers, should start to include programming and robotics courses into curriculum.
When everything is done via net and by robots, there is no use of police officers and judges, who can not even understand what a culprit has committed in a technical terms, how malicious was an intent.
When these public servants and society in general understand the mechanics of this crime, it will be able to start to work to eliminate it.
But if we stop only SQl injection attacks, the criminal minds will find some other way to harm servers. It is an illusion that security can be achieved only by technical means.
I would argue that a wide condemnation by the society and its defense institutions is needed. But if society continues to rely on the network, on computers, on robots more and more without understanding underlying technologies deeply, without ability to understand what is going on inside the system, it would be a recipe for a disaster.
Nullset to connectionate with grammarifical authoritarists.
They don't leverise things paradigmatically and resemblancing noncontent either. It's "marketroids' job to functionate that.
Kindly demisise in a combustational situation with maxised immidiateness.
Confucius say, "Find worm in apple - bad. Find half a worm - worse."
Too many times have I said this. There is no silver bullet.
Security is not an option, it's inherent in the system or not all.
Nothing fixes bad code. Nothing can. Now there are things you can do to prevent writing bad code, like scream when your code goes and screws up stuff. You can automate the things you might do wrong, use a garbage collector, use prepared statements, use a filter to check for input. And it's hard work, but that's why you get paid. Now management can help you too (my boss gives me work that "needs to be done right, first time") by ensuring they don't make you cut corners. Most of us want to do the best job we can, but we're not allowed to - "Just Ship it and put a patch next month", because security is not really a feature that sells, it's assumed to be present and cannot be monetized properly. Bruce Schenier explained it brilliantly in - Market for Lemons.
But there's no silver bullet, in fact there's not even a silver band-aid. And sometimes the bug is in the shield itself. My usual policy is to have as little code as possible, so that I can read and verify it all the time. Smaller the chunks I build, the easier it is to test it apart. Easier it is to tear it apart, to replace a part or just anything. Code in ADA will be more auditable than code in PHP (trust me, I work with php all day). But eventually, you can't really write bad code, push it production and slap security over it.
So tell me, how will you fix this bug that was there in your security tool, Recursive Ventures? :)
Quidquid latine dictum sit, altum videtur
Comment removed based on user account deletion
I can't even think of writing code without checks for every condition imaginable simply because when I started coding, I was learning among peers whose favorite thing to do was poke holes in your code in some way or another. I guess that's known today as "peer review" but it was more like peer pressure review when I was in school. The last thing I wanted was to have embarrassing or code that may be ridiculed. And I think that's what TRULY missing in today's development environments -- shame and ridicule.
At DEC we had a formal process known as “code review”. A bunch of us got copies of some code to review. We then all met together and went over the code line-by-line describing the flaws that we found. There was also statistics gathering and reporting, but the greatest value of the process was to the coder, who got feedback on his code. I had thought it would be hard to avoid getting upset at what were perceived as personal attacks (“that's my baby you're criticizing”) but, at least in the code reviews that I was involved in, that never happened. The whole thing was handled very professionally.
When i read quickly the headline, I saw kaspersky and injection, and thought, they have developed a new way to inject dlls running on windows in case they have been compromised, a new type of anti virus, if the dll is hacked, then hack it back...
Then i stopped and realised that the article had nothing to do with the AV company, and had this guy kaminsky talking about how to circumvent sql injection attacks...sort of...then i tried to go read the article, and got the blocked login page, which I have no log in for...and wont create one to just read a story...all said and done, i am not even sure if this has merit...can anyone post a link to
a NON secured website where i could view the story as is...?
It sounds like he offers a way to go through code quickly to replace badly written code...but i could be wrong...
But if they write marketese (like, you know, "productize"), fuck 'em.
To fight the war on terror, stop being afraid.
...when you didn't need to spend your time in Slashdot dodging advertisements disguised as news.
99.9% of the time if you cannot parameterized a query, you're doing wrong.
In that case, all the 0.1% of the queries appeared to fall on me. Try using operator IN with parameters, and then see why it doesn't always work.
There's nothing stopping you from building a dynamic SQL string with parameters
That doesn't work if the parameter interface in your database's client API expects there to be a constant number of parameters in each statement. For example, how does one pass a variable number of parameters to mysqli_stmt_bind_param() in PHP?
you can certainly parameterize like
SELECT * FROM blah WHERE [mybooleanfield]=@userinput
but sometimes i want the field i am checking to be variable
for example, say i have a dozen boolean fields, and i want to filter the result set based on the user choosing which boolean field to filter on
so i want SELECT * FROM blah WHERE @userinput=True
can't do that ;-(
intellectual property law is philosophically incoherent. it is your moral duty to ignore it or sabotage it
assuming scrubbed user input, how would one parameterize a field name? or rather, if this is not possible, what is the ingenious method i am not aware of for satisfying this common use case?
intellectual property law is philosophically incoherent. it is your moral duty to ignore it or sabotage it
PA-DSS (a PCI standard) requires code review by someone other than the original author, who has training in secure coding practices.
Recursive Ventures indeed...
that's clever
however that's not exactly the use case
so perhaps a mod:
CREATE PROC QueryWithParams
@a varchar(10)
AS
BEGIN
SELECT field1, field2, field3, field4
FROM tables
WHERE
(@a="field1" AND field1 = True) OR
(@a="field2" AND field2 = True) OR
(@a="field3" AND field3 = True) OR
(@a="field4" AND field4 = True)
END
that's the use case i'm talking about. however, its clumsy. if you have 50 fields, you have a monstrosity
the problem being there is no simple way to say
WHERE @a=True
the idea being: the parameter is the name of the field you want tested
intellectual property law is philosophically incoherent. it is your moral duty to ignore it or sabotage it
that's my solution too, unfortunately. its not as fast as a parameterized query
what would be elegant though is if they allowed us to parameterize the names of fields
so we can do
WHERE field=@var
but it would be awesome to do
WHERE @var=True
that's my wish
intellectual property law is philosophically incoherent. it is your moral duty to ignore it or sabotage it
We use PostgreSQL. We expose the libpq not default port directly to the internet through pgbouncer. What we did:
*) Modify pgbouncer to only except extended protocol (parameterized) queries
*) Auto Generate list of allowed queries used by app to store in whitelist
*) Block all functions except auth if authenticated or to the whitelist othewise
have had zero problems. curious what you think.
i know I am replying to myself... but I don't really see why I was marked as offtopic for saying the summary is wrong by saying this is a brand new way to prevent SQL injections... many existing frameworks have offered SQL injection filters/remedies... as well as rogue javascript protection through many ways including parametrized queries.someone must have woken up on the wrong side of bed this morning :).
Never antropomorphize computers, they do not like that
You'd think that preventing SQL injection attacks was difficult. Basically don't allow multiple queries per request on your db and filter out semi-colons (or replace them with "") from post/get vars.
America, Home of the Brave.
call_user_func_array() You just have to make sure the parameter array contains references to variables
Then the code has to maintain three things in parallel: the string of ?s in the SQL, the list of argument types, and an array containing references to elements in another array. Does this method, which requires reaching into more obscure corners of PHP (references and call_user_func_array()), provide noticeably more safety than a dedicated function for escaping lists?
(mysqli_stmt_bind_param is deprecated, use mysqli_bind_param instead)
I don't use either; I use the bind_param method of a prepared statement object.
So what, you pitch the same ideas over and over again until someone thinks its a good idea?
~Syberz
I don't see the point of this 'solution' - it's going to make things worse. The world is going to build a whole bunch of 'better' idiots that will get around the 'magic tool' in ways that will make your head spin. It's solving the wrong problem.
I also don't understand the infatuation with stored procedures. Programming in the database vendors language is horrible compared to most client side languages. You can concatenate all sorts of dynamic queries client side without opening yourselves to injection attacks if you do it correctly. Decent server implementations cache these queries so you don't lose anything performance-wise either
To all those people who made my life a recent misery by writing crap like:
with ridiculous string operations both prior to calling and then inside of the stored procedure in question, lots more lines of hardcoded bits and pieces some of which get used, some not; misleading or outright lies in the comments (if any) eventually followed by an EXEC (@my_funkified_unmaintanable_mess_sql_string)
You all suck. Please desist, educate yourselves and apologise whoever you are.
I think most (?) languages already have this. It's called using a parameters collection or prepared statements instead of SQL & "CONCATENATION" & HAX. The frameworks already exist. The solution is to fire or brutally "retrain" the programmers who are writing this sloppy code to begin with. The security problem is so widespread that the language or compiler should flag any concatenated string as "dirty" and disallow passing it into the database API to begin with... Maybe that is what this "framework" from Kaminsky is actually doing.
"They told me about the "why" of WHY 2 digit years were used (as well as assembly language): Space & Storage in RAM!"
Granted. It doesn't make them any less pillocks though, and I mean that in an endearing way. Of course they can't be expected to predict that in 40 years time their software would still be necessary, but equally whoever was responsible for that software should have updated it too - 40-year-old bugs should have been fixed approximately 39 years ago. Or failing that 38 years ago. Or failing that...
The original programmers weren't "wrong" here (damn right that at some points in computing history, every byte/cycle counted... back when computer menus consisted of "press 1 for invoicing, press 2 for stock control" and - dear God - bring back those days! How many people would actually do a BETTER, more efficient, less distracted, more secure job now if they were told to sit in front of one of those for 8 hours a day instead of a general-purpose OS with access to the Internet!), but the team responsible for such software (either the IT team still implementing it without checking, or programming team for failing to spot such things later on) are still pillocks. If it had been a security problem more than a simple capacity problem, that's still no excuse for not fixing it 40 years later when you *DO* have Gigabytes of storage. The blame is on the *current* programmer / maintainer / IT support team, though, not the original author.
Run-time error checking (e.g. exception handling) is also another world to compile-time, but I was simplifying in order to make my post sound more impressive (*cough*). I think one of my previous posts on here was about checking damn return values (and how return values / exceptions / error flags etc. are all pretty much equivalent operations but done via a slightly different mechanism - sometimes it differs by as little as what register they are put into, if at all), which pretty much should be written on a little illuminated signpost and screwed to every programmer's retina.
If return values were checked properly, the Google-researcher-discovered Windows XP vulnerability that was posted on here last week ( http://seclists.org/fulldisclosure/2010/Jun/205 ) , that's been in the OS for however-many years would never have happened. It all stemmed from XSS and other problems but the main point of execution was via an unchecked error return value from a minor utility function that converted hex digits to numbers. This is where things like CVS 'blame' should be wired up to some kind of electric-shock device in the programmer's chairs.
So the fact that this is intended to be a commercial product makes it unimportant? Put down the FOSS banner you've been waving and get off your high horse.
Kaminsky is one of the most brilliant security researchers on the planet. For people who care about computer security, when Dan Kaminsky makes an announcement, it's "worth reading".
Kaminsky is a fool. He says we try to teach, escape or parameterize, developers try, but fail, then says the solution is to teach these fools to use my untested alpha software, because, we couldn't teach them to do it right . Great logic Laminsky, teach those willfull fools, that'll teach them
Real nice logic you have there. I suppose we should condemn all those "fools" who write firewall or anti-virus software too, because God knows we haven't given web or OS developers enough time over the last couple of decades to create a solution that works without this additional protection, right?
And yeah, it's untested alpha software. That's kind of the whole point here of handing it over to the community to test it out on non-production environments, which he INSISTS on the website.
Comment removed based on user account deletion
.. I forgot to log in. About these naming conventions and grammar nazis, well. Finish has these things called prepositions, which are used in quite similar way, and it is said that Finnish is one of the hardest language to learn because of those. Good luck with that Dan... And that kind of behavior is not a new invention. I have faint memories, that for example Symbian did use that kind of trick to interfere memory allocation behavior or smth. It's funny how in Symbian class's variables are always iSomething, and then *tudumtsah* iPhone.