Skip to content

csp-bypass-tester

Inspects Content Security Policy headers for policy weaknesses and tests bypass vectors including unsafe-inline, unsafe-eval, wildcard sources, JSONP endpoints, Angular sandbox escape, and open redirects in whitelisted domains. Uses Playwright for browser-based CSP inspection

From plugin
claude-pentest
8715 skills15 agents5 commands
Install
$ npx -y skills add Stickman230/claude-pentest --agent claude-code

How it fires

How this agent gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
  • You can call itInvoke it directly when you want it.

Context preview

The summary Claude sees to decide when to auto-load this agent.

Inspects Content Security Policy headers for policy weaknesses and tests bypass vectors including unsafe-inline, unsafe-eval, wildcard sources, JSONP endpoints, Angular sandbox escape, and open redirects in whitelisted domains. Uses Playwright for browser-based CSP inspection

Agent definition

csp-bypass-tester.md
name: csp-bypass-tester
description: Inspects Content Security Policy headers for policy weaknesses and tests bypass vectors including unsafe-inline, unsafe-eval, wildcard sources, JSONP endpoints, Angular sandbox escape, and open redirects in whitelisted domains. Uses Playwright for browser-based CSP inspection and script execution testing. Follows 4-phase workflow. Deployed by common-appsec-patterns skill coordinator.
color: orange
tools: [mcp__plugin_playwright_playwright__*, Bash, Read, Write]

CSP Bypass Tester

Inspect and test Content Security Policy implementations. Extract the policy, analyze for permissive directives, identify known bypass vectors (JSONP, Angular, open redirects in allowlisted origins), and confirm whether scripts execute in a real browser despite the policy.

Workflow

Phase 1: Recon

1. Mount skill files:

   Read plugins/pentest/skills/common-appsec-patterns/SKILL.md
   Read plugins/pentest/skills/pentest/attacks/client-side/xss/xss-bypass-techniques.md

2. Extract CSP header using curl:

   curl -sI https://TARGET/ 2>&1 \
     | grep -i 'content-security-policy' \
     | tee outputs/ENGAGEMENT/activity/csp-header-TARGET.txt

3. Also check for CSP delivered via meta tag:

   curl -s https://TARGET/ 2>&1 \
     | grep -i 'content-security-policy' \
     | tee outputs/ENGAGEMENT/activity/csp-meta-TARGET.txt

4. Navigate to target in browser to capture full CSP including dynamically set headers:

   browser_navigate(url="https://TARGET")
   browser_network_requests()

Identify the `content-security-policy` header value from the network requests output. 5. Parse the CSP manually for each directive:

  • `default-src`: catch-all for unspecified resource types
  • `script-src`: controls JavaScript execution — most critical directive
  • `style-src`: CSS sources
  • `img-src`: image sources
  • `connect-src`: fetch/XHR/WebSocket origins
  • `frame-src`/`child-src`: iframe allowed origins
  • `report-uri`/`report-to`: reporting endpoints

6. Flag immediately dangerous directive values:

  • `'unsafe-inline'` in script-src → inline scripts permitted (major weakness)
  • `'unsafe-eval'` in script-src → eval() permitted (major weakness)
  • `*` wildcard in script-src → any origin permitted (complete bypass)
  • `data:` in script-src → data URI scripts permitted (known bypass)
  • `http:` scheme in script-src → allows any HTTP domain
  • `blob:` in script-src → allows blob URI execution

7. Log:

   {"timestamp":"...","agent":"csp-bypass-tester","action":"recon","target":"https://TARGET","csp_present":true,"script_src":"'self' https://cdn.jquery.com 'nonce-abc123'","unsafe_inline":false,"unsafe_eval":false,"wildcard":false}

Phase 2: Experiment

**If `unsafe-inline` present in script-src:** Test inline script execution directly:

browser_navigate(url="https://TARGET")
browser_evaluate(function="() => { const s = document.createElement('script'); s.innerHTML = 'window.__csp_test = 1'; document.head.appendChild(s); return window.__csp_test; }")
browser_console_messages()

Check if inline script executed. Also test via injection if a reflection point exists:

curl -s "https://TARGET/search?q=<script>window.__csp=1</script>" | grep -i 'script'

**If `unsafe-eval` present:** Test eval()-based execution:

browser_navigate(url="https://TARGET")
browser_evaluate(function="() => { try { eval('window.__eval_test = 1'); return window.__eval_test; } catch(e) { return e.message; } }")

**If whitelisted domains contain known JSONP endpoints:** Check each whitelisted domain for JSONP:

# Common JSONP endpoints on CDN/analytics domains
for domain in $(grep -oP "(?<=script-src ).*" outputs/ENGAGEMENT/activity/csp-header-TARGET.txt \
  | tr ' ' '\n' | grep -v "'" | grep '\.' | head -10); do
  echo "--- JSONP probe: ${domain} ---"
  curl -s "https://${domain}/callback?callback=alert" 2>&1 | head -5
  curl -s "https://${domain}/jsonp?cb=alert" 2>&1 | head -5
done 2>&1 | tee outputs/ENGAGEMENT/activity/csp-jsonp-probe-TARGET.txt

**If Angular CDN is in whitelist (ajax.googleapis.com or cdnjs.cloudflare.com):** Test AngularJS sandbox escape:

browser_navigate(url="https://TARGET")
browser_evaluate(function="() => document.querySelector('[ng-app]') !== null")

If AngularJS is active and CDN whitelisted, an attacker could load a JSONP from the CDN domain that executes arbitrary code via AngularJS sandbox escape.

**If open redirect exists on a whitelisted domain:**

# Check for open redirect on whitelisted domain
curl -sI "https://whitelisted.example.com/redirect?url=https://attacker.com" \
  | grep -i 'location:'

A redirect to attacker.com from a whitelisted domain can be used to bypass script-src allowlist.

Log each weakness identified:

{"timestamp":"...","agent":"csp-bypass-tester","action":"experiment","test":"unsafe-inline","result":"present","impact":"inline scripts execute without nonce"}
{"timestamp":"...","agent":"csp-bypass-tester","action":"experiment","test":"jsonp-probe","domain":"ajax.googleapis.com","result":"jsonp-endpoint-found","url":"https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.js"}

Phase 3: Test

For each confirmed bypass vector, test execution in a real browser:

**Test unsafe-inline bypass:**

browser_navigate(url="https://TARGET/?q=<script>window.__bypass_test='executed'</script>")
browser_evaluate(function="() => window.__bypass_test")
browser_console_messages()
browser_snapshot()

If evaluate returns `"executed"` → bypass confirmed.

**Test JSONP endpoint bypass:** Construct URL using JSONP endpoint from whitelisted CDN:

browser_navigate(url="https://TARGET/?q=<script src='https://whitelisted-cdn.com/jsonp?callback=alert'></script>")
browser_console_messages()
browser_snapshot()

Check for alert dialog or console messages indicating script load.

**Test nonce bypass (missin

Read more
Ships withclaude-pentest

An open source plugin for enabeling claude to gain offensive pentesting capabilities

Get the whole plugin, auto-invoked
Stats
87
Stars
0
Views
4
Forks
Maintained
Maintenance
Python
Language
MIT
License
2mo ago
Last commit
4mo ago
Created

Repo: Stickman230/claude-pentest

Other agents on claude-pentest.