Live data from Hacker News

SQL injection search

github.com

61–70 of 114 posts

Re: SQL injection search

#61
post #39

Some of these look like deliberate examples of vulnerable code (e.g. the one named "Injection.SQL.php") Alarmingly (and sadly) most do not.

No need to be alarmed (or sad.)

Without some real-world context for each project, we just can't say whether the code we're looking at represents a real security problem. I'm certain that github hosts just as many one-off, let-me-scratch-some-code-together-that-I'll-never-use-again type projects as it does hard core, production quality ones.

That said it's a neat technique for quickly auditing code. Someone should now write an automated tool for submitting security patches to all of these projects.

Re: SQL injection search

#62
This isn't a search for SQL injection, its a search for a couple things that you often find in older PHP code that is generally hacked together and likely to have SQL injection vulnerabilities for historical and cultural reasons. However it's perfectly easy to avoid SQL injection even using these things.

    $id = mysql_real_escape_string($_GET['id']);
    $res = mysql_query("SELECT foo FROM bar WHERE id='$id'");
That may be ugly, but it's bulletproof regarding injection.

Re: SQL injection search

#63

This is a potentially great idea. You could make your build process include submitting your code to a search engine like this (perhaps in some obfuscated manner) and making illegal patterns fail if not manually "approved". Just because the halting problem exists doesn't mean there's not a low hanging fruit in approaching it.

Not sure if this search would be good, but your responses triggers the id of a distributed code review like reCAPTHA. Possibly a pattern search brings up suspicious code and then there is distributed review and once enough people flag it as SQL injection, it could be flagged on Github and someone could submit a patch, etc. Clearly not bulletproof, but this would provide a way of doing code review on projects you might have no other interest in helping.

Re: SQL injection search

#64
post #57
post #37

There's a joke to be made here about "broken crypto search".

I'll make that joke, but it won't be very funny. https://github.com/search?p=2&q=MD5+password+extension%3... https://github.com/search?q=CURLOPT_SSL_VERIFYHOST+NOT+depre... There's more low-hanging fruit, if you're willing to use more specialized searches. For example, guess what mode of operation the PyCrypto library uses by default for all its block ciphers if you don't explicitly pick a sane one: https://github.co…

Also, look for "cookie secret" or anything which looks like a cert file.

Re: SQL injection search

#65

This is a potentially great idea. You could make your build process include submitting your code to a search engine like this (perhaps in some obfuscated manner) and making illegal patterns fail if not manually "approved". Just because the halting problem exists doesn't mean there's not a low hanging fruit in approaching it.

Yep, It's called 'static analysis'. http://en.wikipedia.org/wiki/Static_program_analysis

Re: SQL injection search

#66
post #65

This is a potentially great idea. You could make your build process include submitting your code to a search engine like this (perhaps in some obfuscated manner) and making illegal patterns fail if not manually "approved". Just because the halting problem exists doesn't mean there's not a low hanging fruit in approaching it.

Yep, It's called 'static analysis'. http://en.wikipedia.org/wiki/Static_program_analysis

[deleted]

Re: SQL injection search

#67

mysql_query is deprecated... use MySQLi or PDO

MySQLi or PDO will not automatically solve almost any of the security issues found in this search.

90% of example code for PDO uses prepared statements. 90% of example code for the mysql_* functions is ancient and full of security holes.

Re: SQL injection search

#68

This isn't a search for SQL injection, its a search for a couple things that you often find in older PHP code that is generally hacked together and likely to have SQL injection vulnerabilities for historical and cultural reasons. However it's perfectly easy to avoid SQL injection even using these things. $id = mysql_real_escape_string($_GET['id']); $res = mysql_query("SELECT foo FROM bar WHERE id='$id'"); That may be…

Most of the search results show exploitable code. Regardless, this is a search for SQL injection vulnerability, even if not every search result falls under that category.

Re: SQL injection search

#69
post #65

This is a potentially great idea. You could make your build process include submitting your code to a search engine like this (perhaps in some obfuscated manner) and making illegal patterns fail if not manually "approved". Just because the halting problem exists doesn't mean there's not a low hanging fruit in approaching it.

Yep, It's called 'static analysis'. http://en.wikipedia.org/wiki/Static_program_analysis

Heh. I sure romanticized a semi-mundane thing that already exists. ;-)

Re: SQL injection search

#70

This is a potentially great idea. You could make your build process include submitting your code to a search engine like this (perhaps in some obfuscated manner) and making illegal patterns fail if not manually "approved". Just because the halting problem exists doesn't mean there's not a low hanging fruit in approaching it.

Tons of code review tools already exist out there, runnable on your CI machine. Sonar and Fortify are a few off the top of my head, but there are many, many more.

Nothing new here. Google code search a while back was similar. Also search for index.php~, a great way to see the source for an index page with a unix temp file that Apache will forward as plain text. Oops.

Post reply on HN