Slashdot Mirror


The History of SQL Injection, the Hack That Will Never Go Away (vice.com)

An anonymous reader writes with this history of SQL injection attacks. From the Motherboard article: "SQL injection (SQLi) is where hackers typically enter malicious commands into forms on a website to make it churn out juicy bits of data. It's been used to steal the personal details of World Health Organization employees, grab data from the Wall Street Journal, and hit the sites of US federal agencies. 'It's the most easy way to hack,' the pseudonymous hacker w0rm, who was responsible for the Wall Street Journal hack, told Motherboard. The attack took only a 'few hours.' But, for all its simplicity, as well as its effectiveness at siphoning the digital innards of corporations and governments alike, SQLi is relatively easy to defend against. So why, in 2015, is SQLi still leading to some of the biggest breaches around?"

193 comments

  1. Hackers use the integrate face system by Anonymous Coward · · Score: 0

    Hackers use the integrated face system to inject SQL.

    1. Re:Hackers use the integrate face system by davester666 · · Score: 2

      So, Bobby Tables will have his name tattooed on his face...

      --
      Sleep your way to a whiter smile...date a dentist!
    2. Re:Hackers use the integrate face system by FatdogHaiku · · Score: 0

      So, Bobby Tables will have his name tattooed on his face...

      And his sister is still trapped in a drivers license factory...
      https://xkcd.com/327/

      --
      You have the right to remain sentient. If you give up the right to remain sentient, you will be elected to public office
  2. Well, by Anonymous Coward · · Score: 1

    HIV is easy to defend against. Relatively so, also, are things like malaria. Yet they still manage to kill millions. Why, in 2015? Also, is that more or less of a concern than SQL injection attacks?

    1. Re:Well, by MobileTatsu-NJG · · Score: 1

      We appreciate the sacrifices you made to slow the spread of HIV.

      --

      "I like to lick butts!" by MobileTatsu-NJG (#32700246) (Score:5, Informative)

    2. Re:Well, by Anonymous Coward · · Score: 0

      If I tilt my head further I'm going to break my fucking neck.

  3. Everyone has to learn about it. by Anonymous Coward · · Score: 2, Insightful

    Each year brings a fresh crop of computer science graduates into the industry, barely any of them having a clue about attacks like this. Many of them will make these mistakes and learn about defending against them the hard way.

    Maybe a few schools teach about this now. Maybe a few companies will pair senior devs with new devs to transfer this knowledge on the job. Even so, there will be enough new programmers who don't know this, and enough companies who eschew senior talent as a cost-savings measure, that this vulnerability will continue to rear its ugly head.

    1. Re:Everyone has to learn about it. by Rei · · Score: 4, Interesting

      Even older programmers do it - I discovered just last Friday that a senior programmer I work with had written a service that was vulnerable to SQL injection (purely by accident, I was using it and noticed how it was mishandling apostrophes).

      I think most programmers will do it sooner or later until either they've A) internalized the warnings from others, or B) been caught by someone noticing (and potentially exploiting) vulnerable code that they've written. And if neither A) nor B) happen immediately, they may well be serial abusers.

      Also a lot of programmers seem to forget that injection doesn't just apply to SQL. Shell command insertion is also a huge abuse target.

      --
      Hello from Sputnik 2. I am receiving you.
    2. Re:Everyone has to learn about it. by unencode200x · · Score: 4, Insightful

      It's irresponsible to continue to do this. With stored procedures, ORMs (there are some good ones out there, I use Linq a lot), and parameterized queries available in all the major languages I can't help but wonder if people are just incompetent.

      Also, validate and sanitize your input data man. If you're writing code for the web you *have* to do this, no excuses. Albeit, most "web developers" I've seen don't have a clue. Now, get off my lawn!

      --

      Chance favors the prepared mind.
      Perfect is the enemy of good.
    3. Re:Everyone has to learn about it. by OzPeter · · Score: 4, Insightful

      It's irresponsible to continue to do this.

      I was browsing Stack Overflow the other day and looked at an SQL/PHP based question. The poor guy asking the question was obviously a n00b who was just starting to code, and had googled around to find a solution to his problem but it wasn't quite working for him (and hence the SO question).

      From what I saw the problem wasn't that he was a stupid n00b, it was that his googling had turned up horrendously bad PHP code (using ancient DB connection style code, plus totally SQL injection ready) and he didn't know the difference between that code and best practices. So it seems that part of the problem is the act of using google itself and how good code and bad code examples are presented as equals solely based on what ever google's page rank algorithm de jour is. And I can't see how you can fix that without purging google of all the bad code examples.

      --
      I am Slashdot. Are you Slashdot as well?
    4. Re:Everyone has to learn about it. by Anonymous Coward · · Score: 0

      Another baffling thing is that PHP doesn't have a better SQL interface.
      Creating a query string by yourself shouldn't be something the programmer usually does.
      At some point the programmer has a very good idea of that is data and that is the command. Having to manually join them together to a query string increases the risk of not escaping the data and makes it impossible for the language to understand the programmers intention.
      For the simplest selects and inserts PHP could easily provide an interface that escapes the arguments. That would make it more natural for the lazy programmer to realize when he is doing queries that he has to think about.

    5. Re:Everyone has to learn about it. by Anonymous Coward · · Score: 0

      Talented programmers don't copy-paste code from search results. They do the search to learn the facts they are lacking, so they can code the solution themselves. The sort of person who can't think a problem through, and so routinely just googles a solution and uses it as-is, is precisely the sort of person who should not be programming for a living.

      Sorry for being an elitist ass, but the job is hard, and not everybody is cut-out for it. Too much dependence on Google is a clear sign that you belong in another industry.

    6. Re:Everyone has to learn about it. by Opportunist · · Score: 2

      This just in, cargo-cult programming causes security holes.

      That's not really news, is it?

      --
      We used to have a Bill of Rights. Now, with the rights gone, all we have left is the bill.
    7. Re:Everyone has to learn about it. by Anonymous Coward · · Score: 0

      that part of the problem is the act of using google itself and how good code and bad code examples are presented as equals

      Is this some sort of terrible joke or does somebody just not understand?

    8. Re:Everyone has to learn about it. by deviated_prevert · · Score: 1

      Talented programmers don't copy-paste code from search results. They do the search to learn the facts they are lacking, so they can code the solution themselves. The sort of person who can't think a problem through, and so routinely just googles a solution and uses it as-is, is precisely the sort of person who should not be programming for a living.

      Sorry for being an elitist ass, but the job is hard, and not everybody is cut-out for it. Too much dependence on MSSQL by Danny Droptables is a clear sign that you belong in another industry.

      There corrected the error of your logic.

      --
      This message was not sent from an iPhone because Peter Sellers really was a deviated prevert without a dime for the call
    9. Re:Everyone has to learn about it. by gman003 · · Score: 2

      That's what PHP frameworks are for. The main thing I look for in a framework is actually just a good DB interface. One that simplifies query construction and automatically escapes data. I've written some surprisingly complex queries using CodeIgniter's Active Database system (Laravel has a very good one too). About the only time I have to write SQL by string concatenation is when I do crazy subselects or unions.

      I don't know why that functionality is bound up with frameworks. I think it's because PHP's managers are trying to forge a simpler, elegant language out of it, reacting to the throw-it-in nature of early PHP, but they've gone overboard with both that, and contradict themselves by keeping broken functionality around for compatibility.

    10. Re:Everyone has to learn about it. by Anonymous Coward · · Score: 0

      A while back, one place I worked with had H-1B workers who were rotated out every 90 days. It took them about 3-4 weeks to come up to speed, about six weeks to be productive, and by the time they were doing well with the codebase, their contract was terminated, and another H-1B, fresh off the boat, would be on.

      So, on average, code quality was shitty, and with the push to make deadlines over anything security related (the PHB always said that no lock or security device ever earned anyone but the lock company a single dime), security was dead last on any priority lists.

    11. Re:Everyone has to learn about it. by AchilleTalon · · Score: 1

      Fresh crop of computer science graduates should be those from which this should never happen. They are newly trained, supposed to be security awared. Particularily if they have to deal with web sites programming. This is the lamest excuse. I can rather than that old programmers getting a new assignement with web programming will not know how to circumvent such a problem even if they have heard about it in the news. Employers are often trying to save a few bucks on training of old farts.

      However, I believe the real problem lies with the level of training, academic or not, the programmers have. Someone without any proper background may get assigned to a web application design. I have even seen architects without proper skills. I have seen managers which want to save a few bucks and asked to skip the error handling design and so on. This industry is sometimes really insane and these incomptent managers/architects are still rewarded until the company get hit by an exploit due to their incompetency.

      I can give names, but I won't.

      --
      Achille Talon
      Hop!
    12. Re:Everyone has to learn about it. by viperidaenz · · Score: 3, Interesting

      What's wrong with prepared statements?
      http://php.net/manual/en/pdo.p...

      That last time I touched PHP, over 10 years ago, you could do this.

      But then there was crap like this: http://php.net/manual/en/funct... Perhaps they planned to make a mysql_fake_escape_string function but instead accidentally called it mysql_escape_string

    13. Re:Everyone has to learn about it. by Anonymous Coward · · Score: 0

      I'm just wondering how you can be a web programmer and not heard the words "SQL injection". Or how you can have heard those words, and not tried to learn what they mean.

    14. Re:Everyone has to learn about it. by Anonymous Coward · · Score: 0

      So it seems that part of the problem is the act of using google itself and how good code and bad code examples are presented as equals solely based on what ever google's page rank algorithm de jour is.

      Or maybe the amateurs should leave the code writing to those of us who specialize in it as our chosen profession. Would you buy a hand made one-off car that some crank cobbled together in a "maker space" somewhere? Would you put your family in that car? Why is the software business seemingly immune from liability? It's a good question and one I think must be answered before our industry can truly take it's place among the other professional engineering disciplines.

    15. Re:Everyone has to learn about it. by Anonymous Coward · · Score: 0

      And fuck everyone who wants to start learning, right? Because I'm sure you were an elite expert the very first hour you were learning.

    16. Re:Everyone has to learn about it. by ranton · · Score: 1

      It's irresponsible to continue to do this. With stored procedures, ORMs (there are some good ones out there, I use Linq a lot), and parameterized queries available in all the major languages I can't help but wonder if people are just incompetent.

      While I agree there is no excuse to allow SQL injection attacks, some frameworks have some really horrendous parameterized query syntax. I recently had to use the node-postgres client for the first time a few weeks ago, and I was running into some tough situations that took far too long to figure out. There were times I was tempted to not use parameterized queries, but ultimately I knew the dangers of doing it the easy way.

      As long as the easy way to do things is not the same thing as the right way, these vulnerabilities will continue. Its still primarily the fault of every programmer who writes the bad SQL client code, but some blame is also shared by framework writers who either make parameterized syntax too obscure and/or don't document it well enough. And that includes documenting the edge cases, not just one or two basic use cases.

      --
      -- All that is necessary for the triumph of evil is that good men do nothing. -- Edmund Burke
    17. Re:Everyone has to learn about it. by DerPflanz · · Score: 2

      Damn you are right. I did the simple "mysql php tutorial", and except for the first hit (from W3Schools), ALL of them used the old, deprecated mysql_* functions and were wide open to SQL injection.

      Is there something the programmer's community ought to do? What could we do?

      --
      -- The Internet is a too slow way of doing things, you'd never do without it.
    18. Re:Everyone has to learn about it. by WaffleMonster · · Score: 5, Informative

      It's irresponsible to continue to do this. With stored procedures

      Does using stored procedures solve SQL Injection? Show of hands... all of you who raised yours are part of the problem.

      Also, validate and sanitize your input data man. If you're writing code for the web you *have* to do this, no excuses. Albeit, most "web developers" I've seen don't have a clue. Now, get off my lawn!

      The number of people who incorrectly believe SQL Injection is in any way related to data validation means the problem will never go away. SQL Injection is a failure to enforce context and has got exactly nothing to do with content.

      The data validation misinformation is so prevalent the only way you are probably even reading this is you regularly browse -1 as many of you will have modded my comment into oblivion.

    19. Re:Everyone has to learn about it. by MobyDisk · · Score: 2

      I'm curious to know why a senior programmer was writing code to handle apostrophes in the first place when that is probably built-in to whatever library you use. I'm legitimately interested, if you wouldn't mind following-up with a reply at some point. The answer is probably to the heart of why SQL injection continues to be an issue.

    20. Re:Everyone has to learn about it. by Anonymous Coward · · Score: 0

      Learn by studying Computer Science. Especially study data structures and algorithms, and prove your ability to solve novel hard problems by putting the pieces together yourself (and not by just copying from someone else who has this ability). Once you can do that, THEN start writing code in the real world. And if you can't do that, find a different career.

    21. Re:Everyone has to learn about it. by Rei · · Score: 4, Informative

      I think you're confused. They weren't "writing code to handle apostrophes". They wrote a code review-related microapp, and I noticed during the submission of a review that it failed, gave an detailed error message (which I should probably warn him is also bad practice, you don't help would-be hackers out by publicly such information) indicating a particular bad SQL statement, and the statement was "bad" because it wasn't sanitizing the apostrophes in my input. It was immediately clear that he was building his query through simple string concatenation.

      The application was designed for internal usage (though I'm not sure if it was externally accessible)... but even if it wasn't externally accessible, the fact that he would write SQL queries through string concatenation is a problem, in case he ever would write an externally-accessible application for us. I'm not disappointed or upset with him or anything, because lots of people do that, it's a natural way for someone who doesn't realize the risks to do it. People are used to building up strings through concatenation - for example, for displaying text in a GUI. A large chunk of programmers just don't know the risks that exist in certain contexts.

      --
      Hello from Sputnik 2. I am receiving you.
    22. Re:Everyone has to learn about it. by JaredOfEuropa · · Score: 1

      This. In most companies I see few or no senior devs. What they call senior devs are people with a mere 5 years of experience. And management refuses to even let those so-called seniors set aside time to coach the junior coders. And then they wonder why so many projects fail to live up even to minimal expectations.

      --
      If construction was anything like programming, an incorrectly fitted lock would bring down the entire building...
    23. Re:Everyone has to learn about it. by i.r.id10t · · Score: 4, Interesting

      As soon as PHP totally gets rid of the mysql_ family of functions, and forces everyone to convert to mysqli function/objects or PDO, it will fix itself. As a bonus, quite a few folks may make some beer money fixing all of the suddenly broken scripts...

      The problem with search results is that the mysql_ functions for a loong time were the only way to do the task, and with the plethora of tutorials/information out there the sheer number of them overwhelm the "new" stuff (mysqli and/or PDO)

      --
      Don't blame me, I voted for Kodos
    24. Re:Everyone has to learn about it. by Anonymous Coward · · Score: 1

      This is a good point. There really is a lot of poor code out out there as examples, and basically no oversight for making sure it's *relevant*. On one hand, it's easy to assume that the crappy programmer who has to google up answers to his programming is to blame, but on the other hand this is very much a self-taught career/hobby for an absolute ton of people.

      This is also a problem with many "updated" programming books. I picked a PHP guide the other day, revised in early 2014, and it mentions SQL injections as something to consider, but doesn't actually elaborate on how to secure against them. Worse still, the examples given in the book (right before the SQLi warning) are actually not all protected. I assume it's because the book wasn't meant to focus on database connection, but the truth is most people aren't going to use PHP unless there *is* a database connection being made somewhere, so the topic needs way more attention than it really gets.

    25. Re:Everyone has to learn about it. by Anonymous Coward · · Score: 0

      I'm just wondering how you can be a web programmer and not heard the words "SQL injection".

      Most do hear those words sometime after the words "your site has been breached by".

    26. Re:Everyone has to learn about it. by Anonymous Coward · · Score: 0

      Does using stored procedures solve SQL Injection? Show of hands... all of you who raised yours are part of the problem.

      It solves it in the sense that a procedure requires you pass inputs as query parameters. The types of people who still code in SQL injection attack vectors are the same types of people who aren't going to understand the subtleties of content versus context. Giving them a tool which will always force them to parameterize their queries is a means of saving them from themselves. That's the point of most best practices, and like so many of them, there are times to use procedures and times to avoid them.

      If they get advanced enough to wonder why they need to be using procedures for everything (hopefully without falling into the cult of "procedures are always bad"), then you can sit down and have the SQL birds and the bees talk with them.

    27. Re:Everyone has to learn about it. by edtice1559 · · Score: 1

      The problem is that, in non-trivial applications, it's not always easy to tell *where* in the architecture the data should be sanitized. Security experts accidentally write SQLi. Web applications are especially problematic because you have to escape for so many different contexts. It's not possible to do it all in one place since, at the time of receipt, you don't know the context. Is it going into a database? One type of escaping is required. HTML context? Completely different. What if it's going to be reflected *and* stored. If your application is 10 lines long, it's pretty inexcusable to get this wrong. But when there are multiple layers, it's easy to get confused which layer is responsible. And if you double-escape, things just won't work. And I can't tell you how many web sites are broken if you have an apostrophe in your name! It's easy to blame the programmers but the web frameworks are really at fault. Data should not be received in a String type. There should be a separate TaintedString class that receives this type of data and the frameworks should be built that way. Stored procedures *mostly* solve this until you get a stored procedure that makes a web services call and then builds dynamic SQL or something hideous along those lines and then you are back to having SQLi again. Not understanding injection defects in today's day and age makes you poorly qualified to write software for a living. But misunderstanding part of the security architecture of a large application is something that happens to the best.

    28. Re:Everyone has to learn about it. by Anonymous Coward · · Score: 0

      What's wrong with prepared statements?

      They're unnecessary. Don't confuse them with parameterized queries.

      A parameterized query is just a query with parameterized values instead of inline text. There's no need to "escape" the values because the database already knows that they're variables and that they have a declared data type. Just give the database a query and some parameters and let 'er rip.

      Prepared statements are for speed optimization. Basically, you pre-send the query to the database engine for compilation, then get a reference to it back. Then you submit that reference and any parameters that the query requires each iteration of a tight loop. The database merges the values into the pre-compiled query and executes it. And don't forget to "un-prepare" the query to clean up. Your connection won't work with any other query until you release the reference. And abandoned connections with prepared statement references can pollute your connection pool (in some circumstances).

      As for the mysql_escape_string thing in PHP, well, I think they finally solved that with PDO (which you linked to), but if they had kept going, they would've had to make mysql_no_really_we_got_it_right_this_time_for_real_escape_string.

    29. Re:Everyone has to learn about it. by hey! · · Score: 2

      What would be nice is if they learned about it before they develop habitual patterns for using a language/platform.

      The problem is that people who teach n00bs want to give them the success experience of updating a database early on, before they've learned about prepared statements and (the much broader topic) of checking user input. If they'd just stop that then over the course of years the problem would become much smaller.

      --
      Post may contain irony: discontinue use if experiencing mood swings, nausea or elevated blood pressure.
    30. Re:Everyone has to learn about it. by Anonymous Coward · · Score: 0

      Freshman year. Don't concatenate, use parameterized inputs, careful of any dynamic SQL, do not give the SQL user access to anything in the database, except when needed, and never give the SQL user direct table access.

    31. Re:Everyone has to learn about it. by LiENUS · · Score: 2

      For the simplest selects and inserts PHP could easily provide an interface that escapes the arguments. That would make it more natural for the lazy programmer to realize when he is doing queries that he has to think about.

      If you're escaping your sql inputs you're part of the problem. SQL injection has been known to work on escaped strings using unicode tricks. Use bound parameters in parameterized queries and its not an issue at all.

    32. Re:Everyone has to learn about it. by Rinikusu · · Score: 1

      There's a new found disdain for DBAs, because they "slow things down" by pointing out issues before they become issues. Instead, every half-assed "web developer" also thinks they're a DBA because "web scale" or some bullshit. I've always found it ironic that businesses who depend upon the integrity of their data are the first to eschew the services of a good DBA because "slow" or because "nosql". Then again, I've generally always worked with competent DBAs would who ask questions about my queries and help me build new queries that followed better practices (as well as lightening the load on the db itself).

      --
      If you were me, you'd be good lookin'. - six string samurai
    33. Re:Everyone has to learn about it. by WaffleMonster · · Score: 1

      It solves it in the sense that a procedure requires you pass inputs as query parameters.

      No absolutely not. It does no such thing. Anyone can call stored procedures from strings without binding parameters. Using stored procedures in and of itself solves exactly nothing.

      The types of people who still code in SQL injection attack vectors are the same types of people who aren't going to understand the subtleties of content versus context.

      I'm sick of these lame ass excuses for ignorance. It isn't a hard concept at all in any shape or form to understand. Anyone who can't grasp it has no business in the industry.

      Giving them a tool which will always force them to parameterize their queries is a means of saving them from themselves.

      I worship at the church of designing systems requiring people to try really hard to fail yet this isn't what my comment is about. It is about "common wisdom" that is actively harmful.

    34. Re:Everyone has to learn about it. by Anonymous Coward · · Score: 0

      it is why interpreted code should not be used. get a real language and database tools.

      ps: fire that guy and yourself, for failing to use and have stock routines to prevent it!!!

    35. Re:Everyone has to learn about it. by fearlezz · · Score: 1

      Nope, switching to mysqli will not magically fix sql injections. The functions mysqli_query, mysqli::query and even mysqli::prepare allow for idiots to create broken code. Only if programmers are forced to separate the query from the data, it will be fixed. But that will never happen.

      --
      .sig: No such file or directory
    36. Re:Everyone has to learn about it. by unencode200x · · Score: 1

      Re-reading what I posted, I suppose it does sound like I meant just using stored procedures in an RDMS makes things right. SPs don't do much by themselves.

      What I meant was that stored procedures can help keep strings of SQL out of your application code. Yet, you still need to be smart and use them as you would a parametrized query. That is, send the SP strongly typed parameters.

      OWASP has this section about SQL injects and what bad vs. good code look like. They list the following as the top three "Defense Options" in order: 1) Parameterized Queries, 2) Stored Procedures, and 3) "Escaping All User Supplied Input."

      Personally, I am starting to use ORM. LINQ to SQL at the moment as most of my work these days is in C#. ASP.NET has this cool feature where it freaks out if there is anything that remotely looks like SQL in user-supplied data.

      --

      Chance favors the prepared mind.
      Perfect is the enemy of good.
    37. Re:Everyone has to learn about it. by unencode200x · · Score: 1

      Oops, link to said section: https://www.owasp.org/index.ph...

      --

      Chance favors the prepared mind.
      Perfect is the enemy of good.
    38. Re:Everyone has to learn about it. by Anonymous Coward · · Score: 0

      From what I remember, mysql_escape_string does naive escaping, mysql_real_escape_string requires a connection reference and uses that to lookup the correct charset to escape the string.

    39. Re:Everyone has to learn about it. by Anonymous Coward · · Score: 0

      Does using stored procedures solve SQL Injection?

      Of course it does. That's why we have SP_ExecuteSQL, right?

      (Mod hint: Funny, not informative).

    40. Re:Everyone has to learn about it. by Anonymous Coward · · Score: 0

      Web applications are especially problematic because you have to escape for so many different contexts. It's not possible to do it all in one place since, at the time of receipt, you don't know the context. Is it going into a database? One type of escaping is required. HTML context? Completely different.

      No, the problem is that we keep trying to work around the problem with escaping.

      Keep data and code separate. Use SQL Parameters, XMLHttpRequest, etc.

    41. Re:Everyone has to learn about it. by gbjbaanb · · Score: 3, Insightful

      The problem is inherent in many systems so you will always make a mistake until the day that you put all your queries into stored procedures.

      Treat the DB as a generic object pool of crap and it'll be that. Treat it like its a precious storage system with its own (customisable) API and you'll do far better.

      But of course, slapping SQL together in the client and sending it to the DB to parse and execute is so much easier everyone does it.

    42. Re:Everyone has to learn about it. by tompaulco · · Score: 1

      Each year brings a fresh crop of computer science graduates into the industry, barely any of them having a clue about attacks like this. Many of them will make these mistakes and learn about defending against them the hard way.

      Maybe a few schools teach about this now. Maybe a few companies will pair senior devs with new devs to transfer this knowledge on the job. Even so, there will be enough new programmers who don't know this, and enough companies who eschew senior talent as a cost-savings measure, that this vulnerability will continue to rear its ugly head.

      It's not like they teach 'how to protect yourself from SQL injection' in school. In school, they teach people how to program in a clean room, where all data is 100% good and only one person at a time uses a system.

      --
      If you are not allowed to question your government then the government has answered your question.
    43. Re:Everyone has to learn about it. by Anonymous Coward · · Score: 0

      LINQ and parameterization's obfuscate the problem but don't fix it. If the exploits haven't already been written already, Imagine an overflow set to replace parameters in the heap rather than trying to bugger the pointer from the stack.

      In fact I'll bet money one of the next "big hacks" will be predicated on just such an attack. A 'properly paramaterized' query being altered in ram.

      I also imagine that while programmers dutifully sanitize and parameterize their queries, a not insignificant portion will be submitted, as recombined queries, in plain text. Subject to MITM modifications and/or spoofing.

    44. Re:Everyone has to learn about it. by Robert+Goatse · · Score: 1

      I wonder if aspiring developers are using out of date tutorials to write their code. The ones with zero input sanitization. You're right, though, there isn't really any excuse to not use stored procedures these days. Actually, scratch that. I hope to see the same shitty code so I can keep my App Pentesting day job. :)

    45. Re:Everyone has to learn about it. by MobyDisk · · Score: 1

      Hmmm... then I reword my question: "I'm curious to know why a senior programmer was writing code to concatenate strings of SQL." Fortunately, you answered it already when you said "It's a natural way for someone who doesn't realize the risks to do it." That is probably the most common reason for SQL injection vulnerabilities. But that statement concerns me. I expect someone labeled "senior engineer" would already know about these risks. Exceptions might be someone with a very narrow but deep focus like an embedded C programmer, or a PHD with little real experience. Am I off-base in my expectation that senior engineers would know this? I work in a place that has a mix of embedded engineers and higher-level programmers, so I am tempted to take a survey.

      Another area that I think many "senior" engineers don't know is security. Lots of them find an encryption library and call Encrypt(data, key="12345" + "abcde") and think they are secure because they used 256-bit encryption and obfuscated the key.

    46. Re:Everyone has to learn about it. by Anonymous Coward · · Score: 0

      Not just the programmer. A couple years ago, charged as PM to develop PhP app that had been started by an inexperienced programmer. I was given a couple part time programmers and told get us something that works. First thing on my list, perform a security audit of existing code, However, presenting my task list to stakeholders, lead by a director, first thing they see is time allocated for the review. This was removed as outside of "scope" and an unnecessary cost, no matter how hard I argued. My manager, interested in pleasing the director agreed to the cut.

      A few months later, want to open the app to public access, security wants a review and of course all the mysql code wide open and must be changed. The original bad code had been copied to create new functionality so problem multiplied. I had planned two weeks for original review and updates, now it took two months. More time for a senior programmer to review, my programmers, now down to one as project winding down, spending time fixing the much larger codebase. Why, because management decided security unnecessary. Oh, and I was dinged because project took too long.

      Yes, some issues are due to lack of security awareness by the programmer but others because no one want to pay for an audit or take the time to build security into the app, network, organization, etc until forced too. Just get the job done as cheap as possible. Sure, use a 20 year old security library and never think to look at the code to see if something has changed since the library was built. After all, not our responsibility, let someone else pay for it. Do it cheap - until caught.

    47. Re:Everyone has to learn about it. by Anonymous Coward · · Score: 0

      It's not Google perpetuating bad coding styles, but the PHP community at large.

    48. Re:Everyone has to learn about it. by Anonymous Coward · · Score: 0

      I just finished up an electronics engineering degree, and even I was informed of a pretty broad spectrum of attacks and that it is not that hard to avoid them, top of the list was SQL injection. I only took 2 dedicated programming courses. network engineering focused on security pretty intensively. I would say that the problem for recent graduates is not being uninformed, but in cutting corners where they shouldn't be cut.

  4. Well in Government.... by rholtzjr · · Score: 1

    It is usually accomplished by accepting the lowest bidder.

    1. Re:Well in Government.... by khasim · · Score: 1

      And in the private sector I've usually seen it accompanied by the boss saying "My friend/son/cousin knows this computer stuff. I'll get him to do it."

    2. Re:Well in Government.... by Hognoxious · · Score: 1

      That's better, because nepotism is better than communism.

      Some parts of the US like nepotism so much they choose their spouses that way.

      --
      Confucius say, "Find worm in apple - bad. Find half a worm - worse."
    3. Re:Well in Government.... by AK+Marc · · Score: 1

      Don't forget, one of the recent presidents was selected that way as well.

    4. Re:Well in Government.... by Anonymous Coward · · Score: 0

      No, that alleged president was anointed by a bought-and-paid-for political coven in the SCOTUS after the suit was dropped in the lap of the Federal courts by a political party that claims to love "states rights".

    5. Re:Well in Government.... by hummassa · · Score: 1

      One? Try four (Bush, father and son; Harrison, grandfather and grandson; Roosevelt, fifth cousins; and Adams, father and son) The next one will be, too. Ah, and Chelsea is coming after that. :D

      --
      It's better to be the foot on the boot than the face on the pavement. ~~ tkx Kadin2048
    6. Re:Well in Government.... by AK+Marc · · Score: 1

      I wouldn't count Harrison or Adams as "recent". Roosevelt could be argued to be such, but there was only one father-son pair this generation. Bobby would have made the list, but he didn't live to election day.

  5. PHP by Bogtha · · Score: 4, Interesting

    So why, in 2015, is SQLi still leading to some of the biggest breaches around?

    Because typical PHP tutorials still teach old, broken ways of doing things and this shows no signs of abating. Go ahead and search the web for things like php mysql tutorial. The top hits are crap like this, written by incompetent developers who don't know what they are doing. PHP developers learn from crap like that, then they go on to write their own tutorials that are the same or worse.

    And before you start, yes, this is something where PHP is stand-out bad. Go ahead and try the same searches with other languages. There is a vast difference in quality of learning materials. I mean, PHP had XSS vulnerabilities in its official tutorials until relatively recently. Newbies don't stand a chance in those circumstances.

    --
    Bogtha Bogtha Bogtha
    1. Re:PHP by Anonymous Coward · · Score: 0

      PHP is the language written by the noobs, for the noobs, and of the greatest noobity.

    2. Re:PHP by Aethedor · · Score: 1

      Well, than hack one of my websites. Fail, and you're nothing but a loudmouth kiddo.

      --
      It doesn't have to be like this. All we need to do is make sure we keep talking.
    3. Re:PHP by Aethedor · · Score: 1

      This is not a PHP thing, but a bad-developer thing. You can write the same crap in Java, .NET, Python or any language you want. PHP is easy to learn, easy to use and easy to deploy. That's why it has become so popular. Because PHP has so many users, it also has many incompetent users and incompetent users publishing their incompetence in bad tutorials. That's not PHP's fault.

      --
      It doesn't have to be like this. All we need to do is make sure we keep talking.
    4. Re:PHP by phantomfive · · Score: 3, Insightful
      There's a quote from Theo de Raadt that is relevant here:

      “When you know exactly what the APIs are, you’ll spot the bugs very easily. In my mind, it is the same as any other job that requires diligence. Be careful. Humans learn from examples, and yet, in this software programming environment, the tremendous complexity breeds non-obvious mistakes, which we carry along with us, and copy into new chunks of code.
      We’ve even found in man pages where functions were mis-described, and when we found those, lots of programmers had followed the instructions incorrectly”

      --
      "First they came for the slanderers and i said nothing."
    5. Re:PHP by Anonymous Coward · · Score: 0

      PHP suffered from the dual misfortune of a waves of self-taught do-it-yourselfers inserting themselves into a hot job market during the go-go 1990s, before the DOT com bust, and lack of built in language tools or features to make safe SQL queries easier to write. It seems that these problems have now been largely solved, but the taint of past sins continues to haunt PHP and probably always will.

    6. Re:PHP by Anonymous Coward · · Score: 0

      I dunno. I've been learning Meteor (for nodejs) lately, and many of the tutorials I find have left gaping security issues open without mentioning how dangerous it is or where to go next to learn to do the right thing. The same thing happened years ago with Ruby on Rails, where permissions had to be explicitly denied rather than explicitly allowed, and nobody really noticed it until all of a sudden someone did, and it turned out thousands of sites had the problem.

    7. Re:PHP by Bogtha · · Score: 5, Informative

      This is not a PHP thing, but a bad-developer thing.

      I guess you didn't read past my first paragraph? Please do.

      You can write the same crap in Java, .NET, Python or any language you want.

      Go and search the web for tutorials in those languages. You will find that the situation is vastly better with these languages compared with PHP.

      That's not PHP's fault.

      It is - on many fronts.

      Firstly, the language promoted for many, many years, a confusion between the various layers of the application. The whole magic quotes nonsense was an attempt to fix a problem relating to the database layer in the HTTP layer. This confused PHP developers for over a decade, and even though it has since been removed, it was in there for so long that an entire generation of PHP developers had their brains twisted out of shape with this confusion.

      Secondly, the official documentation was super bad for years. Security vulnerabilities in the official tutorial for years, for example.

      Thirdly, the API design is so bad it practically pushes unsuspecting developers into the wrong solution. addslashes()? No, use mysql_escape_string(). Oh wait, wasn't that mysql_real_escape_string()? Or perhaps mysql_really_really_i_promise_to_do_it_right_this_time_escape_string()?

      Finally, the PHP community right from the very top embraces shitty practices, like ignoring failing tests in a release build. Again, a source of security vulnerabilities that simply doesn't need to happen.

      Yes, you can write bad code in any language. But that doesn't mean that all languages are equal. PHP is far, far worse at this than its contemporaries and you shouldn't make excuses for it.

      --
      Bogtha Bogtha Bogtha
    8. Re:PHP by PyramidOfDoom · · Score: 3, Informative

      Thirdly, the API design is so bad it practically pushes unsuspecting developers into the wrong solution. addslashes()? No, use mysql_escape_string(). Oh wait, wasn't that mysql_real_escape_string()? Or perhaps mysql_really_really_i_promise_to_do_it_right_this_time_escape_string()?

      To be fair to PHP here, the mysql_escape_string vs mysql_real_escape_string is mostly MySQLs fault (watch http://www.youtube.com/watch?v... if you want an insight into how screwed up MySQLs development was). It's one of their old C libraries that added the mysql_real_escape_string function.

      PHP is not entirely blameless on this front; back in the early days of PHP Rasmus Lerdorf (PHP's creator - read and weep) thought the best way to design an API is to just expose PHP's internal libraries' headers to PHP code, consistency be damned. That's how we got mysql_real_escape_string; Rasmus was just following past form.

      PHP has had SQL injection licked for at least the past 10 years (literally every database driver except the deprecated mysql_* one supports binding values to a query), it's just that all of the tutorials are utter, utter garbage and STILL use mysql_* functions.

      mysql_* is dead as of PHP 7 (which is pretty imminent now), thank god.

      Finally, the PHP community right from the very top embraces shitty practices, like ignoring failing tests in a release build. Again, a source of security vulnerabilities that simply doesn't need to happen.

      It comes from the top down. Try running PHP's own tests some time. You'll be utterly unsurprised by the result. They're also written in PHP, which I feel is perhaps something of a design flaw.

    9. Re:PHP by PyramidOfDoom · · Score: 1

      Thinking about this a bit more, I've come to the conclusion that the PHP devs may have been correct to add the mysql_real_escape_string function instead of changing mysql_escape_string to invoke MySQLs mysql_real_escape_string (although not necessarily using their crappy name for it).

      There's actually a subtle difference in the expectations of the real_escape variant; it requires an active MySQL connection to be open in order to work, which the older escape function does not. It's not exactly common to try and escape a query when you don't have a connection open to push it down, but I can imagine that there's possibly some weird scenarios where this distinction is important. For example, you could be pushing the queries onto some kind of job queue to be executed asynchronously by another process (don't ask me why you would do this over just pushing the query parameters onto the queue and having the worker build the query itself). This change would break that workflow.

    10. Re:PHP by PyramidOfDoom · · Score: 3, Interesting

      I think that you goading someone into hacking your websites and then claiming that they are secure when they can't is actually quite disingenuous here. To be perfectly honest, from your post history I believe you have some vested interest in this banshee framework you keep linking to.

      I did actually have a quick look at your websites and they don't actually present a lot of attack surface to work with. The only user input that's used is some id parameters from what I can see. It's utterly trivial to secure such a tiny attack surface, so I doubt there's anything much to be worked with unless you really screwed up.

      However, having such little attack surface also implies that there's little reason for PHP to be there at all. You could very easily replace everything with an offline static site generator and just serve html pages. This completely removes all attack surface from your sites and lowers your server requirements.

      Do you have any more complicated websites to look at? Something that actually accepts user input from people that haven't been pre-vetted would be ideal. In my experience, PHP's warts really start to show when you need to start exposing the ability to persist things to random people on the internet.

      Also is your PHP up to date on those sites? There's some rather nasty CVEs against PHP itself that don't give a damn about your code or framework.

    11. Re:PHP by Anonymous Coward · · Score: 0

      You seem to just have something against PHP. Just as you said bad code can be written in any language. Now you're trying to point the blame saying this is PHPs fault and not the person writing the vulnerable code. If I write vulnerable code regardless of what platform/language I use, I can't say the fault is that of the language, the fault is my own. There has always been ways to validate your input that means the fault if the person writing the vulnerable code.

      I've been using PHP since version 4 and have been through all the different progressions of PHP as it has changed and the official documentation has always been good at pointing out any possible ways of misusing functions. And claiming "Security vulnerabilities in the official tutorial for years" without even posting proof, if the vulnerabilities were there "for years" clearly you can provide some examples, since all the PHP documentation is done via revision control, so show us these many vulnerabilities that were there for years.

    12. Re:PHP by KingMotley · · Score: 1

      You forgot magic_quotes, lol.

    13. Re:PHP by Aethedor · · Score: 1

      I did. You're just wrong. That's why I wrote my comment.

      --
      It doesn't have to be like this. All we need to do is make sure we keep talking.
    14. Re:PHP by Aethedor · · Score: 1

      Then you didn't even look at those websites. There are enough attack vectors. There are login pages (add /cms to the URL), weblogs with comments, a public forum and many other forms (login with demo:demo).

      --
      It doesn't have to be like this. All we need to do is make sure we keep talking.
    15. Re:PHP by Anonymous Coward · · Score: 0

      I think you glanced on one of PHP's biggest flaws, in enterprise use. There have been so many generations of completely different, and incompatible methods for interacting with the database. Old-school query functions (pg_query(), mysql_query(), et al), PearDB, PDO, eleventy different ORMs (several of which have had gaping holes and vulnerabilities themselves).

      When you take a language that's gotten popular specifically because any random numpty can pick it up, and then muddle the discussion with THAT many different ways to do things (and potentially do them wrong), the problem of the lack of skill-and-or-experience of the developer base is exacerbated to the nth degree - especially when the signal:noise ratio of people answering the questions the rookies have, is so fundamentally skewed by the number of people who don't even realize how much of a rookie they still are.

    16. Re:PHP by Anonymous Coward · · Score: 0

      Assuming for the sake of argument that it really is as secure as you claim.

      How much effort did it take you (or the framework authors, if you used someone else's framework) to get to that point? How much functionality did you have to (re)invent because the built-in PHP version is inadequate or non-existent? And how many newbies do you think will go to that trouble, or bother to seek out a third-party framework when PHP is supposedly a "web language" that can be used to make websites out of the box?

    17. Re:PHP by Anonymous Coward · · Score: 0

      You could also be connecting to two different databases and moving data between the two, where one database has its encoding set to KOI8-R and the other is SJIS. Without providing the database handle to the function, the function could not magically guess which database the string will be inserted into and how to properly escape the string so that ' cannot be exposed in the resulting conversion (in some character sets -- like UTF-16 -- "[byte]'" and "[byte]\" are both valid multibyte characters, so if you gave the script "[byte]'; drop table foo; --" and the script used the non-real-escape function, it would do "[byte]\'; drop table foo; --" which the database would interpret as "validcharacter'; drop table foo; --". the _real_ variant would understand that "[byte]'" was a single character and not add a backslash. (It could use the standard mysql* tradition of assuming the most recent connection, in which case it'd be wrong half the time).

      _real_escape isn't PHP's fault. It's not even mysql's fault, except in that it doesn't force everyone to perform whatever character set conversion on the client side and mandate UTF8 to communicate between the client and server to avoid any issues (eg consider UTF-16 encoding of U+xx27).

  6. The answer is simple by Anonymous Coward · · Score: 0

    Because companies keep hiring the lowest bidder.

  7. SQL Injection Trivial to Defend Against by StormReaver · · Score: 1

    ...SQLi is relatively easy to defend against.

    Relatively? It's trivial to defend against (spoiler: use prepared statements), and anyone creating software that has even the potential for SQL injection is an incompetent moron.

    Hiring a programmer who doesn't know how to eliminate SQL injection is like hiring a surgeon who doesn't know how to use a scalpel, or a bridge builder who doesn't understand weight distribution. It's the first thing that a programmer should learn when learning to write database aware software.

    1. Re:SQL Injection Trivial to Defend Against by Anonymous Coward · · Score: 0

      ...SQLi is relatively easy to defend against.

      Relatively? It's trivial to defend against (spoiler: use prepared statements).

      It's even worse. In the majority of the cases, the fix leads to simpler and more readable code as well.

    2. Re:SQL Injection Trivial to Defend Against by shess · · Score: 1

      Hiring a programmer who doesn't know how to eliminate SQL injection is like hiring a surgeon who doesn't know how to use a scalpel

      I'd say it's like hiring a surgeon who doesn't wash their hands before operations. Even if they otherwise do a bang-up job, they could still screw things up.

      [Though ... http://news.yahoo.com/clean-ha... ]

    3. Re:SQL Injection Trivial to Defend Against by viperidaenz · · Score: 1

      It can lead to bugs, depending on the interface.
      A prepared statement like "insert into table (col_a, col_b, col_c, col_d) values (?,?,?,?)" makes it easy to mix up the parameters.
      Not all prepared statement interfaces support named parameters. (I'm looking at you Java, that makes it even worse by starting the numbers at 1, contrary to just about every other Java API)

    4. Re:SQL Injection Trivial to Defend Against by Anonymous Coward · · Score: 0

      I get what you're saying, but I look at it from another angle. I think learning to code (ie, making a computer generally do what you want it to do) is really easy and can be learned by anyone truly interested in a matter of weeks or months. Actually understanding what is going on under the hood and the consequences of what you do are some of the hard parts.

      And it can't be the "first thing" someone learns when learning to program, because you have to at least have some idea of what you're doing before you start learning the problems with it. It's not like holding a guitar wrong, which can be corrected upfront.

      So it's more like hiring a surgeon because they know how to use a scalpel and can name all the parts of the body, without testing to see if they know anything about how it actually works. If you don't have any knowledge of surgery yourself, it's could be hard to detect fakers.

    5. Re:SQL Injection Trivial to Defend Against by Anonymous Coward · · Score: 0

      It can lead to bugs, depending on the interface.
      A prepared statement like "insert into table (col_a, col_b, col_c, col_d) values (?,?,?,?)" makes it easy to mix up the parameters.
      Not all prepared statement interfaces support named parameters. (I'm looking at you Java, that makes it even worse by starting the numbers at 1, contrary to just about every other Java API)

      I've been using named parameters in java for a long time.

      https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.html

      Yes, I can write plain old jdbc, but no, I'm not going to do that.

  8. SQL injection is for cows. by Anonymous Coward · · Score: 0

    You are all cows. Cows say moo. MOOOO! MOOOO! Moo cows MOOOO! Moo say the cows. YOU BOBBY TABLES COWS!!

  9. oblig by Anonymous Coward · · Score: 0

    Relevant: Exploits of a Mom

  10. PHP and CGI make it too easy... by Anonymous Coward · · Score: 0

    PHP and CGI make it too easy to write SQL-injection susceptible code.

    1. Re:PHP and CGI make it too easy... by Aethedor · · Score: 2

      And also too easy to do it right.

      --
      It doesn't have to be like this. All we need to do is make sure we keep talking.
    2. Re:PHP and CGI make it too easy... by Anonymous Coward · · Score: 0

      So, using a 'framework' makes PHP secure. Oh... ok, got it. Sure that makes sense. Patch over an inherently insecure environment (PHP) with a 'framework' to make it secure. Yeah, what is or could go wrong with that? Kinda like the myriad of 'registry cleaners' for Windows and yes the comparison is fair.

    3. Re:PHP and CGI make it too easy... by Aethedor · · Score: 1

      A language is not secure or unsecure. It's what developers do with it that makes the result secure or unsecure. I can write a .NET or Java application that has all the vulnerabilities you can think of.

      --
      It doesn't have to be like this. All we need to do is make sure we keep talking.
    4. Re:PHP and CGI make it too easy... by Anonymous Coward · · Score: 0

      Most anything can be made secure or not secure. By *default*, using often repeated documented methods, PHP makes it far easier to do the wrong thing than the right thing, never a good design model starting point. Even an earlier PHP code example (in another comment) showing 'secure' PHP code using PHP Prepared Statements is not secure, not even close! Break-ins via PHP/SQLi far outnumber ALL other language/environs put together by several factors. But go ahead, keep believing all programers will follow some optimal omniscient vision and ignore the realities of the data.

    5. Re:PHP and CGI make it too easy... by CrashNBrn · · Score: 1

      Interesting. Banshee includes many features that every other "CMS" require "extensions" for -- which winds up being mostly unverified third-party code from developers of possibly questionable skill. It would also appear that Banshee's source has undergone at least one external third-party security audit.

      I wonder how Banshee compares to ProcessWire...

      From the surface at least Banshee looks more "big-feature" complete|inclusive than ProcessWire.

    6. Re:PHP and CGI make it too easy... by Aethedor · · Score: 1, Informative

      If any other language would have the same popularity as PHP, it would suffer the same problem. All the noobs that write bad PHP code would than write bad .NET/Java/Python/whatever code. With 'same popularity', I mean being used by all the noobish kiddo's that now abuse PHP.

      --
      It doesn't have to be like this. All we need to do is make sure we keep talking.
    7. Re:PHP and CGI make it too easy... by wonkey_monkey · · Score: 1

      Yeah, what is or could go wrong with that?

      You tell us. Or maybe you don't actually know the answer, and just want to imply that you do.

      --
      systemd is Roko's Basilisk.
    8. Re:PHP and CGI make it too easy... by Anonymous Coward · · Score: 1

      There is no denying that PHP was made with design decisions that make it easy to write insecure code by default. PHP is less secure by default by itself for noobs and those far better than noobs. Look at FB's history with PHP. They created "Hack" to avoid many of PHPs problems, yet kept the good parts of PHP... noobs, hardly. Being 'popular' should have driven PHP to be secure, not used as an excuse for why it's easy to hack with SQLi.

    9. Re:PHP and CGI make it too easy... by Anonymous Coward · · Score: 0

      This framework doesn't prevent programmers from introducing SQL injection vulnerabilities. It does nothing to enforce binding values beyond throwing up a stink about the use of the deprecated mysql_* functions (which are removed in PHP 7). It tries to catch SQL Injection via static analysis, but the supplied tool is too primitive to do this competently.

      It parses PHP files with regular expressions and attempts to discern if some form like $this->db->query("Select * FROM table WHERE id = $id"); is used. It breaks as soon as a query uses a ) inside it.

  11. Simpler times by Anonymous Coward · · Score: 0

    Back in the day there was no such thing as malicious hackers. Just lads who would put a few funny comments into your db and leave you alone. Now we live in a more cut-throat interworld where everyone's out for profit or just to cause maximum damage. I think we should go back to the old days. We need to re-invent the way we communicate to get away from all the sh1tbags, packet ham radio might be the way to go.

  12. I just don't get how it happens by Anonymous Coward · · Score: 4, Interesting

    You are absolutely right. I see this all the time as the hiring manager in a web shop. I always present candidates with this question:

    1. Find and fix the potential SQL injection vulnerability: // .. /*@var \PDO */
    protected $dbh; //..
    public function getOption($name)
            $sql = "SELECT val FROM options WHERE name = {$name}";
            $stmt = $this->dbh->prepare($sql);
            $stmt->execute();
            return $stmt->fetchColumn();
    }

    For those who don't know PHP, the answer is:
            $sql = "SELECT val FROM options WHERE name = ?";
            $stmt = $this->dbh->prepare($sql);
            $stmt->execute(array($name));

    Almost no candidates out of school even know what I'm asking them to do. About half of people with experience get it right; a quarter of them understand the question and get it wrong, and a quarter don't understand the question. I find that it doesn't matter how many years of experience they have, about a quarter of programmers just don't understand what SQL injection is.

    I just don't get it. I've spent more than a decade programming in PHP, the language that really made SQL injection a thing because it lacked prepared statements for a long, long time and even then a lot of the input escaping functions were broken. Over those years, I've picked up a lot of bad habits; some were dictated by the shortcomings of PHP4 ("dependency injection? what's that?"), others are a side effect of spending all of my time cranking out single purpose scripts that had to work yesterday ("Ctrl+C; ctrl+V").

    Nevertheless, it still blows my my mind when I encounter people in this day and age who aren't using prepared statements. Concatenating SQL is just so... messy. Seriously, it takes two minutes to write a nice, clean, understandable SQL statement as a string, and at most a three line loop to bind the values. If your are concatenating it together, you have a mess of loops and conditions (comma here?) and strings and array manipulations... It is so much more work.

    Yet I still hire jokers who can't do it because I need bodies to fill seats.

    1. Re:I just don't get how it happens by Anonymous Coward · · Score: 0

      This appears to be similar to the idea of using parameterized queries in ADO.NET with MSSQL. The dynamic part of the SQL statement(s) are represented by variables which are parameterized and passed into the data layer for execution as part of a command object. The documentation and guidance from Microsoft claims that SQL injection is impossible when using parameterized queries, which is the prescribed method these days. The fact that a programmer would not know how to protect him or herself against SQL injection in their language of choice demonstrates either stupidity or carelessness, neither of which qualities are desirable in a professional developer.

    2. Re:I just don't get how it happens by Anonymous Coward · · Score: 0

      By hiring for PHP development, you are pretty much assuring yourself that you'll get a crop of idiots with a very occasional rare gem among them who learned PHP just because it was "another programming language."

    3. Re:I just don't get how it happens by albacrankie · · Score: 2

      "For those who don't know PHP, the answer is:"

      Except when it isn't. What's the source of that $name parameter to your function? Has it been sanitized in any way? I can imagine your interviewees taking a punt on what kind of idiot they are facing. (Looks like he was born in 1955 so the answer is probably x)

    4. Re:I just don't get how it happens by Anonymous Coward · · Score: 1

      No. You are the reason that SQL injection still happens. It should be parameterized no matter what. It is a public method and as a developer you don't know where it is called from. Or where it will be called from in future iterations of your software. SQL string concatenation is inherently dangerous activity, an anti'pattern. If you absolutely must do it, then variables should be sanitized within the method that is concatenating the statement to avoid errors always.

    5. Re:I just don't get how it happens by Anonymous Coward · · Score: 0

      The problem isn't prepared queries...

      It is a problem when the query is composed from data input... which may have different variable names, different parameters...

      You have to dynamically create "prepared" queries... and making a dynamic parameter list just doesn't work very well.

      ""SELECT val FROM options WHERE name ..." is all very nice.

      Except when the field "name" can change... or have additional fields added.. or different fields....

      At which point, you are back into SQL injection territory.

      "Prepared" queries are all very nice... but so horribly incomplete. They aren't really even "SQL".

    6. Re:I just don't get how it happens by Anonymous Coward · · Score: 0

      Your getOption function doesn't have an opening brace. Yes, that's pedantic, but such an error could lead to SQLi.

      Posting anonymously due to previous mods.

    7. Re:I just don't get how it happens by Anonymous Coward · · Score: 0

      The problem is that "parameterized" SQL is static.... You can't change the fields, you can't change the number of parameters needed...

      And thereby, the SQL injection occurs again.

      It is in the nature of SQL.

    8. Re:I just don't get how it happens by KingMotley · · Score: 1

      It's not really an issue with prepared statements. Prepared statements are just a form of pre-compilation. You just want parameterized queries, which is sort of related (prepared statements are usually parameterized, but not always).

      Prepared statements are usually slower than non-prepared statements (depends on environment, database, etc), so if it is a one-off query that won't be reused then typically you don't want to prepare it. For queries you are calling over and over, or are calling repeatedly, then you want to prepare it.

    9. Re:I just don't get how it happens by KingMotley · · Score: 1

      Sorry, that should have read prepared statements incur an initial overhead, so for one-off queries they are slower, but actually executing them is faster.

    10. Re:I just don't get how it happens by Anonymous Coward · · Score: 1

      The problem is that "parameterized" SQL is static

      You can use parmeterized inputs with dynamic SQL.

      set @Qry = N'
      SELECT *
      FROM AdventureWorks2008R2.Production.Product AS p
      WHERE p.Field1 = @Param1 '

      if something2
      @Qry = @Qry + ' and p.Field2 = @Param2'
      if something3
      @Qry = @Qry + ' and p.Field3 = @Param3'

      EXECUTE sys.sp_executesql
      @statement = @Qry,
      @params = N'@Param1 integer, @Param2 integer, @Param3 integer',
      @Param1 = @parameter1,
      @Param2 = @parameter2,
      @Param3 = @parameter3

    11. Re:I just don't get how it happens by Anonymous Coward · · Score: 0

      Where are you located? Maybe that has something to do with it. In the major cities I've been looking for jobs in, I can't even get an interview despite having ten years of experience and open source contributions. I would be ecstatic if I saw a question like that during an interview because it's so damn easy.

    12. Re:I just don't get how it happens by Anonymous Coward · · Score: 0

      For those who don't know PHP, the answer is:

              $sql = "SELECT val FROM options WHERE name = ?";

              $stmt = $this->dbh->prepare($sql);
              $stmt->execute(array($name));

      On a side note, I think it's funny that for all the gnashing of teeth PHP developers do about Perl, and how scary and archaic it is, the safe way to wield PDO is a clone of the usage of DBI that's been around for a dog's age...

    13. Re:I just don't get how it happens by Anonymous Coward · · Score: 0

      You have to dynamically create "prepared" queries... and making a dynamic parameter list just doesn't work very well.

      It works just fine if you're not an idiot.

  13. Webserver with ability to block SQL injection by Aethedor · · Score: 1

    The Hiawatha webserver can block SQL injection attacks. I like to hear what you think of it.

    --
    It doesn't have to be like this. All we need to do is make sure we keep talking.
    1. Re:Webserver with ability to block SQL injection by Anonymous Coward · · Score: 0

      These things will never work. They will catch a lot of known attacks or obvious vectors, but they'll either break your web application in subtle ways (what happens when a user writes an article about SQL injection? will her text with code examples be munged?) or they'll be easy to circumvent.

      There is no substitute for prepared statements and stored procedures. Pay for programmers that know what they are, it's worth it.

    2. Re:Webserver with ability to block SQL injection by Aethedor · · Score: 1

      Hiawatha has the ability to ignore the SQL injection prevention for certain IP addresses, so you can whitelist the webadmin IP addresses.

      --
      It doesn't have to be like this. All we need to do is make sure we keep talking.
    3. Re:Webserver with ability to block SQL injection by Chris+Mattern · · Score: 0

      Ah, so you'll only be vulnerable to SQL injection from the right IP address.

      Grandparent post is correct. Do it right, and you don't need patches like this that could leave things uncovered or need clusmy unsafe patch-ups to try to cover up what you're doing wrong.

    4. Re:Webserver with ability to block SQL injection by WaffleMonster · · Score: 1

      The Hiawatha webserver can block SQL injection attacks. I like to hear what you think of it.

      All heuristic attempts at blocking SQLi not only don't work but can themselves be leveraged as a vector for attack/denial.

    5. Re:Webserver with ability to block SQL injection by Anonymous Coward · · Score: 0

      This is absolutely always a bad idea.

      It should be perfectly OK to passing strings like "select * from users where username=%s", and your application should handle them properly, and not try to interpret them as SQL.

      If people like you had their way, little bobby tables would never go to school.

    6. Re:Webserver with ability to block SQL injection by phantomfive · · Score: 1

      Yahoo used (probably still uses) a modified Apache server that does a similar thing. From what I heard, it worked fine.

      --
      "First they came for the slanderers and i said nothing."
    7. Re:Webserver with ability to block SQL injection by Anonymous Coward · · Score: 0

      So only webadmins can write articles/comments about SQL injection? OK for sites with only a limited number of people posting content, but not so much for something like, say, Slashdot.

  14. Strings are the problem by cyrus0101 · · Score: 0

    So long as queries are composed of strings, there will be injection attacks. There are tools to perform escaping, but they're optional: " 'SELECT * FROM users WHERE id=' + userid" is always going to be something the programmer can choose to do. The only solution is to remove that option. Limit database interaction to framework ORMs or query building tools (e.g. Querydsl) and the programmer can no longer choose dangerous options.

  15. The attack that _would_ go away by bytesex · · Score: 1

    If people used perl and DBI with properly prepared statements, instead of [censored] php.

    --
    Religion is what happens when nature strikes and groupthink goes wrong.
    1. Re:The attack that _would_ go away by bytesex · · Score: 1

      I don't.

      --
      Religion is what happens when nature strikes and groupthink goes wrong.
    2. Re:The attack that _would_ go away by bytesex · · Score: 1

      Plus, PHP was modelled after perl. The way one writes php to generate web pages is typically the way you do it just as well in perl (with the added bonus of clear separation of front- and backend code in perl).

      --
      Religion is what happens when nature strikes and groupthink goes wrong.
    3. Re:The attack that _would_ go away by WaffleMonster · · Score: 1

      Perl?!? Are you serious? That's the language you will have problems with to read back your own code after a minute you wrote it.

      This is the same person who recently posted the following jem:

      A language is not secure or unsecure. It's what developers do with it that makes the result secure or unsecure. I can write a .NET or Java application that has all the vulnerabilities you can think of.

    4. Re:The attack that _would_ go away by Anonymous Coward · · Score: 0

      Yes, Perl.

      DBI is an example of exactly how you _should_ design a database layer.

      The fact that PHP was inspired by Perl, but then went on to have the mysql_* as its primary database functions shows that the original PHP authors understood Perl about as well as you do.

    5. Re:The attack that _would_ go away by Anonymous Coward · · Score: 0

      So you write perl code that interacts with an SQL database and does not use parameter substitution or bound variables?

      I think I found your problem.

    6. Re:The attack that _would_ go away by Aethedor · · Score: 1

      You're right, Perl is the exception. But I wouldn't even call that a programming language. It's more like a scripting tool from hell.

      --
      It doesn't have to be like this. All we need to do is make sure we keep talking.
  16. The problem STARTS with SQL itself. by Anonymous Coward · · Score: 0

    It was (and still is) a poor relational language to use with databases.

    It MANDATES creating SQL queries on the fly...

    Only when you sidestep SQL and use parameterized queries (and even then, they get screwed up) are even close to being better.

    As long as queries have to be created by concatenating strings together to create a "valid" SQL syntax - you WILL have SQL injection attacks.

    There is no way around it.

    1. Re:The problem STARTS with SQL itself. by glenebob · · Score: 1

      There is no way around it.

      What do you mean there's no way around it? That's the stupidest thing I've heard all day. It's simple to prevent even if you write all your queries with string concatenation. It's called an escape sequence.

    2. Re: The problem STARTS with SQL itself. by ShieldW0lf · · Score: 2

      Myself, I prefer to use stored procedures for all db interactions, and set table access to deny for the account used by the web server. But that's me.

      --
      -1 Uncomfortable Truth
    3. Re:The problem STARTS with SQL itself. by Anonymous Coward · · Score: 0

      It MANDATES creating SQL queries on the fly...

      oops bullshit alert , everything else is even worse

    4. Re:The problem STARTS with SQL itself. by DahGhostfacedFiddlah · · Score: 1

      This is pretty much right. We're trapped writing snippets of one language (SQL) in another (PHP/whatever).

      Avoiding any single SQLi vulnerability is trivial - use stored procs, escape strings, or use parameterized queries. You can even avoid most problems at the organizational level as long as someone competent is in charge and raw SQL is banned or forced into rigid guidelines.

      But it seems we've collectively decided to trust our data interface to a framework that is at its core no better than an eval() in terms of inherent safety. That's just asking for trouble.

    5. Re:The problem STARTS with SQL itself. by Anonymous Coward · · Score: 0

      And just WHICH escape sequence...

      no it is not simple. That is why it keeps happening. The language itself is the source of the failure.

      Forcing everything into strings is itself a failure - not everything can be expressed properly in a string (try expressing 1/7 exactly... then store it and make a query against it. You can't. Every representation forces a roundoff...).

      That is why there is no way around it. Try generating a query dynamically... changing the field names, the number of fields in the where clause, the variations on data types...

      nope. doesn't work.

  17. The problem with SQL is syntax by Anonymous Coward · · Score: 0

    The syntax with SQL allows for breaks because of the usage of quotes. This danger can be mitigated by the use of proc's written to process each transaction. Attempting to write procs for each call is time consuming, and the syntax is very spaghetti making mistakes an issue.

    Tying function into a string was a terrible idea, sql is a bad language, and it's a slow database.

    Please end the scourge of these terrible databases.

    Think about an object database eh? I'll give you an example to mull over.
    var user={username:'bob',messages:[{username:'al',text:'hi bob!'}],contacts:[]}
    As an object when I search in an object database I get the user and all of the fields such as contacts and messages in 1 search.
    If this was an SQL database I would have had to search through all users to find this user, then search all messages to find messages for just this user, then search all contacts for contacts for just this user, that's 3 searches more than I had to do with having that directly logically connected data nested in the first place.

    1. Re:The problem with SQL is syntax by Anonymous Coward · · Score: 0

      If this was an SQL database I would have had to search through all users to find this user, then search all messages to find messages for just this user, then search all contacts for contacts for just this user, that's 3 searches more

      Ignorant idiot knows nothing about SQL and indexing

    2. Re:The problem with SQL is syntax by phantomfive · · Score: 1

      var user={username:'bob',messages:[{username:'al',text:'hi bob!'}],contacts:[]}

      When you realize how this can be translated exactly into SQL, you will be enlightened.

      --
      "First they came for the slanderers and i said nothing."
    3. Re:The problem with SQL is syntax by viperidaenz · · Score: 1

      But MongoDB is web-scale.

    4. Re:The problem with SQL is syntax by Anonymous Coward · · Score: 0

      And fails when you find out a "'" is also a valid character within the name..

    5. Re:The problem with SQL is syntax by phantomfive · · Score: 1

      Learn about parameterized queries. It's not a problem.

      --
      "First they came for the slanderers and i said nothing."
    6. Re:The problem with SQL is syntax by Anonymous Coward · · Score: 0

      Ignorant ass developers like that are a reason why I avoid MongoDB and most other NoSQL crap.

  18. What decade you living in? by Anonymous Coward · · Score: 0

    PHP's supported prepared statements for at least a decade. I bet you still test your websites in IE6.

  19. the most easy by Anonymous Coward · · Score: 0

    'It's the most easy way to hack,'

    Also know as 'easiest'

  20. The reason? A lack of programmers by Opportunist · · Score: 3, Interesting

    No, I didn't write "a lack of people who write code". I exactly mean what I wrote: A lack of programmers.

    What we have today is a load of people who learned programming somehow, kinda-sorta, but without understanding just what they're doing. Now add how most of them gains information about how to do things. By looking it up on the internet. And taking the first solution that looks like it works.

    Of course it's easier to simply concat strings than using prepared statements and parameters. It is simply more readily understandable and less convoluted for people who have little knowledge and less time to gain it. And they don't know anything about security and why this could possibly be a security problem.

    These people are cheaper than people who know what they're doing. So much cheaper even that the additional time they need to get anything done is easily compensated. And whether it is a security problem is usually only found out after a security breach happens because, well, whoever hired them has even LESS knowledge about security.

    And since every year a new batch of people comes out of schools that kinda-sorta learned how to kinda-sorta do queries, this problem will mean job security for me 'til retirement.

    --
    We used to have a Bill of Rights. Now, with the rights gone, all we have left is the bill.
    1. Re:The reason? A lack of programmers by edtice1559 · · Score: 2

      Although I mostly agree with you, I feel compelled to put out that in order to write software today, one must know both the technical programming aspects *and* be an expert on the target domain model. The days of a business analyst writing requirements are over. The world changes too fast. If you're implementing tax software, the IRS publishes new rules and you have to be ready on January 1st. "Poor" code that implements the rules correctly is valuable. "Good" code that doesn't quite understand the domain model and gets some things wrong isn't useful. In terms of the triple-constraints, time is *usually* the primary constraint and quality is the tertiary constraint. The "poor" apps survive because their authors get to market and make money. A *good* security solution is one that would make things go *faster* not slower. Then there would be widespread adoption.

    2. Re:The reason? A lack of programmers by Anonymous Coward · · Score: 0

      Prepared statements are not the answer. Parameterized queries are the answer. The first thing you should do is to learn the difference, so I'm going to help you out a bit here.

      A parameterized query is simply a query that is merged with a named parameter list prior to execution. There is nothing special about them, other than that they are the answer to any and all SQL injection problems. Stored procedures are a special type of parameterized query.

      A prepared statement is a method of using a parameterized query that 1) pre-compiles in the database engine, 2) defers parameter binding until execution, 3) can be configured to auto-reset parameters to default values before the next execution, 4) does not require recompilation for each execution, and 5) stays resident on the connection until explicitly released. This improves performance for tightly-looped query execution, but requires you to take responsibility for proper cleanup. Failure to properly unprepare a query results in connections that can't be used for anything but the "open" p-statement, but can't release the p-statement because they don't have the reference to it anymore.

      Do not recommend prepared statements to newbies unless there is a specific performance need for it and proper oversight by a senior developer. I have been there and done that, and you don't want the scars from it.

    3. Re:The reason? A lack of programmers by Anonymous Coward · · Score: 0

      They also don't work when the query must be dynamically generated... variable number of fields returned, variable number of fields to key on, with variable number of parameters....

      Granted, they are better than SQL... but not by much. Most of them still get treated like a "sprintf" function... and then passed to the SQL interpreter. And that is a big FAIL.

    4. Re:The reason? A lack of programmers by Anonymous Coward · · Score: 0

      Belittling a programmer who looks up solutions on the web? Do you actually code, or are you an architect? This is typical programmer conceitedness that I can't stand. Everyone thinks they are a better caliber of programmer than they other guy.

      You learn something cold, mostly through fixing bugs and working some project where you discover the dirty details about some library, language or platform.

      Then you turn around and criticize people who don't know something as well as you do, because they haven't had the experience with it that you have, belittle them and question their credentials as a programmer.

    5. Re:The reason? A lack of programmers by Anonymous Coward · · Score: 0

      Never use a variable number of parameters.

      If you need a list of values in a database that doesn't support array types, there are easy-to-find "split" functions that you should use. Convert them into a temp table in-script, then join against it for filtering.

      If you need optional parameters, remember that NULL is a valid value for every SQL type and test for it in your WHERE clause. It makes your query a bit longer (but not much), and it makes your fixed set of parameters completely NULL-safe. Example: WHERE (@foo_id IS NULL OR foo_id = @foo_id) AND (@bar_id IS NULL OR bar_id = @bar_id)

      In all of my years, I've found that there are approximately zero valid reasons to use procedurally-generated SQL. Every single use-case for that technique is covered by what is generally referred to as "doing it the right way".

    6. Re:The reason? A lack of programmers by Anonymous Coward · · Score: 0

      In all of my years, I've found that there are approximately zero valid reasons to use procedurally-generated SQL

      Flexibility. If you do not know how to use is your problem.

  21. I absolutely WAS. Was a CMS. Much better now by raymorris · · Score: 4, Informative

    Absolutely PHP was originally for for non-programmers. It was a CMS written in Perl, for people who couldn't use the Perl templating systems directly. That was a long time ago, of course.

    It was abused as a general programming language, often by people who didn't know about file permissions and couldn't be bothered to learn how to chmod 755. That wouldn't have been a huge problem if they weren't putting the scripts on web sites, for everyone to attack. That was a big problem for several years - non-programmers who didn't want to learn an actual programming language wrote PHP scripts and PUT THEM ON THE INTERNET. It wouldn't really have been a big deal if they wrote scripts for their own desktop or for their local intranet.

    Now that PHP has been used as a general-purpose web programming language for several years, it has been significantly updated to better fit that role. Current PHP is much, much better than it was a few years ago. It's still relatively easy, though, so it -can- be used by people who are clueless. But now it's also used, correctly, by people who are actually competent.

    1. Re:I absolutely WAS. Was a CMS. Much better now by grcumb · · Score: 1

      Absolutely PHP was originally for for non-programmers. It was a CMS written in Perl, for people who couldn't use the Perl templating systems directly.

      The first sentence is correct. But PHP was written in C, and calling CGI.pm a templating system is pretty generous. :-)

      That was a long time ago, of course.

      Clearly. :-)

      --
      Crumb's Corollary: Never bring a knife to a bun fight.
    2. Re:I absolutely WAS. Was a CMS. Much better now by Anonymous Coward · · Score: 0

      Personally I think the main purpose was to stop having to understand how to speak CGI and/or fastCGI to the webserver. It's main competitors at that time were mod_embperl and SSI.

      I figure that if something is going to replace PHP as the noob language of choice, hello world has to be shorter than

      Hello world.

      and definitely not

      15 lines of include statements and setup
      syntactic sugar fluff
      webService.response.setCode(200);
      webService.response.setHeader('mime-type', 'text/html')
      xhtml = xhtmlHelper.factory(xhtmlHelper::XHTML1_0_BACKWARD_COMPAT)
      webService.response.body.setType(xhtml.getType())
      page = xhtml.nodeGenerator.createElement('html')
      page.appendChild(xhtml.nodeGenerator.createElement('head').appendChild(xhtml.nodeGenerator.createElement('title').appendChild(xhtml.nodeGenerator.createCData('Hello World')))
      page.appendChild(xhtml.nodeGenerator.createElement('body').appendChild(xhtml.nodeGenerator.createElement('p').appendChild(xhtml.nodeGenerator.createCData('Hello world.')))
      webService.response.body.setContent(page)
      webService.response.sendToClient(true)

      With another 30 lines of XML to set up the server, 50 lines of XML to set up the "webapp" and an arcane Apache configuration directive that you pasted off the internet that causes Apache to stop serving everything but your webapp.

      BTW Bonus points if you use a "templating system" which involves having one file containing

      <html>
        <head>
          <title>Hello World</title>
        </head>
        <body>
          <p>Hello world.</p>
        </body>
      </html>

      and another file similar in length to the first example that sets up the template engine, locates the template, and submits it to the client. Doubly so if the template engine requires another 30 lines of XML to configure.

  22. New day, same exact story. Incompetence. by Anonymous Coward · · Score: 0

    Same answer, both ways. Most people aren't very skilled at either sexual interaction or web site security.

    There's no mystery here.

    Our society is so bad at sexual education and so mired in sexual prohibition and repressive, backwards thinking it's a wonder we even manage to reproduce.

    As for web site builders bothering to learn how to sanitize input, and make sure that the mechanism for fetching that input for sanitization is as clean and safe as possible... you have to understand that a very large number of them have no real programming skills. They know HTML and CSS, they can prod PHP a bit, and they may have spent some time sniffing at the buttcrack of that abortion they call UX design (which explains why so many websites demonstrate not a single fucking clue that rollover menus and popups are toxic and visitor/customer-unfriendly and just plain stupid) but they sure as hell don't understand programming. They only learn about injection vulnerabilities when someone rips off their website one way or another.

    A programmer's "easy" is a script kiddy's completely unknown territory.

    1. Re:New day, same exact story. Incompetence. by Anonymous Coward · · Score: 0

      I became responsible for a company website after somebody in mainland China (thank you Google Analytics) performed a SQL injection attack on it.

      After noting the various log files, IIS version and patch level I went to the contract programmer (hired by a marketing manager) that maintained the site and presented him with the need to protect from these attacks.

      He professed absolutely no knowledge about how to protect against it, so I closed out his contract, hired a contractor with the ability to quickly firm up the site and then went on a three month adventure in upgrading to a current version of IIS, getting it set to the right patch level, performing administrative hardening and finally re-writing the forms input to properly handle any improper inputs.

      From this experience I am NOT surprised that most sites have vulnerabilities

  23. Pay peanuts by TekPolitik · · Score: 4, Insightful

    Because businesses think software development in general, and especially web development, is easy. They hire monkeys and pay peanuts (or sometimes even serious dollars that could get them quality of they could recognise they were being taken for a ride), and we continue to see the most basic errors being repeated across most web sites. Seriously, the quality of web developers generally is absolutely appalling.

    1. Re:Pay peanuts by readin · · Score: 1

      Exactly. Quality costs time and money. If you want to prevent SQL-Injection you not only need senior developers, you need an environment where they are encouraged to find problems in code and bring attention to it so people can learn from mistakes. Code reviews take time and money but customers don't want to pay for them. They may say they're willing to pay for code reviews but but they'll complain about the cost and hire someone else if you actually do them.

      --
      I often don't like the choices people make, but I like the fact that people make choices. That's why I'm a conservative.
    2. Re: Pay peanuts by TekPolitik · · Score: 1

      There are also many mistakes being made that demonstrate a basic lack of understanding, that cannot be attributed to lack of code review (my favourite example is email address validation code that assumes a TLD must have 2 or 3 characters).

    3. Re:Pay peanuts by Tablizer · · Score: 1

      Those who make the decisions often focus on superficial things. I don't know a fix for that.

      I've seen people take sloppy shortcuts to put something visually snazzy up quick, and the clueless people who evaluate it think they are a Web-God.

      If one points out potential security, ADA, performance, maintenance, device-dependent problems, they are painted as jealous nay-sayers. It's happened to me many times.

      And those making the decisions expect to get promoted or hired away fairly soon; the long-term is not their concern.

      Chimps are drawn to shiny objects, not smart objects. That's just the way it is. It's not a technology problem, it's a people problem.

      Who knows, maybe I'm making similar mistakes with things I know little about like plumbing, car repairs, bank accounts, etc. Maybe civilization is just growing too complex to manage well. We cannot all be subject experts in everything because the subjects keep growing.

  24. You've got it backwards, kid. by Anonymous Coward · · Score: 0

    Senior developers who have diversified experience have seen it all before, and are the most likely to know about these vulnerabilities and how to avoid them. That is why their price tag is high, which is also why companies try to cheap-out and avoid them.

    Entry-level developers are the most likely to believe they know everything, precisely because they have too little experience to have a clue about how much they don't know, and also because all they have known is academia so all they have encountered are easy, academic problems (as opposed to hard, complex, real-world problems). Also, schools have proven that they are bad about teaching this to kids, so being freshly-trained is not the same as being well-trained.

    It is true that some developers have been in it for a long time, and have been doing it wrong the whole time. It happens when someone finds a special niche where they can just solve the same problem over and over (non-diversified experience). It is also true that plenty of people who are simply not qualified to be architects bill themselves out as architects because they want that money....what they have are good interviewing and salesmanship skills and mediocre programming skills. These guys are toxic to the businesses that hire them.

    Lastly, sometimes you get a green fresh-out-of-college kid who actually *is* of above-average talent and knowledge (they all think they are, and very few actually are). But such people can spot the mistakes that these poser-architects are making, but when they raise the challenge they are not respected due to their lack of experience. This is very rare (though nearly everyone believes it to be true of themselves). You might be one such. Maybe.

  25. Because people are careless by Anonymous Coward · · Score: 0

    This is like asking why buffer overflows are still around. People forget to sanitize user input: In C it's letting user input flow past the end of a buffer (often exploiting the stupidity of the design choice known as the null-terminated string); in SQL it's injecting metacharacters into SQL statements that aren't escaping their user input (or using prepared statements).

  26. Why? by Lumpy · · Score: 2

    So why, in 2015, is SQLi still leading to some of the biggest breaches around?"

    Easy, idiots writing the apps because companies don't want to pay for skilled people that demand honest wages. they instead outsource ti for the lowest bidder and then bitch when they get crap quality because that is all they were willing to pay for.

    --
    Do not look at laser with remaining good eye.
    1. Re:Why? by hcs_$reboot · · Score: 1

      they instead outsource ti for the lowest bidder and then bitch when they get crap quality because that is all they were willing to pay for.

      No they just hire the cheapest because they have no clue he/she is more or less competent than the more expensive candidates.

      --
      Slashdot, fix the reply notifications... You won't get away with it...
  27. managers like to promote on 3wk projects by Lobachevsky · · Score: 3, Interesting

    There simply isn't any incentive for to build software that will last through some cyber attack some 10 months or 3 years into the future. The current incentives reward sloppily slapping together something that barely functions and gives a demo without crashing. If your demo crashes and makes the boss look bad, you're fired. If your demo works, has slick graphics and no spelling mistakes and the english dialog is polished, you get a raise. You're building software for the boss's demo, you're not building software that's robust, handles edge-cases, and input sanitizes everything. I meant, you could, but you're not getting paid any extra for it.

  28. Legacy by Anonymous Coward · · Score: 0

    Where I work, we (or sometimes our opponent: the Internet) sometimes turn up injection bugs. The reason the bug is there, is because it was written over a decade ago by someone who did not care.

    Removing them all isn't possible, because we don't know what all that code is intended to do. I can't fix the code because it doesn't make any sense to me, and I can't replace it with a rewrite, because nobody knows what the code is supposed to be doing. It's not that there's missing documentation; it's that there is no documentation at all. And the code can't serve as documentation, because .. well .. it was written by the kind of people who give zero fucks about injection bugs. So it's not like the injection bugs are the only thing wrong with it; it's nearly completely inscrutable.

    So it's going to be there until the business rules change enough (which may be never) such that someone can say, "Oh, let's just totally replace that part." Until it's replaced, we'll have bugs. Period. Nobody can fix it.

  29. Well by Greyfox · · Score: 2

    There's a lot more client/server going on, and a lot of programmers haven't discovered that you can't trust the client and are doing all their input validation and sanitation on the client side. As long as that's going on, this sort of attack is going to be popular. '); drop table articles.

    --

    I'm trying to teach myself to set people on fire with my mind... Is it hot in here?

  30. It's not the learning, it's the public blundering by Anonymous Coward · · Score: 0

    By all means, learn. Just don't do it on a public-facing website containing other people's data, m'kay?

    It's like walking onto a firing range with a fucking target painted on your forehead.

    It isn't going to go well.

  31. elitist fucks by Anonymous Coward · · Score: 0

    Because elitist fucks doesnt teach but only knows how to condemn noobies asking questions and the cycle goes on and on..

  32. incompetent programmers by Anonymous Coward · · Score: 0

    This is all due to incompetent programmers, but the reality is bad programmers are always going to make up a significant portion of the dev population. I would think the better solution here is for DB software to make it harder for devs to be incompetent. e.g. disable the ability to do remote dynamic SQL by default and make stored procs and parameterized queries the always the first method documented on how to retrieve and send data, make them jump through hoops to enable it, the same for DB libraries.

  33. Just ban PHP by Anonymous Coward · · Score: 0

    You can solve most SQL injection attacks by just passing a law banning PHP.

    1. Re:Just ban PHP by Anonymous Coward · · Score: 0

      And you can solve all SQL injections by banning SQL

  34. Mod this up ! by Anonymous Coward · · Score: 0

    Mod StormReavers answer up

    StormReavers answer is on the money.

    Not only does it make the code readable and secure, it avoids the need to craft stupid string manipulation and data validation code. The reason that SQL injection is so prevalent is that people have never seen how easy it is to do this properly.

  35. Legacy code by Tony+Isaac · · Score: 1

    There is a ton of legacy code out there that was written before people worried about SQL injection. There's so much of it, going back and refactoring it would be as monumental as fixing the two-digit year problems of Y2K. Businesses really don't like to pay money for software development that doesn't lead to more sales, so it's a hard sell for IT departments. Sadly, this means that the problems don't get fixed until after a company loses money due to an actual attack.

  36. Matter of opinion by Anonymous Coward · · Score: 0

    Maybe you are all looking at this from the wrong angle, I mean if people don't lookup my faulty tutorials on MySQL, then how am I supposed to hack them to make a living?

  37. Matter of opinion by Anonymous Coward · · Score: 0

    You guys got it all wrong, if people educate themselves on how to properly defend against SQLi attacks instead of reading my purposely faulty tutorials, then how am I supposed to hack them to make a living?

  38. Because SQL sucks by Anonymous Coward · · Score: 0

    SQL injection exists because SQL is a bad interface to databases. We should be calling functions or passing a data structure instead of converting your data into a string then sending the string to the database which will then parse it into another format. SQL isn't typed in by sectaries any more, it should be upgraded.

  39. visual appeal by Anonymous Coward · · Score: 0

    Good code has low visual appeal, only appreciated by a few. Some objective tests could help, to test the code against common attacks.
    Which input characters that are allowed, and how many, should not be hard to put a limit on.

  40. Because we're not as "full stack" as we think by anchovy_chekov · · Score: 1

    Somewhere along the way we dispensed with DBAs and anyone else who might freak out at insecure access to the database layer. Glad that's working out.

    1. Re:Because we're not as "full stack" as we think by Anonymous Coward · · Score: 0

      "If A devided by B is less than the cost of a recall, we don't do one."

      It's working out great stock prices have never been higher.

      Did you think there was any other metric that matters?

  41. Its all about layers by Anonymous Coward · · Score: 0

    Unfortunately too many developers like to do all of the work themselves. That generally works out badly due to a lack of in depth knowledge in each layer of coding and often leads to code in the wrong place.

    Layering code and restricting access in the right places won't necessarily stop some one from getting into a system but it will reduce the amount of damage to be done.

    The biggest mistake in Web design is giving the web layer direct access to the underlying database tables. This means if the web server can be broken into then it becomes easy to steal every ones data.

    On the other hand if the web layer can only access stored procedures within the database and not the tables themselves and these stored procs are paramaterised correctly it will only ever be possible to retrieve one item of data at a time and only if the correct keys are known in advance.

    Accessing databases via stored procedures and locking down database accounts correctly will prevent large scale data protection. New developer especially, are more interested in doing everything themselves and using nosql and some of the more basic open source databases for the cool factor and its costing companies dearly.

  42. SQL has no place in applikation persistance. by Qbertino · · Score: 2

    I always wonder why people - even professionals (ableit only the non-DB pros) - think SQL is a feasible means for an application to utilise persistance. It isn't. In fact, it's a huge smelly turd for app-persistance and using it so broadly for this sort of work is a really harebrained and abysmally stupid idea.

    That we have to deal with SQL injection problems is one of the countless pieces of crap based on this technology decision.

    SQL was meant as an end-user interface for interacting with relational database - and for that it is absolutely perfect. End of story.

    Using SQL as intermediate for application persistance is one of the most annoying and studidest things in the history of applikation development - for reasons to countless to list them. DB designers are among those who time and time again shake their heads in disbelief when they see the mess devs do with SQL.

    --
    We suffer more in our imagination than in reality. - Seneca
    1. Re:SQL has no place in applikation persistance. by phantomfive · · Score: 1

      SQL was meant as an end-user interface for interacting with relational database - and for that it is absolutely perfect

      That argument was lost decades ago, man. Turns out SQL wasn't that great for end-users, but programmers kind of liked it.

      --
      "First they came for the slanderers and i said nothing."
    2. Re:SQL has no place in applikation persistance. by Chelloveck · · Score: 1

      Thank you. I've been saying this for years. I'm glad someone else can see that the Emperor has no clothes.

      SQL sucks. Not the concept of a relational database; that's something that's pretty cool. But the so-called "Structured Query Language" used to interact with the database is the worst affront to programming ever(*). It's not bad for user interaction, and I know it was an easy path to hacking in database support for languages that didn't have it. But for crying out loud, continuing to use it is just like passing a single string to the shell for execution. You never do that, you use execv() or whatever your language has for a wrapper around it. At the very least you should be able to do the same damned thing for your database!

      (* One could argue that PHP or AppleScript are worse. I won't quibble.)

      --
      Chelloveck
      I give up on debugging. From now on, SIGSEGV is a feature.
  43. PHP.net says Perl & C in 1994. Text::Template, by raymorris · · Score: 1

    PHP.net says "1994 - Started writing CGI scripts in C and Perl".
    http://talks.php.net/show/comm...

    By the time PHP was gaining popularity, Text::Template and HTML::Embperl were available for Perl.

    Rasmus's comments in this interview are revealing:
      "I donâ(TM)t know how to stop it, there was never any intent to write a programming language [â¦] I have absolutely no idea how to write a programming language, I just kept adding the next logical step on the
    way."
    MP3 recording of these comments:
    http://web.archive.org/web/201...

  44. Use JOOQ by clifwlkr · · Score: 1

    The sad thing is that most programmers are still using simple string concatenation to write their SQL programmatically. In this modern day, that is beyond silly. If you use a DSL like jooq, you get several advantages. First off, all strings will automatically be bounded and avoid the simple injection tactics that most people use. Second, you can change databases on a whim by just changing the dialect. This is great for testing and using in memory databases for unit tests. If people just took that simple step, very few attacks would remain, and they would probably be much happier programmers with far fewer bugs!

  45. Re:It's an SQL flaw by Anonymous Coward · · Score: 0

    Don't most database systems allow you to change the statement and quote delimiters? Mine does.

  46. MVProc by jswalter9 · · Score: 1

    Take a look at MVProc - http://mvproc.free-blog.net/ SQL Injection doesn't ever get a foothold, and it (the module) is very efficient with a tiny footprint. (Yes, I wrote it; and I'll take whatever feedback comes my way.)

    --
    Retired from software... maybe. Sort of.