web attacks - sql injections Flashcards
(58 cards)
what is sql
standard language for interacting with databases, very common with web applications
what is it used for in web applications
authentications : DB users and passwords
common password: data storage
how is it used in desktops and server apps
Email clients/servers
Photo applications, media servers
Custom database clients
Application data caches
what is network injections
usually considered the bigger risk
can be accessed by unknown users
network is a gateway crossing physical boundaries
risk in priviledged servers
what is local injections
local users can only deny access to themselves
desktop apps run as plain users , putting own data at risks
however:
drive by exloits attack locally growing concerns due to insider threats
Typical Setting for Attacks
1) presentation tier
2)logic tier
3) storage
what happens in the presentation tier
get victim
renders the html that is given from the logic tier
what happens in the logic tier
load compile and execute index.asp
sends html from the storage after the data is return from the storage
what happens in the storage tier
exeutes sql and returns data
what does this code accomplish?
$username = $HTTP_POST_VARS [ ’username ’ ];
$password = $HTTP_POST_VARS [ ’ passwd ’ ];
$query = “ SELECT * FROM logintable WHERE user = ’”
. $username . “ ’ AND pass = ’” . $password . “ ’ “;
…
$result = mysql_query ( $query ) ;
if (! $results )
die_bad_login () ;
this guarantees login!
write sql code that guarntees login
▶ User name: bob’ OR user<>’bob’
▶ Password: foo OR pass<>’foo’
SELECT * FROM logintable WHERE user = ’ bob ’ or user < > ’ bob ’ AND pass = ’ foo ’ OR pass < > ’ foo ’
what is an in - band fix
filtering
what does in-band fix :filtering do?
use filtering to escape black listed characters
php and mysql have functions to help do this
what is an out-band fix
Prepared statements
what does out-band fix:Prepared statements do?
uses a prepared query with parameters
parameters are safe substitued in sql statements
what is an alterative fix from filtering and prepared statements
ORM and LINQ
what is ORM used for?
Use Object-Relational Mapping (ORM) for structured DB access
what does orm stand for
Object-Relational Mapping
what is LINQ used for
Use LINQ in .NET to interact with databases safely
what is a more general out of band solution besides from prepared statements
A more general ”out-of-band” solution is to use embedded programming language support for
databases
what should we examine when trying to classify sql injections
▶ Route – where injection happens
▶ Motive — what it aims to achieve
▶ SQL code — the form of SQL injected
name the different types of injection routes
▶ User input e.g., web forms via HTTP GET or POST
▶ Cookies used by web apps to build queries
▶ Server variables logged by web apps (e.g., HTTP headers)
▶ Second-order injections where the injection is separated from attack
give me examples of a primary motive
▶ Extracting data
▶ Adding or modifying data
▶ Mounting a denial-of-service attack
▶ Bypassing authentication
▶ Executing arbitrary commands
give me examples of an auxiliary motive
finding injectable parameters
finding database schema
database server fingerprinting
escalating priviledge at a database level