Drupal Fixes Highly Critical SQL Injection Flaw
An anonymous reader writes Drupal has patched a critical SQL injection vulnerability in version 7.x of the content management system that can allow arbitrary code execution. The flaw lies in an API that is specifically designed to help prevent against SQL injection attacks. "Drupal 7 includes a database abstraction API to ensure that queries executed against the database are sanitized to prevent SQL injection attacks," the Drupal advisory says. "A vulnerability in this API allows an attacker to send specially crafted requests resulting in arbitrary SQL execution. Depending on the content of the requests this can lead to privilege escalation, arbitrary PHP execution, or other attacks."
I've seen no mention of whether or not Drupal 6.x is vulnerable; are they?
You had one job!
What a fool believes, he sees, no wise man has the power to reason away.
... the definition of irony.
I understand database abstration layers that let you write:
db_query('select * from table where id = 3')
instead of:
mysql_query('select * from table where id = 3')
or
pgsql_query('select * from table where id = 3')
But I'm not sure I understand why you would want even more abstraction that lets you write:
db_select('*').from('table').where({ id: 3 })
---
Sealing against SQL injection isn't that hard. Don't ever write:
select * from table where id = $id
If you see a dollar sign in an SQL string, it should catch your eye. Instead use parametric queries whenever you can:
select * from table where id = ? or :id or
select * from table where id = $1 or
select * from table where id =
whatever your programming language's syntax is.
Maybe variables in queries are unavoidable, if you have some kind of query building code:
if ($x) {
$table = 'x';
} else {
$table = 'y';
}
$q = db_prepare("select * from $table where id = ?");
Does anyone have a better way to build up queries?
Maybe I'm missing something, but aren't injection attacks a non-issue with parameterized stored procs?
I'm unclear on what their API is doing, but it can't just allowing people to insert anything in a query can it?
'The unexamined life is not worth living' - Socrates
Well. Glad I didn't waste time updating to v. 7.31.
Quick, patch whitehouse.gov ;-)
http://radar.oreilly.com/2009/...
http://buytaert.net/whitehouse...
More seriously, I assume they also run some kind of WAF that would catch the attempt even if drupal wasn't yet patched since I do and I am much much smaller.
Everything I write is lies, read between the lines.
Just don't use PHP. It's been so broken for so many years, these vulnerabilities in major PHP projects proving this time and time again that I am astonished that people still want to use this language/software... Besides, at least where I live, PHP programmers are a commodity, they come a dime a dozen so how is it a good career choice? Learn Python and/or Java and/or Ruby and/or C and/or C++ - there are so many great languages/frameworks out there, why would you want to waste your life on PHP which is a laughing stock pretty much everywhere outside PHP communities?
Seriously, why would one use a CMS for a serious project? They limit you more than they help you if you hit their limits. Just pick some barebone framework, like Laravel 4 (or 5) and start doing your mojo.
To the people bitching about PHP, I can only say that it's here to stay. The syntax is simple, the technology has loads of helpful functionality and the latest frameworks (PHP-FIG compatible ones) like Symfony, Laravel, Zend, Fuel and Aura are thousand times better than anything Drupal and/or Wordpress can bring to the table, using modern techniques and design patterns. Security flaws happen because of programmer incompetence, not because of a language. Claiming that a language is not secure is just stupid and proves how much of an expert you are. Everything can be abstracted. Even the most flawed of systems. Also are you implying that projects written in C++/Java/Ruby does not get hacked just because they use the said tech?
You do realize that Facebook's frontend is powered by PHP because to them it is just cheaper to have a dev team optimizing HHVM and tons of PHP devs buildings things right? (Recently moving from PHP to "Hack"). Go ahead and SQL inject facebook smartass :)
The Irony Dept. just called; they said your shipment of fail just arrived...