Attacking Data Stores Brad Stancel CSCE 813 Presentation 11/12/2012.

Slides:



Advertisements
Similar presentations
Module XIV SQL Injection
Advertisements

SQL Injection Stephen Frein Comcast.
Creating Stronger, Safer, Web Facing Code JPL IT Security Mary Rivera June 17, 2011.
Understand Database Security Concepts
How Did I Steal Your Database Mostafa
Introduction The concept of “SQL Injection”
NAVY Research Group Department of Computer Science Faculty of Electrical Engineering and Computer Science VŠB-TUO 17. listopadu Ostrava-Poruba.
SQL Injection Attacks Prof. Jim Whitehead CMPS 183: Spring 2006 May 17, 2006.
Introduction to Structured Query Language (SQL)
Input Validation For Free Text Fields Project Members: Hagar Offer &Ran Mor Academic Advisor: Dr Gera Weiss Technical Advisors: Raffi Lipkin & Nadav Attias.
SQL Injection and Buffer overflow
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
Introduction to Structured Query Language (SQL)
Sara SartoliAkbar Siami Namin NSF-SFS workshop July 14-18, 2014.
SQL Injection Attacks CS 183 : Hypermedia and the Web UC Santa Cruz.
Check That Input Preventing SQL Injection Attacks By Andrew Morton For CS 410.
MIS Week 11 Site:
CSCI 6962: Server-side Design and Programming JDBC Database Programming.
Analysis of SQL injection prevention using a proxy server By: David Rowe Supervisor: Barry Irwin.
SQL INJECTION COUNTERMEASURES &
Hamdi Yesilyurt, MA Student in MSDF & PhD-Public Affaris SQL Riji Jacob MS Student in Computer Science.
(CPSC620) Sanjay Tibile Vinay Deore. Agenda  Database and SQL  What is SQL Injection?  Types  Example of attack  Prevention  References.
Preventing SQL Injection Attacks in Stored Procedures Alex Hertz Chris Daiello CAP6135Dr. Cliff Zou University of Central Florida March 19, 2009.
Lecture slides prepared for “Computer Security: Principles and Practice”, 3/e, by William Stallings and Lawrie Brown, Chapter 5 “Database and Cloud Security”.
Lecture 16 Page 1 CS 236 Online SQL Injection Attacks Many web servers have backing databases –Much of their information stored in a database Web pages.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
Attacking Applications: SQL Injection & Buffer Overflows.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
Copyright © 2013 Curt Hill Database Security An Overview with some SQL.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Analysis of SQL injection prevention using a filtering proxy server By: David Rowe Supervisor: Barry Irwin.
Injection CSC 482/582: Computer SecuritySlide #1.
SQL Injection Jason Dunn. SQL Overview Structured Query Language For use with Databases Purpose is to retrieve information Main Statements Select Insert.
Security Attacks CS 795. Buffer Overflow Problem Buffer overflows can be triggered by inputs that are designed to execute code, or alter the way the program.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
SQL INJECTIONS Presented By: Eloy Viteri. What is SQL Injection An SQL injection attack is executed when a web page allows users to enter text into a.
Sumanth M Ganesh B CPSC 620.  SQL Injection attacks allow a malicious individual to execute arbitrary SQL code on your server  The attack could involve.
Aniket Joshi Justin Thomas. Agenda Introduction to SQL Injection SQL Injection Attack SQL Injection Prevention Summary.
SQL Basic. What is SQL? SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate with a database.
SQL – Injections Intro. Prajen Bhadel College of Information Technology & Engeneering Kathmandu tinkune Sixth semister.
WEB SECURITY WEEK 2 Computer Security Group University of Texas at Dallas.
Database Security Cmpe 226 Fall 2015 By Akanksha Jain Jerry Mengyuan Zheng.
JDBC CS 260 Database Systems. Overview  Introduction  JDBC driver types  Eclipse project setup  Programming with JDBC  Prepared statements  SQL.
SQL Injection Anthony Brown March 4, 2008 IntroductionQuestionsBackgroundTechniquesPreventionDemoConclusions.
Secure Authentication. SQL Injection Many web developers are unaware of how SQL queries can be tampered with SQL queries are able to circumvent access.
Databases Kevin Wright Ben Bruckner Group 40. Outline Background Vulnerabilities Log File Cleaning This Lab.
SQL Injection Attacks An overview by Sameer Siddiqui.
Error-based SQL Injection
LM 5 Introduction to SQL MISM 4135 Instructor: Dr. Lei Li.
ADVANCED SQL.  The SQL ORDER BY Keyword  The ORDER BY keyword is used to sort the result-set by one or more columns.  The ORDER BY keyword sorts the.
SQL Injection By: Ayman Mohamed Abdel Rahim Ali Ehab Mohamed Hassan Ibrahim Bahaa Eldin Mohamed Abdel Sabour Tamer Mohamed Kamal Eldin Jihad Ahmad Adel.
SQL INJECTION Lecturer: A.Prof.Dr. DANG TRAN KHANH Student :Le Nguyen Truong Giang.
SQL Injection Attacks S Vinay Kumar, 07012D0506. Outline SQL Injection ? Classification of Attacks Attack Techniques Prevention Techniques Conclusion.
Agenda for Today  DATABASE Definition What is DBMS? Types Of Database Most Popular Primary Database  SQL Definition What is SQL Server? Versions Of SQL.
SQL INJECTION Diwakar Kumar Dinkar M.Tech, CS&E Roll Diwakar Kumar Dinkar M.Tech, CS&E Roll
Chapter 12 Introducing Databases. Objectives What a database is and which databases are typically used with ASP.NET pages What SQL is, how it looks, and.
SQL Injection Attacks.
Database and Cloud Security
ASP.NET Programming with C# and SQL Server First Edition
SQL Injection.
Group 18: Chris Hood Brett Poche
CSC 482/582: Computer Security
Chapter 7: Identifying Advanced Attacks
SQL Injection.
SQL INJECTION ATTACKS.
SQL Injection Attacks Many web servers have backing databases
Intro to Ethical Hacking
Lecture 2 - SQL Injection
Intro to Ethical Hacking
SQL Injection Attack.
Presentation transcript:

Attacking Data Stores Brad Stancel CSCE 813 Presentation 11/12/2012

Sources Consulted Stuttard, D. and Pinto, M., The Web Application Hacker's Handbook: Finding and Exploiting Security Flaws 2nd Edition, 2011, Wiley Publishing

Importance of Data Stores Almost every web app uses data stores Used to hold information vital to the application Often hold information crucial to the application logic (access control, etc.)

Important Notes about Data Stores Application interacts with the data store at a specified security level Common data stores are databases that use SQL (Structure Query Language) to interact & manipulate database Other non-SQL type databases are becoming more popular (i.e. NoSQL) Some data stores specifically revolve around access control (i.e. LDAP)

Interpreted vs. Compiled Languages Injection Attacks can happen on either type of language Interpreted languages make it easier for injection attacks (i.e. can type in code) Compiled language injection attacks generally use machine code

SQL Injection Type of code injection common in interpreted languages that use SQL data stores A lot of similarities across databases but each vendor database may be a bit different Our focus today is on: MS-SQL, Oracle and MySQL data stores

Fingerprinting the Database Extract version string o MySQL /*!32302 and 1=0*/ Look at Concatenation of Strings o Oracle'serv'||'ices' o MS-SQL 'serv'+'ices' o MySQL 'serv' 'ices' Look at how Numeric Data is handled o Oracle BITAND(1,1)-BITAND(1,1) o MS-SQL o MySQL CONNECTION_ID()-CONNECTION_ID()

Testing for Injection Bugs General Algorithm: Supply unexpected data and syntax Identify any anomalies Observe and examine any error messages Systematically modify input to confirm or disprove vulnerability existence Construct proof-of-concept that causes safe command to execute in a verifiable way to prove flaw exists Exploit the vulnerability by leveraging functionality and knowledge of target language and/or its components

