Why Does Sql Injection Work?

Author: admin  //  Category: SQl Injection

SQL injection works because programmers don’t properly escape SQL queries that use data submitted by an untrusted source. The most common place for this vulnerability to be exploited is on dynamic web forms. If a user submits text that has correctly formatted SQL code in it and the server-side software does not prevent that SQL code from being run by the database during the database query, the user has successfully injected SQL into the database query. The most common way of preventing SQL injection is escaping all characters of a query that are not part of the intended SQL code, but may be interpreted as SQL code given its syntax, with back-slashes. Most programming languages have built in functionality for this action (i.e. PHP’s mysql_real_escape_string function). Another method is using stored procedures, which limits the queries that may be run to only those that are trusted. If you have any further questions, please feel free to message me.

Tags: , ,

One Response to “Why Does Sql Injection Work?”

  1. HPWebSol Says:

    SQL uses data and commands in the same command. Because of this, commands and data are sent together and the computer only has syntax to figure out what is data and what is commands. So if a user types in data that has been designed to look like a command the computer will try to run it
    Select `*` from `users` where `password` = ” or 1=1 -’ Limit 1;
    That is an example notice in the part where the password should have been passed, well the user put their own ‘ and then added a true statement (to allow a login) and then a comment (-) telling the computer to ignore everything that follows.
    If they escape it correctly, this wouldn’t be a problem.

Leave a Reply