SlideShare ist ein Scribd-Unternehmen logo
SQL Injection Attacks

          Tyler Fetters
          Stacy Watts
            3.13.2013
CS586 – Introduction to Databases
    Portland State University
Today‟s Topics
     What is a SQL Injection Attack
     Security in SQL
       How to lock down a dbms
       Best Practices
       Common Mistakes
     SQL Injection Attack Example
     Questions




2
SQL Injection Attack - Definition

     SQL injection consists of the possibility the
     user has to inject fragments of SQL queries in
     Web application input fields.

     If these fields or the resulting SQL query to be
     sent to the database are not properly
     validated, then it might be possible for the
     attacker to access unauthorized data, reverse
     engineer the database structure, or even to
     insert/delete data [1]
3
Security in SQL – dbms Lock Down
     Keep your PostgreSQL version up-to-date
     Network design should include firewalls
     Track user Input
     Analyze the correctness of SQL statements
     Additional security
       SQL Randomization
         Appending random numbers to all statements, and rejecting
          any not containing such numbers
       Black Box testing your solution prior to release
     Third party software options for testing and
     locking
         Examples: SQLMap, V1p3R, Candid

4
Best Practices




5
Security in SQL – Best Practices
     Parameterize all Queries
         Example From Week 7 – Guest Lecture




     Stored Procedures and Permissions
       All code can be implemented using stored procedures
        on the DB
       Use the account with the lowest permissions needed for
        the task
       In PostgreSQL there are the following privileges:
         SELECT (read), INSERT (append), UPDATE
         (write), DELETE, RULE, REFERENCES (foreign key), and
         TRIGGER.
6      Eg. GRANT SELECT ON accounts TO external;
Security in SQL – Best Practices
     Input Validation Checks
       Implement code that ensures correct inputs are
       given.
         Some examples:
             A name input should not contain an “=“ with it
             A zip code should only contain numbers


     Avoid printing error codes directly
       Use Try and Catch Mechanisms
         Within the Catch Provide meaningful error messages to the
          user


7
Security in SQL – Best Practices
     Encrypt Secure Data
       Passwords should be encrypted or hashed not
       stored as text




       What about CC info? Or SSN?


     Data Segregation
       Store secure data in a separate database from non-
       secure data
        Not accessible from outside of the network
8
        Example Bank Teller
Security in SQL – Best Practices
     Keep your database Schema hidden
       Avoid using select *….
       Use the table and attribute aliases
       Avoid obvious nomenclature and schema
         i.e. User (first_name, last_name, user_name, password)


     Log and Audit you dbms
       Verify users and permissions
         Require high security passwords and passwords be
          updated
       Remove any non-essential/not approved tables
       Helps to find potential threat attempts and prevent
       future attacks
9
Common Mistakes




10
Security in SQL – Common Mistakes
      Turning off the default security configuration
          The idea might be to make input easier for the user by
           allowing any input
          Not a good idea. Know what might happen by turning off a
           security measure before doing so.
      Security through Obscurity
          As long as the machine is connected to the internet and
           responsive, attacks are possible
          “In operational environments, it has been noted that
           applications experience an average of 71 attempts an hour.”
           [3]
      Accessing Tables Directly
          If the information is for viewing, use a view, don‟t expose the
11
           table
Security in SQL – Common Mistakes
      Obvious nomenclature and schema
          Once access is gained even if the schema is protected it might
           be possible to guess User (Name, Password) as a relation.
          Even without, possible to damage with drop table.
      Not checking logs, or performing audits
          No assumptions about data integrity
      User Permissions pitfalls
          Setting user permission tiers too high
          Setting global user permissions for ease of administration
          The user the application uses to connect to the database
           should never be the owner of the objects created in the
           database
      Storing sensitive data without encryption
          Eg: social security number, current location, credit card
           information
12
SQL Injection Attack Example
      Go to the following url and complete the survey
        http://sqlinjection.70sites.com/
      Now we will Run a SQL injection attack


      SQL Injection Attack
        $lastn = stripslashes($lastn);
          Used to remove built in security of “” on „ or “
          Might be done for names like O‟Brian




13
Questions




