[Owasp-leaders] Stop blaming developers on Sql Injection
Calderon, Juan Carlos (GE, Corporate, consultant)
juan.calderon at ge.com
Tue Jan 6 16:19:57 EST 2009
I agree 100% with you, I have used LINQ for some apps and found it very intuitive. This is agreat example of a technology solution.
So why not making a Object SQL (OSQL) language specification that could be implemented in any technology? Something like this C-style code:
Result r = db.query("SELECT * FROM user WHERE username=?50s AND password=?50s", username, password); //(username would be a 50 characters string)
I don't know if this is the real answer at it just figure it out while replying this email. Or the SQL input validation I mentioned before.
My point is that we have to push for technology to upgrade itself and make it as easy as it is now and secure by default at the same time. So we reach a new status quo and developer do not have to think or evaluate between making it easy and fast or hard and secure. It would be easy and at the same time inherintely secure. Otherwise we have the battle lost against close deadlines.
So if we want Sql Injection to be gradually out of top 10s of the world a long term solution is a technology solution in my point of view.
Jeff, what was proposed for mitigate Sql Injection for Servlets 3.0 specification?
Juan Carlos Calderon
From: Erlend Oftedal [mailto:Erlend.Oftedal at BEKK.no]
Sent: Jueves, 04 de Diciembre de 2008 10:47 a.m.
To: Calderon, Juan Carlos (GE, Corporate, consultant); Owasp leaders
Subject: RE: Stop blaming developers on Sql Injection
I work as a developer myself. I don't think we can change the DBRMs themselves or the query language for that matter. The query languages themselves are structured, generic and flexible which is probably the reason why they succeeded in the first place.
What we can do, is change the frameworks that we use. Framework developers could make it harder to do the wrong thing, than to do the right. Right now it's the other way around. Doing a query wrong might take one line of code - something like:
Result r = db.query("SELECT * FROM user WHERE username='" + username + "' AND password='" + password "'"); Doing the same using a parameterized query often takes four or more lines (define query, define each parameter, execute query) and is generally a bit harder to understand for inexperienced developers.
I think the best approach is to remove the actual problem, which in my opinion is that we are mixing control and data when we are writing SQL. The frameworks should seek to allow us to write our code without having to think about the SQL, and then the SQL can be generated for us.
An interesting example of such a framework is LINQ (Language Integrated Query) which can be used in the newer versions of the .NET framework. When using LINQ, you can specify the query directly in the programming language, and then parameterized queries are created by the framework:
User user = from u in user where u.name = username and u.password = password select u; The from...in...where...select can be used with any query language (SQL, LDAP etc.), as long as there is a so called LINQ provider for it (it's possible to implement you own LINQ providers for unsupported query languages).
I like this approach, because it allows you to think about the data as objects directly in the language, instead of stepping into SQL context. This page has a lot of LINQ samples on how to do ordering, grouping, aggregations etc.: http://msdn.microsoft.com/en-us/vcsharp/aa336746.aspx
Fra: owasp-leaders-bounces at lists.owasp.org [mailto:owasp-leaders-bounces at lists.owasp.org] På vegne av Calderon, Juan Carlos (GE, Corporate, consultant)
Sendt: 4. desember 2008 16:06
Til: Owasp leaders
Emne: [Owasp-leaders] Stop blaming developers on Sql Injection
> Hello Leaders
> I liked a lot the mentality of Jeff Williams related to our Industry is not doing enough about security.
> We have seen Sql injection for many years now on every top X list of every single list about common security problems. We have see massive sql injections and robots on the wild and now many people, even not technical is aware of "the problem" but the increasing trend has not changed.
> So what it takes to stop this? to train every single old school, expert and newly graduated and amateur developer? fight back every single misrecomendation on the blogs of the world? I think no, a technology oriented solution is required.
> So my proposal today is to change how DBRM process Query languages and
> do not allow string literals that do not represent an object in the
> database in the Query string but as attached values. So
> Select * from table where id = 'something' when lastdate =
> Would be an invalid query as 'something' and #01/02/2007# would not be
> allowed by DBRM processor. Yet
> Select * from table where id = anothercolum and field2 = @@identity
> is valid, as we are comparing columns vs. columns and vs. internal
> variables (there are some room for security issues on this area of
> variables, but I am assuming that would me much less than the current
> So, we would be forced to use parameterized queries to feed literal
> values in a DB information request for information or action. With the
> additional benefit of performance (less probability of another
> security problem - DoS)
> I know the change acceptance is a big deal as well, many existent applications would break or they will be forced to run old vulnerable version of RBDM until they are migrated, but once this becomes the new status quo we can think on how to use technology to avoid XSS and other security "plagues" in the same technology oriented way.
> You might realized this already but this could be applicable to any
> interpreter in a harder or easier way including LDAP, system
> functions, XPath, etc etc
So if the industry is not doing anything should we add something to enforce this on ESAPI?
> Juan Carlos
OWASP-Leaders mailing list
OWASP-Leaders at lists.owasp.org
More information about the OWASP-Leaders