Clickjacking
Clickjacking is an interface-based attack in which a user is tricked into clicking on actionable content on a hidden website by clicking on some other content in a decoy website.
We can give protection against this attack using a CSRF Token (A session-specific, single-use number or nonce).
Google Chrome has built-in security features and browser extensions that can help protect against clickjacking
Basic Click-jacking payload
Online Site for testing Clickjacking
This payload you can use as POC.
You can replace the src value in an Iframe and check for a proof of concept of clickjacking. If you see a website inside the iframe, it is vulnerable to clickjacking.
Performing Click jacking using Burp Suite Professional
Burp's Click Bandit tool is best for testing clickjacking. It generates an interactive proof of concept in seconds without writing a single line of HTML or CSS.
Clickjacking with pre-filled form data
First, identify the text field where you can add data and capture the request in burp suite.


In this case, I can see that there is an email parameter that holds a passed email value. I will pass the email ID in the URL and see if I get the value in the website reflected.
As soon, as I visited this site, It showed be email id pre-filled on the website.

Now I will make a payload for clickjacking.
The above code worked perfectly.
Frame busting scripts
This is a special type of script that uses the browser to prevent clickjacking. Its main role is to ensure that the website loads in the main window and that nothing is hidden. If the script detects clickjacking, it alerts the user.
These frame buster are javascript which can be easily prevented from getting loaded by the browser. We can bypass this by using iframe with sandbox attribute.
When this is set with the allow-forms or allow-scripts values and the allow-top-navigation value is omitted then the frame buster script can be neutralized as the iframe cannot check whether or not it is the top window.
Both the allow-forms and allow-scripts values permit the specified actions within the iframe but top-level navigation is disabled. This inhibits frame busting behaviors while allowing functionality within the targeted site.
Combining clickjacking with a DOM XSS attack
We can combine clickjacking and DOM XXS attacks.
Implementing this combined attack is relatively straightforward, assuming the attacker first identified the XSS exploit. The XSS exploit is then combined with the iframe target URL so that the user clicks on the button or link and consequently executes the DOM XSS attack.
First, Check which parameter is vulnerable to an XXS attack. In my case, the name field was vulnerable.

Making payload to exploit.
The above exploit makes use of XXS and clickjacking vulnerability.
Multiple-step clickjacking
An attacker can design a payload that forces you to click multiple times. For instance, they might trick you into making purchases on a retail site by causing you to unknowingly add several items to your shopping cart before you place an order. This is often achieved by overlaying several invisible elements or iframes on the page. However, for such an attack to work effectively and remain unnoticed, the attacker must be very precise and careful in how they implement it.
Protection against Clickjacking
It can be prevented on both the client and server sides. On the client side, we can use frame busting to prevent this. On the server side, we can use Headers to avoid this vulnerability.
Below are headers that will be helpful.
X-Frame-Options
Content Security Policy.
X-Frame-Options is not implemented consistently across browsers (the allow-from directive is not supported in Chrome version 76 or Safari 12 for example). However, when properly applied with Content Security Policy as part of a multi-layer defence strategy it can provide effective protection against clickjacking attacks.
Content Security Policy (CSP) is a detection and prevention mechanism that provides mitigation against attacks such as XSS and clickjacking.
CSP informs the client browser about the permitted sources for web resources, enabling it to detect and block potentially malicious behaviors.
Last updated