14
References
      [1] http://en.wikipedia.org/wiki/SQL_injection_attack
      [2] http://wiki.postgresql.org/wiki/Sql_injection
      [3]http://blog.imperva.com/2011/09/sql-injection-by-the-numbers.html
      [4]http://savepoint.blog.br/o-minimo-que-voce-deveria-aprender-para-se-defender-de-ataques-de-injecao-
        de-sql-no-postgresql/

      [5]http://wiki.postgresql.org/wiki/9.1%E7%AC%AC%E4%B8%89%E5%8D%81%E4%B8%80%E7%AB%A0
      [6]https://www.simple-talk.com/sql/learn-sql-server/sql-injection-
       defense-in-depth/
      [7]http://www.postgresql.org/docs/7.2/static/privileges.html
      [8]http://msdn.microsoft.com/en-us/library/ff648339.aspx# paght000002
        _additionalconsiderations
      [9]https://www.simple-talk.com/sql/learn-sql-server/sql-injection-
       defense-in-depth/
      [10]http://www.php.net/manual/en/exception.getmessage.php
      [11]https://www.simple-talk.com/sql/learn-sql-server/sql-injection-defense-in-
        depth/
      [12]http://weblogs.sqlteam.com/jamesw/archive/2011/10/03/a-list-of-sql-best-
15     practices.aspx

Weitere ähnliche Inhalte

Was ist angesagt?

A Brief Introduction in SQL Injection
A Brief Introduction in SQL InjectionA Brief Introduction in SQL Injection
A Brief Introduction in SQL Injection
Sina Manavi
 
Advanced Sql Injection ENG
Advanced Sql Injection ENGAdvanced Sql Injection ENG
Advanced Sql Injection ENG
Dmitry Evteev
 

Was ist angesagt? (20)

SQL Injection
SQL Injection SQL Injection
SQL Injection
 
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya MorimotoSQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
 
Web Security: SQL Injection
Web Security: SQL InjectionWeb Security: SQL Injection
Web Security: SQL Injection
 
SQL Injections - A Powerpoint Presentation
SQL Injections - A Powerpoint PresentationSQL Injections - A Powerpoint Presentation
SQL Injections - A Powerpoint Presentation
 
seminar report on Sql injection
seminar report on Sql injectionseminar report on Sql injection
seminar report on Sql injection
 
Sql injection
Sql injectionSql injection
Sql injection
 
SQL Injection
SQL InjectionSQL Injection
SQL Injection
 
Sql Injection - Vulnerability and Security
Sql Injection - Vulnerability and SecuritySql Injection - Vulnerability and Security
Sql Injection - Vulnerability and Security
 
A Brief Introduction in SQL Injection
A Brief Introduction in SQL InjectionA Brief Introduction in SQL Injection
A Brief Introduction in SQL Injection
 
SQL Injection
SQL InjectionSQL Injection
SQL Injection
 
Advanced SQL Injection: Attacks
Advanced SQL Injection: Attacks Advanced SQL Injection: Attacks
Advanced SQL Injection: Attacks
 
Advanced SQL Injection
Advanced SQL InjectionAdvanced SQL Injection
Advanced SQL Injection
 
SQL Injection Tutorial
SQL Injection TutorialSQL Injection Tutorial
SQL Injection Tutorial
 
Sql injection
Sql injectionSql injection
Sql injection
 
Advanced Sql Injection ENG
Advanced Sql Injection ENGAdvanced Sql Injection ENG
Advanced Sql Injection ENG
 
How to identify and prevent SQL injection
How to identify and prevent SQL injection  How to identify and prevent SQL injection
How to identify and prevent SQL injection
 
D:\Technical\Ppt\Sql Injection
D:\Technical\Ppt\Sql InjectionD:\Technical\Ppt\Sql Injection
D:\Technical\Ppt\Sql Injection
 
What is advanced SQL Injection? Infographic
What is advanced SQL Injection? InfographicWhat is advanced SQL Injection? Infographic
What is advanced SQL Injection? Infographic
 
SQL Injection Defense in Python
SQL Injection Defense in PythonSQL Injection Defense in Python
SQL Injection Defense in Python
 
Sql injection
Sql injectionSql injection
Sql injection
 

