Review Videos for Lecture 14: Cross-Site Request Forgery (CSRF) + Cross-Site Scripting (XSS)


Cross-Site Request Forgery (CSRF)

HTML Forms


Why do we prefer sending HTML forms using HTTP POST requests instead of GET requests?




Session Management with Cookies




Cross-Site Request Forgery (CSRF)


Fill in the blanks with (attacker/victim/server) or (GET/POST): In a CSRF attack, the ___ sends an HTTP ___ request to the ___. The ___ responds with some HTML that fills out a form with malicious input and some Javascript that sends the form to the ___. The ___ sends the filled-out form to the ___ as an HTTP ___ request, along with any browser cookies. The ___ thinks this request is legitimate and accepts the malicious form input.




Real-World CSRF Attacks




Defense: CSRF Tokens



Would the CSRF token defense work if the server used the same CSRF token for every request, regardless of user?




Defense: Referer Validation


Would referer validation stop the CSRF attack shown at the beginning of the video? Assume the browser attaches the correct referer, and the referer field is not blank.




CSRF Conclusion




Cross-Site Scripting (XSS)

Intro to XSS, Review




Stored XSS


If the user input is stored on the server and displayed as HTML, how can an attacker inject Javascript?




XSS Demo




Real-world XSS Attacks




Reflected XSS


(True/False) Reflected XSS requires the victim to visit a malicious link crafted by the attacker, but Stored XSS does not.




XSS Defenses


Consider an escaper that finds all instances of <script> and </script> in user input and removes them. Can an attacker still perform an XSS attack with <script> tags? If yes, write a malicious input that would bypass this escaping function. If no, explain why.