20
Security Khaled Al-Sham’aa

Security Khaled Al-Shamaa. What Is Security? Security is a measurement, not a characteristic. Security must be balanced with expense. Security must be

Embed Size (px)

DESCRIPTION

Basic Steps Consider illegitimate uses of your application. Educate yourself. If nothing else: FILTER ALL INPUT DATA ESCAPE ALL OUTPUT DATA

Citation preview

Page 1: Security Khaled Al-Shamaa. What Is Security? Security is a measurement, not a characteristic. Security must be balanced with expense. Security must be

Security Khaled Al-Sham’aa

Page 2: Security Khaled Al-Shamaa. What Is Security? Security is a measurement, not a characteristic. Security must be balanced with expense. Security must be

What Is Security?

• Security is a measurement, not a characteristic.

• Security must be balanced with expense.

• Security must be balanced with usability.

• Security must be part of the design.

Page 3: Security Khaled Al-Shamaa. What Is Security? Security is a measurement, not a characteristic. Security must be balanced with expense. Security must be

Basic Steps

• Consider illegitimate uses of your application.

• Educate yourself.

• If nothing else:

FILTER ALL INPUT DATAESCAPE ALL OUTPUT DATA

Page 4: Security Khaled Al-Shamaa. What Is Security? Security is a measurement, not a characteristic. Security must be balanced with expense. Security must be

Register Globals (1)

Page 5: Security Khaled Al-Shamaa. What Is Security? Security is a measurement, not a characteristic. Security must be balanced with expense. Security must be

Register Globals (2)

Page 6: Security Khaled Al-Shamaa. What Is Security? Security is a measurement, not a characteristic. Security must be balanced with expense. Security must be

Filtering (1)

Page 7: Security Khaled Al-Shamaa. What Is Security? Security is a measurement, not a characteristic. Security must be balanced with expense. Security must be

Filtering (2)

Page 8: Security Khaled Al-Shamaa. What Is Security? Security is a measurement, not a characteristic. Security must be balanced with expense. Security must be

Filtering (3)

Page 9: Security Khaled Al-Shamaa. What Is Security? Security is a measurement, not a characteristic. Security must be balanced with expense. Security must be

Form Processing (1)

Page 10: Security Khaled Al-Shamaa. What Is Security? Security is a measurement, not a characteristic. Security must be balanced with expense. Security must be

Form Processing (2)

Page 11: Security Khaled Al-Shamaa. What Is Security? Security is a measurement, not a characteristic. Security must be balanced with expense. Security must be

Cross-Site Scripting (XSS)

Page 12: Security Khaled Al-Shamaa. What Is Security? Security is a measurement, not a characteristic. Security must be balanced with expense. Security must be

Cross-Site Scripting (XSS) 1

Page 13: Security Khaled Al-Shamaa. What Is Security? Security is a measurement, not a characteristic. Security must be balanced with expense. Security must be

Cross-Site Scripting (XSS) 2

Page 14: Security Khaled Al-Shamaa. What Is Security? Security is a measurement, not a characteristic. Security must be balanced with expense. Security must be

Cross-Site Scripting (XSS) 3

• htmlentities()• strip_tags()• utf8_decode()

Page 15: Security Khaled Al-Shamaa. What Is Security? Security is a measurement, not a characteristic. Security must be balanced with expense. Security must be

Session Hijacking

Page 16: Security Khaled Al-Shamaa. What Is Security? Security is a measurement, not a characteristic. Security must be balanced with expense. Security must be

SQL Injection (example 1)

<form method="post" action="http://www.example.com/login.php">

<input name="user" type="text"><input name="pwd" type="password">

</form>

Page 17: Security Khaled Al-Shamaa. What Is Security? Security is a measurement, not a characteristic. Security must be balanced with expense. Security must be

SQL Injection (example 1) con.

• SELECT `id` FROM `logins` WHERE `username` = '$user' AND `password` = '$pwd'

• $user = “Khaled”;• $pwd = “anything' OR 'x'='x”;

• SELECT `id` FROM `logins` WHERE `username` = 'Khaled' AND `password` = 'anything' OR 'x'='x'

Page 18: Security Khaled Al-Shamaa. What Is Security? Security is a measurement, not a characteristic. Security must be balanced with expense. Security must be

SQL Injection (example 2)

• $query = “UPDATE usertable SET pwd='$pwd' WHERE uid='$uid' ”;

• $pwd = “abc”;• $uid = “anything' or uid='admin'; -- ”;

• $query = “UPDATE usertable SET pwd='abc' WHERE uid= 'anything' or uid='admin'; -- ' ”;

Page 19: Security Khaled Al-Shamaa. What Is Security? Security is a measurement, not a characteristic. Security must be balanced with expense. Security must be

Avoiding SQL Injection

• mysql_real_escape_string()

• for PHP version < 4.3.0 use addslashes()

• Prepared Statements

Page 20: Security Khaled Al-Shamaa. What Is Security? Security is a measurement, not a characteristic. Security must be balanced with expense. Security must be

Questions