Testing for SQL Injection Bugs Three Main Methods: Injecting into String Data Injecting into Numeric Data Injecting into Query Structure

Injecting Into String Data String data is encapsulated into single quotation marks Need to break out of these quotation marks o ex. Wiley' OR 'a'='a Preliminary Steps to Test: o Submit a single quotation mark to see if error occurs o Submit two quotation marks (escape sequence) and look for error or odd behavior o Try SQL concatenation techniques discussed earlier and if no behavior detected possible vulnerable

Injecting Into Numeric Data Query may use numbers as strings so try string data methods first Remember to encode certain characters Steps to Test: o Supply a mathematical expression equiv. to number (responds same way = possible vulnerable) o Use more complicated expressions that use SQL keywords. o Using ASCII commands to test are useful  67-ASCII('A')  51-ASCII(1)

Injecting Into Query Structure Determine the Type of Statement o SELECT Statements o INSERT Statements o UPDATE Statements o DELETE Statements o UNION Operator (more of a technique)

SELECT Statements Frequently used when returning data based on user's actions Attack entry point is usually the statement's WHERE clause Correct Example: o SELECT author,title,year FROM books WHERE publisher = 'Wiley' Malicious Example: o Input into web form: Wiley' OR 1=1-- o SELECT author,title,year FROM books WHERE publisher = 'Wiley' OR 1=1--

INSERT Statements Used to create a new row of data in a table Example: Web app that allows users to self register Correct Example: o INSERT INTO users (username, password, privs) VALUES ('daf','secret',1) Malicious Example: o Input into web form: foo','bar',0)-- o INSERT INTO users (username, password, privs) VALUES ('foo','bar',0)-- o MUST contain correct number of data types!

UPDATE Statements Used to modify one or more rows of existing data in a table Correct Example: o UPDATE users SET password='newsecret' WHERE user='brad' and password='secret' Malicious Example: o Input into web form: admin'-- o UPDATE users SET password='newsecret' WHERE user='admin'-- This example bypasses the password check & changes the admin password!

DELETE Statements Used to delete one or more rows of data in a table Can corrupt the entire table or database Correct Example: o DELETE from users WHERE uid='brad' Malicious Example: o Input into web form: ' OR ' '=' o DELETE from users WHERE uid=' ' OR ' '=' ' This example deletes all user ID's in the users table!

UNION Operator Used to combine results of two or more SELECT statements into a single result set Supported by all major DBMS products Fastest way to retrieve arbitrary information when query results are returned Point of attack is usually the WHERE clause of a SELECT statement Additional SELECT statement must contain correct number of data types

UNION Operator cont. Example SELECT statement before: o SELECT author,title,year FROM books WHERE publisher ='Wiley' (Where Wiley was submitted) Input put into web form: o Wiley' UNION SELECT username,password,uid FROM users-- Returns a dataset containing both the authors,titles,year and username,password,uid in one table This example only works if users table has three columns

Advanced Techniques Out-of-Band Communication Bypassing Filters Using Comments & Circumventing Validation Second Order SQL Injection Retrieving Data as Numbers Inference

Escalating Attacks Most applications employ one account for database access Rely on application-layer controls to enforce segregation of access Already have the data, why escalate? o Gain access to other hosted application data o Compromise the OS of the database server o Gain network access to access other systems o Establish network connection to own system for faster data retrieval o Include own functions to enhance DB capabilities

Some Tools Used in SQL Exploitation Absinthe - Automated Blind SQL Injection Tool SQLMap - Automatic SQL Injection Tool

Preventing SQL Injection Validate input! Escape certain characters and words Use Stored Procedures to help o This does not completely solve the problem Parameterized Queries o AKA: prepared statements o Application specifies query's structure o Application specifies contents of each placeholder

Summary, Comments and Questions Attacking Data Stores can be done in a variety of ways Protecting Data Stores is of utmost importance Understanding how these attacks take place enables one to better protect against them Questions and Comments