In-depth lesson · CSP bypass
Tips for beginners
Every point the CSP bypass reports back under this heading, best-backed first, each with the reports it is seen in.
-
Look for gadgets in allowed scripts. If the policy allows a third-party library, see if it can be abused to execute code. The reports show AngularJS being used as a gadget, and an analytics script that could be repurposed for exfiltration. Check for known vulnerable libraries and whether their expressions can read the nonce.
Seen in 3 reports
-
Start by understanding the policy in place. Use browser developer tools to inspect the Content-Security-Policy header and note which directives are present or missing. Look for weak policies such as those allowing unsafe-inline, broad script-src lists, or missing base-uri and form-action. The evidence shows that missing directives like base-uri and form-action were key to bypasses.
-
Look for injection points first. Any place that reflects or stores user input is a candidate: comments, titles, filenames, profile fields, and imported data. The reports include many examples, such as a comment text inserted without escaping and a filename not sanitised in an error message. Test with benign markup to see if it renders, then consider whether a bypass is needed.
Seen in 2 reports
-
Check for sanitiser weaknesses. Try inputs that exploit parser differences, such as unusual tag structures or encoded characters. The evidence shows a sanitiser bypass using a tag that differed between the sanitiser's parser and the browser's. Also test type confusion, like setting a value to the string 'false' where a boolean is expected.
Seen in 2 reports
-
Test DOM clobbering. This technique can override variables that the policy relies on, or that the page uses for security decisions. The evidence includes using DOM clobbering to defeat the policy and read a CSRF token. Look for named elements that could shadow global variables.
-
Consider the delivery mechanism. If the site uses a proxy or CDN, test whether you can influence the policy header or serve content from the same origin. The reports show a proxy that cached attacker-supplied policy headers and a service worker path traversal that served attacker HTML. These are advanced but impactful.
-
When you find a bypass, demonstrate impact clearly. Show that you can execute script, read sensitive data, or perform actions as the victim. The evidence includes chaining a bypass with an OAuth flow to steal a token and using a bypass to read a CSRF token. A proof of concept that only shows an alert may be considered low impact.
Seen in 2 reports
-
Check the program's scope and rules before reporting. Some programs exclude browser-specific issues or require a specific browser version. The evidence includes testing browser-specific bypasses and reporting the version. Also, avoid reporting self-XSS unless you can show a realistic attack path.
Seen in 2 reports
-
Do not report a bypass without an injection. A CSP bypass alone is not a vulnerability; it must be combined with a way to inject content. The reports all involve an injection point, such as a reflected parameter or stored field. Make sure you can demonstrate the full chain.
Seen in 2 reports
-
Keep up with new bypass techniques. The evidence includes recent reports on browser-specific bypasses and DOM clobbering. Follow security research and test new techniques against your targets, but always stay within the program's rules.
Seen in 2 reports
-
Look for unusual features like reader mode, extensions, or QR code flows. These can provide alternative execution contexts. The reports include using reader mode to run script and scanning a crafted QR code. These may be out of scope for some programs, so check first.
Seen in 1 report