Computer and Network Security

Table of Contents

Web attacks

Authentication

Which is the best way to auth web users?

Basic auth:

Attacking authentication

Authorization

Authorization: what can a user do?

attacks:

Command Injection attacks

Main problem:

Server-side includes (SSI)

PHP’s allow_url_fopen allows URLs when including files with include()/require(), if user input used for this then bad

HTML injection:

How do you survive? Don’t trust user input, use built-in sanitization functions.

SQL injection

Input validation error where SQL queries built using unsanitized parameters provided by users.

For example, if logins are verified by checking with a database like this:

var sql = "select * from user_accounts \
    where username = '" + username + "' and \
    password = '" + password + "'";

If you enter ' or 1=1 -- as the username, you get this query, returning the whole table:

select * from user_accounts where username='' or 1=1 --' and password="

SQL injection can modify any type of query (SELECT, INSERT, UPDATE, DELETE)

With MySQL, double-dash comment requires the second dash to be followed by at least one whitespace/control character. You can use subqueries to get more info, e.g. (select version()) as one of the fields in an INSERT query. If results aren’t seen immediately, see if they are reflected somewhere else on the page.

Number of columns in query can be determined by using UNION SELECT NULL, UNION SELECT NULL, NULL, etc. progressively longer. Type of columns can be determined by adding e.g. a string to the UNION SELECT.

To determine table/column names, rely on database-specific techniques. Want to look at metadata tables, schema tables, etc.

Second Order SQL injection

Blind SQL injection (when no output/error from web app)

Dealing with SQL injections