Andere mochten auch

Website attack n defacement n its control measures
Website attack n defacement n its control measures Website attack n defacement n its control measures
Website attack n defacement n its control measures
أحلام انصارى
 
Introduction to SQL Injection
Introduction to SQL InjectionIntroduction to SQL Injection
Introduction to SQL Injection
jpubal
 
Protecting Web Services from DDOS Attack
Protecting Web Services from DDOS AttackProtecting Web Services from DDOS Attack
Protecting Web Services from DDOS Attack
Ponraj
 

Andere mochten auch (19)

Entropy and denial of service attacks
Entropy and denial of service attacksEntropy and denial of service attacks
Entropy and denial of service attacks
 
Website attack n defacement n its control measures
Website attack n defacement n its control measures Website attack n defacement n its control measures
Website attack n defacement n its control measures
 
DDOS ATTACKS
DDOS ATTACKSDDOS ATTACKS
DDOS ATTACKS
 
Sql Injection Attacks Siddhesh
Sql Injection Attacks SiddheshSql Injection Attacks Siddhesh
Sql Injection Attacks Siddhesh
 
SQL INJECTION
SQL INJECTIONSQL INJECTION
SQL INJECTION
 
Sql injection
Sql injectionSql injection
Sql injection
 
Sql Injection attacks and prevention
Sql Injection attacks and preventionSql Injection attacks and prevention
Sql Injection attacks and prevention
 
SQLMAP Tool Usage - A Heads Up
SQLMAP Tool Usage - A  Heads UpSQLMAP Tool Usage - A  Heads Up
SQLMAP Tool Usage - A Heads Up
 
Advanced SQL injection to operating system full control (short version)
Advanced SQL injection to operating system full control (short version)Advanced SQL injection to operating system full control (short version)
Advanced SQL injection to operating system full control (short version)
 
Threat modeling librarian freedom conference
Threat modeling   librarian freedom conferenceThreat modeling   librarian freedom conference
Threat modeling librarian freedom conference
 
03. sql and other injection module v17
03. sql and other injection module v1703. sql and other injection module v17
03. sql and other injection module v17
 
SQL injection
SQL injectionSQL injection
SQL injection
 
Introduction to SQL Injection
Introduction to SQL InjectionIntroduction to SQL Injection
Introduction to SQL Injection
 
Sql injection
Sql injectionSql injection
Sql injection
 
Time-Based Blind SQL Injection
Time-Based Blind SQL InjectionTime-Based Blind SQL Injection
Time-Based Blind SQL Injection
 
Protecting Web Services from DDOS Attack
Protecting Web Services from DDOS AttackProtecting Web Services from DDOS Attack
Protecting Web Services from DDOS Attack
 
Prevention of SQL Injection Attacks having XML Database
Prevention of SQL Injection Attacks having XML DatabasePrevention of SQL Injection Attacks having XML Database
Prevention of SQL Injection Attacks having XML Database
 
Devouring Security XML Attack surface and Defences
Devouring Security XML Attack surface and DefencesDevouring Security XML Attack surface and Defences
Devouring Security XML Attack surface and Defences
 
Sql injection with sqlmap
Sql injection with sqlmapSql injection with sqlmap
Sql injection with sqlmap
 

Ähnlich wie SQL Injection Attacks cs586

Ähnlich wie SQL Injection Attacks cs586 (20)

Hardening Database Server
Hardening Database ServerHardening Database Server
Hardening Database Server
 
Sql security
Sql securitySql security
Sql security
 
SQLSecurity.ppt
SQLSecurity.pptSQLSecurity.ppt
SQLSecurity.ppt
 
SQLSecurity.ppt
SQLSecurity.pptSQLSecurity.ppt
SQLSecurity.ppt
 
Database security issues
Database security issuesDatabase security issues
Database security issues
 
Sql injections (Basic bypass authentication)
Sql injections (Basic bypass authentication)Sql injections (Basic bypass authentication)
Sql injections (Basic bypass authentication)
 
Modern Data Security for the Enterprises – SQL Server & Azure SQL Database
Modern Data Security for the Enterprises – SQL Server & Azure SQL DatabaseModern Data Security for the Enterprises – SQL Server & Azure SQL Database
Modern Data Security for the Enterprises – SQL Server & Azure SQL Database
 
