Content Security Policy

Check List

Methodology

CSP Misconfiguration

1

Inspect HTTP response headers of target

2

Observe the Content-Security-Policy header includes script-src 'unsafe-inline'

3

This allows inline scripts execution, weakening CSP protections against Cross-Site Scripting (XSS)

4

Although no direct exploit is shown, the presence of unsafe-inline increases risk of script injection attacks

5

Best practice Avoid unsafe-inline in script-src to reduce XSS attack surface


CSP Bypass Via Percent-Encoding

1

Appending % or % to the URL endpoint causes the browser to misinterpret or relax CSP enforcement

2

By inspecting and editing the HTML in the dev tools, an attacker can inject inline JavaScript and use this cheat sheet despite a strict script-src policy, leading to a bypass of the CSP


Cheat Sheet

CSP Header

curl -I $WEBSITE | grep "content-security-policy"

CSP Parameters

default-src (Secure)

default-src (Non-Secure)

script-src (Secure)

script-src (Non-Secure)

style-src (Secure)

style-src (Non-Secure)

img-src (Secure)

img-src (Non-Secure)

connect-src (Secure)

connect-src (Non-Secure)

font-src (Secure)

font-src (Non-Secure)

object-src (Secure)

object-src (Non-Secure)

frame-src (Secure)

frame-src (Non-Secure)

frame-ancestors (Secure)

frame-ancestors (Non-Secure)

sandbox (Secure)

sandbox (Non-Secure)

CSP Bypass

BeEF & JSONP

Create Script

Run Script

Last updated