Live data from Hacker News

Drupal 7 SQL Injection Vulnerability

sektioneins.de

21–30 of 83 posts

Re: Drupal 7 SQL Injection Vulnerability

#23
The patch is only one line[1], so if you're scared to update Drupal for fear of breaking things you can just patch the vulnerable part.

In this file:

    includes/database/database.inc
Replace line 739:

    foreach ($data as $i => $value) {
With the patched code:

    foreach (array_values($data) as $i => $value) {
[1] https://www.drupal.org/files/issues/SA-CORE-2014-005-D7.patc...

Re: Drupal 7 SQL Injection Vulnerability

#24
post #19

Could this problem be solved by quoting parameters ? I believe PDO has quoting capabilities when it comes to query parameters in prepared statements.i.e. one can state this parameters is a string , or an integer ....

The problem here is that placeholders are added to the query itself to match the amount of array items. These newly constructed placeholders inadvertently contained user data.

Re: Drupal 7 SQL Injection Vulnerability

#25
Drupal uses prepared statements in all its SQL queries.

There's this common misconception "just use prepared statements and they'll completely prevent SQL injection" floating around. Good to see (yet another) counterexample of that. Prepared statements and parameters are only strategies that can help, but they don't replace an understanding of where the characters in the query are coming from and how they're being used. Escaping shouldn't be a difficult concept to understand either.

Re: Drupal 7 SQL Injection Vulnerability

#26
post #19

Could this problem be solved by quoting parameters ? I believe PDO has quoting capabilities when it comes to query parameters in prepared statements.i.e. one can state this parameters is a string , or an integer ....

The problem here is that placeholders are added to the query itself to match the amount of array items. These newly constructed placeholders inadvertently contained user data.

Oh yeah, I see it now,thanks.

They are naming the query placeholders based directly on the indexes passed in the querystring parameters?

And since indexes can be whatever string like ?name[DELETE FROM USERS]=foo&... ,you end up with an exploit ...

Re: Drupal 7 SQL Injection Vulnerability

#27

Drupal uses prepared statements in all its SQL queries. There's this common misconception "just use prepared statements and they'll completely prevent SQL injection" floating around. Good to see (yet another) counterexample of that. Prepared statements and parameters are only strategies that can help, but they don't replace an understanding of where the characters in the query are coming from and how they're being us…

These aren't prepared statements. This wouldn't be an issue if they were actual RDBMS prepared statements. These are the bullshit fake prepared statements that PDO emulates by default to achieve cross-database compatibility to offer things like named-parameters (oracle, postgresql support) for databases that only offer positional parameters (mysql, mssql).

It's quite simply shoddy string substitution that's not doing proper escaping, as you pointed out.

Re: Drupal 7 SQL Injection Vulnerability

#28

I feel like Hacker News has become home of the "security exploit du jour." There have always been new exploits being found daily, what's changed is the severity and wide reaching nature of said exploits. You might ask, when will we learn? Well, the truth is making secure systems is incredibly hard work and often comes at the price of flexibility/usability/programmer productivity. We know how to do it, it's just not e…

I like hearing about the big ones. I'm subscribed to announcements from the projects I rely on but it's good to have the bigger picture.

Re: Drupal 7 SQL Injection Vulnerability

#29

Drupal uses prepared statements in all its SQL queries. There's this common misconception "just use prepared statements and they'll completely prevent SQL injection" floating around. Good to see (yet another) counterexample of that. Prepared statements and parameters are only strategies that can help, but they don't replace an understanding of where the characters in the query are coming from and how they're being us…

If there's one thing I learnt today, I'd make sure my SQL abstraction libraries include test cases which makes sure the libraries barf when presented with bad input.
Post reply on HN