Cross Site Scripting
Snippets of XSS stuff
XSS
Basic XSS Payload
Load remote script
Send Cookie details to attacker server
XSS + CSRF
Chaining XSS + CSRF to execute javascript
Base64 encode the entire payload above and send with
Mitigation
Sanitize inputs on the Front-end and Back-end
Validate inputs on the Front-end and Back-end
Output HTML Encoding
html entities
Server Configuration
XSS prevention headers
X-XSS-Protection
Use
Content-Security-Policy
options likescript-src="self"
to only allow locally hosted scriptsUse
HttpOnly
andSecure
cookie flags to prevent JavaScript from reading cookie values
WAF to detect and block XSS attacks
Same Origin Policy for Cross-Site. Does not work for the same site
Last updated