Cross-Site Request Forgery
Anti-CSRF Token
- server process only with valid right token
Referrer Validation
- > still head might be suppressed
Double Submit Cookies
Custom Request Header
- > applications would have to be changed significantly
Cross-site Scripting (XSS)
Server Client
Reflected user must visit malicious link
no change to server
XSS Mitigation
HttpOnly Cookies
Content Security Policy (CSP)
e.g.
script-src ‘self’: Only allow JavaScript per files from same origin
img-src ‘self’ img.com: Only allow images from same origin and img.com
Command Injection in PHP
e. g.
http: //victim.com/calc.php?number=5 -> 5 user input
http: //victim.com/calc.php?number=5; system(‘rm .’);
SQL Injection
e.g.
normal:
SELECT pizza, toppings, quantity, order_day
FROM orders
WHERE userid=4123 AND order_month=10
malicious:
SELECT pizza, toppings, quantity, order_day
FROM orders
WHERE userid=4123 AND order_month=0 OR 1=1
Blind SQL Injection
- has to use side channel to learn result
Preventing SQL Injection