+ Housekeeping Project/assignment 6/quiz 6 questions? Quiz 6: Query optimization, database security At 9:10, you’ll have 15 minutes to do on- line student.

Slides:



Advertisements
Similar presentations
MySQL Access Privilege System
Advertisements

Chapter 23 Database Security and Authorization Copyright © 2004 Pearson Education, Inc.
Understand Database Security Concepts
Database Management System
Introduction The concept of “SQL Injection”
SQL Injection Attacks Prof. Jim Whitehead CMPS 183: Spring 2006 May 17, 2006.
System Administration Accounts privileges, users and roles
Chapter 8 Security Transparencies © Pearson Education Limited 1995, 2005.
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
SQL Injection Attacks CS 183 : Hypermedia and the Web UC Santa Cruz.
EC500 Lecture Made By: Jiaxi Jin, Rashmi Shah, Ludovico Fontana Boston University.
Chapter 6: Hostile Code Guide to Computer Network Security.
Check That Input Preventing SQL Injection Attacks By Andrew Morton For CS 410.
PHP Security.
MIS Week 11 Site:
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Chapter 5 Introduction to SQL. Structured Query Language = the “programming language” for relational databases SQL is a nonprocedural language = the user.
Chapter 6: Integrity and Security Thomas Nikl 19 October, 2004 CS157B.
Database Security and Auditing: Protecting Data Integrity and Accessibility Chapter 3 Administration of Users.
Lets Make our Web Applications Secure. Dipankar Sinha Project Manager Infrastructure and Hosting.
1 Group Account Administration Introduction to Groups Planning a Group Strategy Creating Groups Understanding Default Groups Groups for Administrators.
(CPSC620) Sanjay Tibile Vinay Deore. Agenda  Database and SQL  What is SQL Injection?  Types  Example of attack  Prevention  References.
Lecture 14 – Web Security SFDV3011 – Advanced Web Development 1.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
Web Application Access to Databases. Logistics Test 2: May 1 st (24 hours) Extra office hours: Friday 2:30 – 4:00 pm Tuesday May 5 th – you can review.
Today’s Objectives Chapters 10 and 11 Security in SQL Server –Manage server logins and database users. –Manage server-level, database-level, and application.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
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.
Attacking Applications: SQL Injection & Buffer Overflows.
SEC835 Practical aspects of security implementation Part 1.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
(Chapter 10 continued) Our examples feature MySQL as the database engine. It's open source and free. It's fully featured. And it's platform independent.
Copyright © 2013 Curt Hill Database Security An Overview with some SQL.
 Chapter 14 – Security Engineering 1 Chapter 12 Dependability and Security Specification 1.
Triggers and Stored Procedures in DB 1. Objectives Learn what triggers and stored procedures are Learn the benefits of using them Learn how DB2 implements.
Attacking Data Stores Brad Stancel CSCE 813 Presentation 11/12/2012.
CpSc 462/662: Database Management Systems (DBMS) (TEXNH Approach) Stored Procedure James Wang.
Chapter No 4 Query optimization and Data Integrity & Security.
IMS 4212: Database Security 1 Dr. Lawrence West, Management Dept., University of Central Florida Data & Database Administration Security.
SQL – Injections Intro. Prajen Bhadel College of Information Technology & Engeneering Kathmandu tinkune Sixth semister.
Get Rid of Cron Scripts Using Events Sheeri Cabral Senior DB Admin/Architect,
Database Security Lesson Introduction ●Understand the importance of securing data stored in databases ●Learn how the structured nature of data in databases.
Database Security Cmpe 226 Fall 2015 By Akanksha Jain Jerry Mengyuan Zheng.
Form Handling IDIA 618 Fall 2014 Bridget M. Blodgett.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
JDBC CS 260 Database Systems. Overview  Introduction  JDBC driver types  Eclipse project setup  Programming with JDBC  Prepared statements  SQL.
Agenda for Class 2/20/2014 Introduce Microsoft’s SQL Server database management system. Use the lab to discuss how to CREATE, DROP and populate (INSERT)
Secure Authentication. SQL Injection Many web developers are unaware of how SQL queries can be tampered with SQL queries are able to circumvent access.
Oracle 11g: SQL Chapter 7 User Creation and Management.
SQL Injection Attacks An overview by Sameer Siddiqui.
SQL Triggers, Functions & Stored Procedures Programming Operations.
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.
Chapter 7 SQL Injection I: Identification
M M Waseem Iqbal.  Cause: Unverified/unsanitized user input  Effect: the application runs unintended SQL code.  Attack is particularly effective if.
Cosc 5/4765 Database security. Database Databases have moved from internal use only to externally accessible. –Organizations store vast quantities of.
Defense In Depth: Minimizing the Risk of SQL Injection
SQL Injection Attacks.
Database and Cloud Security
Database System Implementation CSE 507
Securing Network Servers
Chapter 5 Introduction to SQL.
Pengantar Keamanan Informasi
Intro to Ethical Hacking
Chapter 8 Working with Databases and MySQL
PHP: Security issues FdSc Module 109 Server side scripting and
Chapter 13 Security Methods Part 3.
Lecture 2 - SQL Injection
Intro to Ethical Hacking
6. Application Software Security
Presentation transcript:

+ Housekeeping Project/assignment 6/quiz 6 questions? Quiz 6: Query optimization, database security At 9:10, you’ll have 15 minutes to do on- line student ratings Office hours today: 10:30-12:30 Offce hours next week: M/W/F 10:30-12:30

+ Security: Access Control, SQL Injection Attacks Based upon slides from: classes.soe.ucsc.edu/.../SQL%20Injection%20Attacks.ppt homes.cs.washington.edu/~suciu/current-trends.ppt

+ Data Security Protection from malicious attempts to steal (view) or modify data. The science and study of methods of protecting data (...) from unauthorized disclosure and modification Data Security = Confidentiality + Integrity

+ 4 Traditional Data Security Security in statistical databases = Theory In a statistical database, it is often desired to allow query access only to aggregate data, not individual records. Securing such a database is a difficult problem, since intelligent users can use a combination of aggregate queries to derive information about a single individual. Security in SQL = Access control + Views

+ 5 Access Control in SQL GRANT privileges ON object TO users [WITH GRANT OPTIONS] privileges = SELECT | INSERT | DELETE |... object = table | attribute REVOKE privileges ON object FROM users [CASCADE ] [Griffith&Wade'76, Fagin'78]

+ Access Control in MySQL The primary function of the MySQL privilege system is to authenticate a user who connects from a given host and to associate that user with privileges on a database such as SELECT, INSERT, UPDATE, and DELETE There are some things that you cannot do with the MySQL privilege system: You cannot explicitly specify that a given user should be denied access. That is, you cannot explicitly match a user and then refuse the connection. You cannot specify that a user has privileges to create or drop tables in a database but not to create or drop the database itself. A password applies globally to an account. You cannot associate a password with a specific object such as a database, table, or routine.

+ 7 Views in SQL A SQL View = (almost) any SQL query Typically used as: GRANT SELECT ON pmpStudents TO DavidRispoli CREATE VIEW pmpStudents AS SELECT * FROM Students WHERE…

+ Views in MySQL CREATE [OR REPLACE] [ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}] [DEFINER = { user | CURRENT_USER }] [SQL SECURITY { DEFINER | INVOKER }] VIEW view_name [(column_list)] AS select_statement [WITH [CASCADED | LOCAL] CHECK OPTION] The DEFINER and SQL SECURITY clauses determine which MySQL account to use when checking access privileges for the view when a statement is executed that references the view.

+ 9 Summary of SQL Security Limitations: Often no row level access control Note: DB specific – fine-grained access control is an active area of improvement Table creator owns the data (not always fair) … or spectacular failure: Only ~30% assign privileges to users/roles And then to protect entire tables, not columns Access control = great success story of the DB community...

+ MySQL security Many aspects: General factors that affect security. These include choosing good passwords, not granting unnecessary privileges to users, ensuring application security by preventing SQL injections and data corruption, and others. See Section 6.1, “General Security Issues”. Security of the installation itself. The data files, log files, and the all the application files of your installation should be protected to ensure that they are not readable or writable by unauthorized parties. For more information, see Section 2.18, “Postinstallation Setup and Testing”.

+ MySQL security Access control and security within the database system itself, including the users and databases granted with access to the databases, views and stored programs in use within the database. For more information, see Section 6.2, “The MySQL Access Privilege System”, and Section 6.3, “MySQL User Account Management”. Network security of MySQL and your system. The security is related to the grants for individual users, but you may also wish to restrict MySQL so that it is available only locally on the MySQL server host, or to a limited set of other hosts. Ensure that you have adequate and appropriate backups of your database files, configuration and log files. Also be sure that you have a recovery solution in place and test that you are able to successfully recover the information from your backups. See Chapter 7, Backup and Recovery.

+ SQL Injection Attacks

+ _in_the_wild/

+ What is a SQL Injection Attack? Many web applications take user input from a form Often this user input is used literally in the construction of a SQL query submitted to a database. For example: SELECT productdata FROM table WHERE productname = ‘ user input product name ’ ; A SQL injection attack involves placing SQL statements in the user input

