MySQL Security MySQL User Conference & Expo Tuesday, April 24 th, 2007 Sheeri Kritzer, MySQL DBA

Slides:



Advertisements
Similar presentations
Module XIV SQL Injection
Advertisements

PHP SQL. Connection code:- mysql_connect("server", "username", "password"); Connect to the Database Server with the authorised user and password. Eg $connect.
PHP Hypertext Preprocessor Information Systems 337 Prof. Harry Plantinga.
WebGoat & WebScarab “What is computer security for $1000 Alex?”
How Did I Steal Your Database Mostafa
Group X7 – Year 2010/2011 – First Year Team Project.
9/9/2005 Developing "Secure" Web Applications 1 Methods & Concepts for Developing “Secure” Web Applications Peter Y. Hammond, Developer Wasatch Front Regional.
NAVY Research Group Department of Computer Science Faculty of Electrical Engineering and Computer Science VŠB-TUO 17. listopadu Ostrava-Poruba.
Information Networking Security and Assurance Lab National Chung Cheng University The Ten Most Critical Web Application Security Vulnerabilities Ryan J.W.
Sara SartoliAkbar Siami Namin NSF-SFS workshop July 14-18, 2014.
Security in SQL Jon Holmes CIS 407 Fall Outline Surface Area Connection Strings Authenticating Permissions Data Storage Injections.
Jonas Thomsen, Ph.d. student Computer Science University of Aarhus Best Practices and Techniques for Building Secure Microsoft.
Web Application Vulnerabilities Checklist. EC-Council Parameter Checklist  URL request  URL encoding  Query string  Header  Cookie  Form field 
Sql Server Advanced Features MIS 424 Professor Sandvig.
1 IS 2150 / TEL 2810 Introduction to Security James Joshi Associate Professor, SIS Lecture 12.1 Nov 20, 2012 SQL Injection Cross-Site Scripting.
Preventing SQL Injection ~example of SQL injection $user = $_POST[‘user’]; $pass = $_POST[‘pass’]; $query = DELETE FROM Users WHERE user = ‘$user’ AND.
Check That Input Preventing SQL Injection Attacks By Andrew Morton For CS 410.
The OWASP Foundation Injection Flaws.
By Daniel Siassi.  XHTML  For Structure  CSS  For Stylization of Structure  SQL Database  Store Customer, Calendar, and Order Data  PHP  Server-side.
Introduction to SQL Server 2000 Security Dave Watts CTO, Fig Leaf Software
CSCI 6962: Server-side Design and Programming Secure Web Programming.
Lecture 14 – Web Security SFDV3011 – Advanced Web Development 1.
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.
November 13, 2008 Ohio Information Security Forum Attack Surface of Web Applications James Walden Northern Kentucky University
© 2003 By Default! A Free sample background from Slide 1 Week 2  Free PHP Hosting Setup  PHP Backend  Backend Security 
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
Attacking Applications: SQL Injection & Buffer Overflows.
ITN Wake Tech1 ITN270 Advanced Internet Databases Lecture 15. General MySQL Administration Topics: –Securing a New MySQL Installation –MySQL Server.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
MySQL Databases & PHP Integration Using PHP to write data to, and retrieve data from, a MySQL database.
Web Application Security ECE ECE Internetwork Security What is a Web Application? An application generally comprised of a collection of scripts.
1 IT420: Database Management and Organization Database Security 5 April 2006 Adina Crăiniceanu
Effective Security in ASP.Net Applications Jatin Sharma: Summer 2005.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
Accessing Your MySQL Database from the Web with PHP (Ch 11) 1.
October 3, 2008IMI Security Symposium Application Security through a Hacker’s Eyes James Walden Northern Kentucky University
MySQL Proxy Boston MySQL User Group Monday, September 24th, 2007 Sheeri Kritzer, MySQL DBA Technocation, Inc.
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
GOAL User Interactive Web Interface Update Pages by Club Officers Two Level of Authentication.
Get Rid of Cron Scripts Using Events Sheeri Cabral Senior DB Admin/Architect,
Web Security Lesson Summary ●Overview of Web and security vulnerabilities ●Cross Site Scripting ●Cross Site Request Forgery ●SQL Injection.
MySQL. Is a SQL (Structured Query Language) database server. Can be accessed using PHP with embedded SQL Queries Supports Large DB’s, 60,000 tables with.
Database Security Cmpe 226 Fall 2015 By Akanksha Jain Jerry Mengyuan Zheng.
SQL Injection Anthony Brown March 4, 2008 IntroductionQuestionsBackgroundTechniquesPreventionDemoConclusions.
PHP Security Ryan Dunn Jason Pack. Outline PHP Overview PHP Overview Common Security Issues Common Security Issues Advanced Security Issues Advanced Security.
INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014.
Example – SQL Injection MySQL & PHP code: // The next instruction prompts the user is to supply an ID $personID = getIDstringFromUser(); $sqlQuery = "SELECT.
DATABASES.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
LOGIN FORMS.
SQL Injection Attacks S Vinay Kumar, 07012D0506. Outline SQL Injection ? Classification of Attacks Attack Techniques Prevention Techniques Conclusion.
CS320 Web and Internet Programming Database Access with JDBC Chengyu Sun California State University, Los Angeles.
MySQL Security: More Than Just ACL's Sheeri Cabral Senior DB Admin/Architect,
Security Around MySQL Presented by: Danil Zburivsky/Singer Wang.
Securing MySQL Presented by: Sheeri K. Cabral
Fundamental of Databases
Web Application Vulnerabilities, Detection Mechanisms, and Defenses
Introduction to Dynamic Web Programming
Outsourcing Database Administration
CS320 Web and Internet Programming Database Access with JDBC
DBA and IT Professional for ~9 years. Currently I am a Data Architect
Unix System Administration
Introduction to SQL Server 2000 Security
PHP: Security issues FdSc Module 109 Server side scripting and
Super Market Management
Chapter 13 Security Methods Part 3.
Lecture 2 - SQL Injection
DBA for ~4+years, IT Professional for 7.5 years.
Web Programming Language
Presentation transcript:

MySQL Security MySQL User Conference & Expo Tuesday, April 24 th, 2007 Sheeri Kritzer, MySQL DBA

Overview ➲ ACLs ➲ Test dbs & anonymous accounts ➲ OS files and permissions

Overview ➲ Application data flow ➲ SQL Injection ➲ XSS

ACLs - Who Has Access? ➲ SELECT user,host,password FROM mysql.user; ➲ SUPER ➲ Anonymous

ACLs – From where? ➲ % ➲ %.company.com ➲ % or 10.0.%

ACLs – From where? ➲ localhost, --skip-networking ➲ firewall ➲ DOS

ACLs – To Do What? ➲ --local-infile=0 ➲ --skip-symbolic-links ➲ GRANT ● MAX_QUERIES_PER_HOUR ● MAX_UPDATES_PER_HOUR ● MAX_CONNECTIONS_PER_HOUR

Server Options ➲ --bind-address ➲ --skip-name-resolve ➲ --skip-show-database

Changing ACLs ➲ How are ACL changes audited? ➲ When do ACL changes happen?

Audit Example - PHP ➲ Create a table for information: CREATE TABLE `action` ( `user` varchar(77) NOT NULL default '', `asuser` varchar(77) NOT NULL default '', `db` varchar(64) NOT NULL default '', `query` mediumtext NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='77= ';

Audit Example - PHP ➲ Create the function: function my_mysql_query ($query, $dblink) { $action="INSERT INTO action (user,asuser, db,query) VALUES (CURRENT_USER(), USER(), DATABASE(), $query)"; mysql_query($action, $dblink); mysql_query($query, $dblink); }

Audit Example - PHP ➲ Use the function: $result = my_mysql_query($query,$dblink); INSERT INTO action (user, asuser, db, query) VALUES (CURRENT_USER(), USER(), DATABASE(), 'select foo from bar');

Test Databases ➲ Why get rid of them? ➲ Copying tables ➲ Stuff with data

OS Files and Permissions ➲ mysql server user ➲ mysql server files & logs ➲ Passwords on commandline ➲ Office policies/runbook

OS Files and Permissions ➲ Backups ➲ /etc/my.cnf, my.ini,.my.cnf ➲ CLI, GUI tools ➲ Personal history files

How Does Your Data Flow? ➲ Where is user data encrypted? ➲ Where do errors go? ➲ Where does the traffic flow?

Administrative Applications ➲ Same data, different interface ➲ Reporting ➲ VPN ➲ “It's public” vs. “It's easily accessible”

Plaintext Passwords Are Bad! ➲ Storage of customer login ➲ Compromised DB ➲ Transmission of passwords/hashes ➲ Users may use elsewhere

Plaintext Passwords Are Bad! ➲ Where are you encrypting? ➲ Where are you checking?

Validate User Input ➲ ; \g \G ' “ UNION ➲ HTML encoding ➲ NULL / char(0) ➲ VARCHAR and ' '

Validate User Input ➲ Save yourself time ➲ Buffer overflows ➲ CHARSET

Trusting GET or POST ➲ Only from certain pages ➲ Even with valid session ids, cookies ➲ register_globals=off in PHP Test your site! acetunix....

Use Prepared Statements ➲ MySQL ● PREPARE stmt1 FROM 'SELECT uname FROM UserAuth WHERE uname=? and pass=?'; ● = "alef"; = md5("alef"); ● EXECUTE

Use Prepared Statements ➲ MySQL ● PREPARE stmt1 FROM 'SELECT uname FROM UserAuth WHERE uname=? and pass=?'; ● = "alef"; = md5("alef"); ● EXECUTE ● = "alef"; ● = "alef' or 'x'='x"; ● EXECUTE ● DEALLOCATE PREPARE stmt1;

Use Prepared Statements ➲ Prepared statement speed ➲ Stored procedures

Prepared Statements - Code ➲ Perl ● $query = $sql->prepare("SELECT uname FROM UserAuth WHERE uname = ? AND pass = ?"); ● $query->execute($uname, $pass); ➲ PHP ● $stmt = $mysqli->prepare("SELECT uname FROM UserAuth WHERE uname = ? AND pass = ?"); ● $stmt->bind_param($uname, $pass); ● $stmt->execute();

Prepared Statements - Code ➲ Java ● PreparedStatement pstmt = con.prepareStatement("SELECT uname FROM UserAuth WHERE uname = ? AND pass = ?"); ● pstmt.setString(uname, pass); ● ResultSet rset = pstmt.executeQuery();

Prepared Statements - Code ➲.NET/C# ● using(SqlCommand cmd = new SqlCommand("SELECT uname FROM UserAuth WHERE uname AND pass { ● userName); ● pass); ● using( SqlDataReader rdr = cmd.ExecuteReader() ){ ●...} ● }

Encryption ➲ SSL is per-client ➲ Unencrypted MySQL data streams shell> tcpdump -l -i eth0 -w -src or dst port 3306 | strings

Feedback? ➲ Other ideas....