Greensql2007
Greensql2007Greensql2007
Greensql2007
 
Code injection and green sql
Code injection and green sqlCode injection and green sql
Code injection and green sql
 
Security For Application Development
Security For Application DevelopmentSecurity For Application Development
Security For Application Development
 
SqlSa94
SqlSa94SqlSa94
SqlSa94
 
Sql server security in an insecure world
Sql server security in an insecure worldSql server security in an insecure world
Sql server security in an insecure world
 
Database Systems Security
Database Systems SecurityDatabase Systems Security
Database Systems Security
 
SQL Injection and Clickjacking Attack in Web security
SQL Injection and Clickjacking Attack in Web securitySQL Injection and Clickjacking Attack in Web security
SQL Injection and Clickjacking Attack in Web security
 
ASP.NET Web Security
ASP.NET Web SecurityASP.NET Web Security
ASP.NET Web Security
 
Secure Software Engineering
Secure Software EngineeringSecure Software Engineering
Secure Software Engineering
 
Web security
Web securityWeb security
Web security
 
Understanding and preventing sql injection attacks
Understanding and preventing sql injection attacksUnderstanding and preventing sql injection attacks
Understanding and preventing sql injection attacks
 
Owasp Top 10 2017
Owasp Top 10 2017Owasp Top 10 2017
Owasp Top 10 2017
 
Securing you SQL Server - Denver, RMTT
Securing you SQL Server - Denver, RMTTSecuring you SQL Server - Denver, RMTT
Securing you SQL Server - Denver, RMTT
 

Kürzlich hochgeladen

Kürzlich hochgeladen (20)

Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
Agentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdfAgentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdf
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT Professionals
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. Startups
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
Enterprise Security Monitoring, And Log Management.
Enterprise Security Monitoring, And Log Management.Enterprise Security Monitoring, And Log Management.
Enterprise Security Monitoring, And Log Management.
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Intelligent Gimbal FINAL PAPER Engineering.pdf
Intelligent Gimbal FINAL PAPER Engineering.pdfIntelligent Gimbal FINAL PAPER Engineering.pdf
Intelligent Gimbal FINAL PAPER Engineering.pdf
 
AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 