+ SQL Injection Attacks on the rise “Many, many sites have lost customer data in this way,” said Chris Hinkley, Senior Security Engineer at FireHost. “SQL Injection attacks are often automated and many website owners may be blissfully unaware that their data could actively be at risk. These attacks can be detected and businesses should be taking basic and blanket steps to block attempted SQL Injection, as well as the other types of attacks we frequently see.”

News of SQL attacks still-a-problem/ still-a-problem/ An SQL injection vulnerability resulted in an urgent June bugfix release of Ruby on Rails 3.x. Yahoo! Voices was hacked in July. The attack acquired 453,000 user addresses and passwords. The perpetrators claimed to have used union-based SQL injection to break in. LinkedIn.com leaked 6.5 million user credentials in June. A class action lawsuit alleges that the attack was accomplished with SQL injection. SQL injection was documented as a security threat in 1998, but new incidents still occur every month. Making honest mistakes, developers fail to defend against this means of attack, and the security of online data is at risk for all of us because of it.

+ Some good sites to learn more Prevention guide (with sample code in many languages): Tutorials: (webinar) fallacies (webinar) fallacies Cool site that let’s you try out attacks on a sample DB and explains why they work Research paper on how to retrofit existing websites to combat SQL injection attacks

+ An Example SQL Injection Attack Product Search: This input is put directly into the SQL statement within the Web application: $query = “ SELECT prodinfo FROM prodtable WHERE prodname = ‘”. $_POST[ ‘ prod_search ’ ]. “’” ; Creates the following SQL: SELECT prodinfo FROM prodtable WHERE prodname = ‘ blah ‘ OR ‘ x ’ = ‘ x ’ Attacker has now successfully caused the entire database to be returned. blah‘ OR ‘x’ = ‘x

+ A More Malicious Example What if the attacker had instead entered: blah ‘ ; DROP TABLE prodinfo; -- Results in the following SQL: SELECT prodinfo FROM prodtable WHERE prodname = ‘ blah ’ ; DROP TABLE prodinfo; -- ’ Note how comment (--) consumes the final quote Causes the entire database to be deleted Depends on knowledge of table name This is sometimes exposed to the user in debug code called during a database error Use non-obvious table names, and never expose them to user Usually data destruction is not your worst fear, as there is low economic motivation

+ Other injection possibilities Using SQL injections, attackers can: Add new data to the database Could be embarrassing to find yourself selling politically incorrect items on an eCommerce site Perform an INSERT in the injected SQL Modify data currently in the database Could be very costly to have an expensive item suddenly be deeply ‘ discounted ’ Perform an UPDATE in the injected SQL Often can gain access to other user ’ s system capabilities by obtaining their password

+ Best defence If possible, use bound variables with prepared statements Many libraries allow you to bind inputs to variables inside a SQL statement PERL example (from injection.html) $sth = $dbh->prepare("SELECT , userid FROM members WHERE = ?;"); $sth->execute($ ); See for example code in many languages

+ How does this prevent an attack? The SQL statement you pass to prepare is parsed and compiled by the database server. By specifying parameters (either a ? or a named parameter like :name) you tell the database engine what to filter on. Then when you call execute the prepared statement is combined with the parameter values you specify. It works because the parameter values are combined with the compiled statement, not a SQL string. SQL injection works by tricking the script into including malicious strings when it creates SQL to send to the database. So by sending the actual SQL separately from the parameters you limit the risk of ending up with something you didn't intend.

+ Other Defenses Use provided functions for escaping strings Many attacks can be thwarted by simply using the SQL string escaping mechanism ‘  \ ’ and “  \ ” mysql_real_escape_string() is the preferred function for this Will not guard against all attacks Consider: SELECT fields FROM table WHERE id = 23 OR 1=1 No quotes here!

+ More Defenses Check syntax of input for validity Many classes of input have fixed languages addresses, dates, part numbers, etc. Verify that the input is a valid string in the language Some languages allow problematic characters (e.g., ‘ * ’ in ); may decide to not allow these Exclude quotes and semicolons Not always possible: consider the name Bill O ’ Reilly Want to allow the use of single quotes in names Have length limits on input Many SQL injection attacks depend on entering long strings

+ Even More Defenses Scan query string for undesirable word combinations that indicate SQL statements INSERT, DROP, etc. If you see these, can check against SQL syntax to see if they represent a statement or valid user input Limit database permissions and segregate users If you ’ re only reading the database, connect to database as a user that only has read permissions Never connect as a database administrator in your web application

+ And Yet More Defenses Configure database error reporting Default error reporting often gives away information that is valuable for attackers (table name, field name, etc.) Configure so that this information is never exposed to a user