Asish Ku. Rath
Sr. Software Developer
 Introduction
 Types of SQL INJECTION
 Steps for performing SQL INJECTION
 How it Works
 Countermeasures
 Conclusion
 References
 SQL Injection is a type of Security
Exploit in which the attacker
injects SQL statements to gain
access to restricted resources and
make changes.
 TARGET: Web Application with
backend database
 Uses client supplied SQL queries
to get unauthorized access to
database.
 SQL Manipulation
 Code Injection
 Function Call Injection
 Buffer Over Flow
 It means to manipulate and retrieve data in a
relational database.
 SQL Manipulation comprises the SQL-Data
change statements, which modify the stored
data but not the schema or database objects.
 Code injection is the exploitation of computer
application that is caused by processing
invalid data.
 It is always used malevolently which means it
is always used in an evil way to destroy a
database by exploiting the other codes.
 It is one of the most common type of
injection technique where functions are used
for injection.
 When a function call a parameter then the
attacker passes a different parameter to the
function resulting something different than
expected.
 It also one of the common technique used for
injection at the users input side.
 It is a mechanism of injection by input of data
exceeding the limits of the fields of the user
input resulting an error message using which
the SQL codes are injected.
 Input field to submit data
(e.g. a login page)
 Check for server pages if input field is absent
e.g. http://www.xsecurity.com/index.jsp?id=10
 In the above example attack will be like this:
e.g. http://www.xsecurity.com/index.jsp?id=debu’ or 1=1 –
 Look for errors: This can be done using single quotation
mark (‘). E.g.
Using single quote in the input
•sujit’ or 1=1 --
•login: shweta’ or 1=1 --
•http://search/index.asp?id=sql’ or 1=1 --
Depending on the error:
• ‘ or 1=1 --
• “ or 1=1 --
•‘ or ‘a’ = ‘a
• “ or “a” = “a
•‘) or (‘a’ = ‘a)
 Minimize the Privilege of Database
Connection
 Disable Verbose Error Message
 Protect the system account “SA”
 Audit Source Code:
Escape Single Quotes
Input Validation
Reject Known Bad Input
Input Bound Checking
All user inputs should be filtered
SQLBlock
Now a days SQL injection is one of the
biggest nightmare among Database
administrators. Though we have a lot of way
for its prevention but still today’s most
website suffer from this attack.
 http://hack.er.org/sqlinjection
 http://hackercentre.com/sqlinjectioncheetsh
eet
22

SQL Injection

  • 1.
    Asish Ku. Rath Sr.Software Developer
  • 2.
     Introduction  Typesof SQL INJECTION  Steps for performing SQL INJECTION  How it Works  Countermeasures  Conclusion  References
  • 4.
     SQL Injectionis a type of Security Exploit in which the attacker injects SQL statements to gain access to restricted resources and make changes.  TARGET: Web Application with backend database  Uses client supplied SQL queries to get unauthorized access to database.
  • 5.
     SQL Manipulation Code Injection  Function Call Injection  Buffer Over Flow
  • 6.
     It meansto manipulate and retrieve data in a relational database.  SQL Manipulation comprises the SQL-Data change statements, which modify the stored data but not the schema or database objects.
  • 7.
     Code injectionis the exploitation of computer application that is caused by processing invalid data.  It is always used malevolently which means it is always used in an evil way to destroy a database by exploiting the other codes.
  • 8.
     It isone of the most common type of injection technique where functions are used for injection.  When a function call a parameter then the attacker passes a different parameter to the function resulting something different than expected.
  • 9.
     It alsoone of the common technique used for injection at the users input side.  It is a mechanism of injection by input of data exceeding the limits of the fields of the user input resulting an error message using which the SQL codes are injected.
  • 10.
     Input fieldto submit data (e.g. a login page)
  • 11.
     Check forserver pages if input field is absent e.g. http://www.xsecurity.com/index.jsp?id=10  In the above example attack will be like this: e.g. http://www.xsecurity.com/index.jsp?id=debu’ or 1=1 –  Look for errors: This can be done using single quotation mark (‘). E.g.
  • 12.
    Using single quotein the input •sujit’ or 1=1 -- •login: shweta’ or 1=1 -- •http://search/index.asp?id=sql’ or 1=1 -- Depending on the error: • ‘ or 1=1 -- • “ or 1=1 -- •‘ or ‘a’ = ‘a • “ or “a” = “a •‘) or (‘a’ = ‘a)
  • 16.
     Minimize thePrivilege of Database Connection  Disable Verbose Error Message  Protect the system account “SA”  Audit Source Code: Escape Single Quotes Input Validation Reject Known Bad Input Input Bound Checking All user inputs should be filtered
  • 17.
  • 20.
    Now a daysSQL injection is one of the biggest nightmare among Database administrators. Though we have a lot of way for its prevention but still today’s most website suffer from this attack.
  • 21.
  • 22.