SQL Injection Attacks cs586

  • 1. SQL Injection Attacks Tyler Fetters Stacy Watts 3.13.2013 CS586 – Introduction to Databases Portland State University
  • 2. Today‟s Topics  What is a SQL Injection Attack  Security in SQL  How to lock down a dbms  Best Practices  Common Mistakes  SQL Injection Attack Example  Questions 2
  • 3. SQL Injection Attack - Definition  SQL injection consists of the possibility the user has to inject fragments of SQL queries in Web application input fields.  If these fields or the resulting SQL query to be sent to the database are not properly validated, then it might be possible for the attacker to access unauthorized data, reverse engineer the database structure, or even to insert/delete data [1] 3
  • 4. Security in SQL – dbms Lock Down  Keep your PostgreSQL version up-to-date  Network design should include firewalls  Track user Input  Analyze the correctness of SQL statements  Additional security  SQL Randomization  Appending random numbers to all statements, and rejecting any not containing such numbers  Black Box testing your solution prior to release  Third party software options for testing and locking  Examples: SQLMap, V1p3R, Candid 4
  • 6. Security in SQL – Best Practices  Parameterize all Queries  Example From Week 7 – Guest Lecture  Stored Procedures and Permissions  All code can be implemented using stored procedures on the DB  Use the account with the lowest permissions needed for the task  In PostgreSQL there are the following privileges:  SELECT (read), INSERT (append), UPDATE (write), DELETE, RULE, REFERENCES (foreign key), and TRIGGER. 6  Eg. GRANT SELECT ON accounts TO external;
  • 7. Security in SQL – Best Practices  Input Validation Checks  Implement code that ensures correct inputs are given.  Some examples:  A name input should not contain an “=“ with it  A zip code should only contain numbers  Avoid printing error codes directly  Use Try and Catch Mechanisms  Within the Catch Provide meaningful error messages to the user 7
  • 8. Security in SQL – Best Practices  Encrypt Secure Data  Passwords should be encrypted or hashed not stored as text  What about CC info? Or SSN?  Data Segregation  Store secure data in a separate database from non- secure data  Not accessible from outside of the network 8  Example Bank Teller
  • 9. Security in SQL – Best Practices  Keep your database Schema hidden  Avoid using select *….  Use the table and attribute aliases  Avoid obvious nomenclature and schema  i.e. User (first_name, last_name, user_name, password)  Log and Audit you dbms  Verify users and permissions  Require high security passwords and passwords be updated  Remove any non-essential/not approved tables  Helps to find potential threat attempts and prevent future attacks 9
  • 11. Security in SQL – Common Mistakes  Turning off the default security configuration  The idea might be to make input easier for the user by allowing any input  Not a good idea. Know what might happen by turning off a security measure before doing so.  Security through Obscurity  As long as the machine is connected to the internet and responsive, attacks are possible  “In operational environments, it has been noted that applications experience an average of 71 attempts an hour.” [3]  Accessing Tables Directly  If the information is for viewing, use a view, don‟t expose the 11 table
  • 12. Security in SQL – Common Mistakes  Obvious nomenclature and schema  Once access is gained even if the schema is protected it might be possible to guess User (Name, Password) as a relation.  Even without, possible to damage with drop table.  Not checking logs, or performing audits  No assumptions about data integrity  User Permissions pitfalls  Setting user permission tiers too high  Setting global user permissions for ease of administration  The user the application uses to connect to the database should never be the owner of the objects created in the database  Storing sensitive data without encryption  Eg: social security number, current location, credit card information 12
  • 13. SQL Injection Attack Example  Go to the following url and complete the survey  http://sqlinjection.70sites.com/  Now we will Run a SQL injection attack  SQL Injection Attack  $lastn = stripslashes($lastn);  Used to remove built in security of “” on „ or “  Might be done for names like O‟Brian 13
  • 15. References  [1] http://en.wikipedia.org/wiki/SQL_injection_attack  [2] http://wiki.postgresql.org/wiki/Sql_injection  [3]http://blog.imperva.com/2011/09/sql-injection-by-the-numbers.html  [4]http://savepoint.blog.br/o-minimo-que-voce-deveria-aprender-para-se-defender-de-ataques-de-injecao- de-sql-no-postgresql/  [5]http://wiki.postgresql.org/wiki/9.1%E7%AC%AC%E4%B8%89%E5%8D%81%E4%B8%80%E7%AB%A0  [6]https://www.simple-talk.com/sql/learn-sql-server/sql-injection- defense-in-depth/  [7]http://www.postgresql.org/docs/7.2/static/privileges.html  [8]http://msdn.microsoft.com/en-us/library/ff648339.aspx# paght000002 _additionalconsiderations  [9]https://www.simple-talk.com/sql/learn-sql-server/sql-injection- defense-in-depth/  [10]http://www.php.net/manual/en/exception.getmessage.php  [11]https://www.simple-talk.com/sql/learn-sql-server/sql-injection-defense-in- depth/  [12]http://weblogs.sqlteam.com/jamesw/archive/2011/10/03/a-list-of-sql-best- 15 practices.aspx

Hinweis der Redaktion

  1. Tyler
  2. Tyler
  3. Stacy
  4. Stacy
  5. Tyler
  6. https://www.simple-talk.com/sql/learn-sql-server/sql-injection-defense-in-depth/http://www.postgresql.org/docs/7.2/static/privileges.htmlhttp://msdn.microsoft.com/en-us/library/ff648339.aspx#paght000002_additionalconsiderationsTyler
  7. https://www.simple-talk.com/sql/learn-sql-server/sql-injection-defense-in-depth/http://www.php.net/manual/en/exception.getmessage.phpTyler
  8. https://www.simple-talk.com/sql/learn-sql-server/sql-injection-defense-in-depth/Tyler
  9. http://weblogs.sqlteam.com/jamesw/archive/2011/10/03/a-list-of-sql-best-practices.aspxTyler
  10. Stacy
  11. Stacy
  12. Stacy
  13. Last Name = Fake" OR "a" = "a