👑
Cheet Sheet: AWS, BSCP, HTB
  • 🔹Script Kiddies🔹
    • Wifi Cracking
    • Spam
    • Malware
    • Crypto
  • 🔹AWS🔹
    • AWS Certified Security - Specialty
  • 🔹BSCP🔹
    • #1 Web Attack Cheat Sheet
    • #2 Web Attack: Cheat Sheet
    • BAPP EXTENTIONS
    • 1. Essential skills
    • 2. Information disclosure
    • 3 .HTTP Host headers
    • 4. Authentication
    • 5. OAuth Authentication
    • 6. Broken access control
    • IDOR
    • 7. Path traversal
    • 8. File upload vuln
    • 9. Open Redirect
    • 10. Web Cache Poisoning
    • CSP
    • DOM clobbering
    • 11. Prototype Pollution
    • 12. Web messages
    • 13. WebSockets
    • HTTP request smuggling
    • OS Command Injection
    • Dangling markup injection
    • CORS
    • Logic Flaws
    • Insecure deserialization
    • JWT
    • Clickjacking
    • Race Condition
    • LFI / RFI
    • CSRF
    • SSRF
    • SSTI
    • XXE
    • XSS
    • XSS PAYLOADS
    • GRAPHQL
    • NoSQL Injection
    • SQL Injection
  • 🔹HTB🔹
    • CTF
    • Starting Point
    • TIER: 1
    • TIER: 2
  • 🔹HTB: LINUX OSCP PREP🔹
    • Lame Writeup
    • Brainfuck Writeup
    • Shocker Writeup
    • Bashed Writeup
    • Nibbles
    • Tabby
    • Cronos
    • Nineveh
    • Sense
    • SolidState
    • Node
    • Valentine
    • Poison
    • Sunday
    • TartarSauce
    • Irked
    • FriendZone
    • SwagShop
    • Networked
    • Jarvis
    • Magic
    • Delivery
    • Paper
    • Armageddon
    • Knife
    • Previse
    • Soccer
    • OpenAdmin
  • 🔹HTB: WINDOWS OSCP PREP🔹
    • Legacy
    • Blue
    • Devel
    • Optimum
    • Bastard
    • Granny
    • Artic
    • Grandpa
    • Silo
    • Bounty
    • Jerry
    • Conceal
    • Chatterbox
    • Forest #1 AD
    • Active #2 AD
    • Sauna #3 AD
    • Resolute #4 AD
    • Cascade #5 AD
    • Bastion
    • ServMon
    • Buff
    • Toolbox
    • Driver
    • Return
    • Timelapse
    • Love
    • Monteverde
    • Fuse
    • Scrambled
Powered by GitBook
On this page
  1. 🔹BSCP🔹

Clickjacking

UI redressing

PreviousJWTNextRace Condition

Last updated 1 year ago

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.

How to construct a basic clickjacking attack

Clickjacking attacks use CSS to create and manipulate layers. The attacker incorporates the target website as an iframe layer overlaid on the decoy website. An example using the style tag and parameters is as follows:

<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">
	</iframe>
</body>

The target website iframe is positioned within the browser so that there is a precise overlap of the target action with the decoy website using appropriate width and height position values. Absolute and relative position values are used to ensure that the target website accurately overlaps the decoy regardless of screen size, browser type and platform. The z-index determines the stacking order of the iframe and website layers. The opacity value is defined as 0.0 (or close to 0.0) so that the iframe content is transparent to the user. Browser clickjacking protection might apply threshold-based iframe transparency detection (for example, Chrome version 76 includes this behavior but Firefox does not). The attacker selects opacity values so that the desired effect is achieved without triggering protection behaviors.

//Lab: Basic clickjacking with CSRF token protection

//Clickbandit

Although you can manually create a clickjacking proof of concept as described above, this can be fairly tedious and time-consuming in practice. When you're testing for clickjacking in the wild, we recommend using Burp's Clickbandit tool instead. This lets you use your browser to perform the desired actions on the frameable page, then creates an HTML file containing a suitable clickjacking overlay. You can use this to generate an interactive proof of concept in a matter of seconds, without having to write a single line of HTML or CSS.

Clickjacking with prefilled form input

Some websites that require form completion and submission permit prepopulation of form inputs using GET parameters prior to submission. Other websites might require text before form submission. As GET values form part of the URL then the target URL can be modified to incorporate values of the attacker's choosing and the transparent "submit" button is overlaid on the decoy site as in the basic clickjacking example.

//Lab: Clickjacking with form input data prefilled from a URL parameter

Frame busting scripts

//Lab: Clickjacking with a frame buster script

Combining clickjacking with a DOM XSS attack

So far, we have looked at clickjacking as a self-contained attack. Historically, clickjacking has been used to perform behaviors such as boosting "likes" on a Facebook page. However, the true potency of clickjacking is revealed when it is used as a carrier for another attack such as a DOM XSS attack. Implementation of this combined attack is relatively straightforward assuming that the attacker has 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.

//Lab: Exploiting clickjacking vulnerability to trigger DOM-based XSS

Multistep clickjacking

Attacker manipulation of inputs to a target website may necessitate multiple actions. For example, an attacker might want to trick a user into buying something from a retail website so items need to be added to a shopping basket before the order is placed. These actions can be implemented by the attacker using multiple divisions or iframes. Such attacks require considerable precision and care from the attacker perspective if they are to be effective and stealthy.

//Lab: Multistep clickjacking

How to prevent clickjacking attacks

Clickjacking is a browser-side behavior and its success or otherwise depends upon browser functionality and conformity to prevailing web standards and best practice. Server-side protection against clickjacking is provided by defining and communicating constraints over the use of components such as iframes. However, implementation of protection depends upon browser compliance and enforcement of these constraints. Two mechanisms for server-side clickjacking protection are X-Frame-Options and Content Security Policy.

//X-Frame-Options

  • The header provides the website owner with control over the use of iframes or objects so that inclusion of a web page within a frame can be prohibited with the deny directive: X-Frame-Options: deny

  • Alternatively, framing can be restricted to the same origin as the website using the sameorigin directive: X-Frame-Options: sameorigin

  • or to a named website using the allow-from directive: X-Frame-Options: allow-from https://normal-website.com 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 in conjunction with Content Security Policy as part of a multi-layer defense strategy it can provide effective protection against clickjacking attacks.

//Content Security Policy (CSP)

  • Content Security Policy (CSP) is a detection and prevention mechanism that provides mitigation against attacks such as XSS and clickjacking. CSP is usually implemented in the web server as a return header of the form: Content-Security-Policy: policy

What is Clickjacking? Tutorial & Examples | Web Security AcademyWebSecAcademy
Logo
Lab: Basic clickjacking with CSRF token protection | Web Security AcademyWebSecAcademy
Lab: Clickjacking with form input data prefilled from a URL parameter | Web Security AcademyWebSecAcademy
Logo
Logo
Lab: Clickjacking with a frame buster script | Web Security AcademyWebSecAcademy
Logo
Lab: Exploiting clickjacking vulnerability to trigger DOM-based XSS | Web Security AcademyWebSecAcademy
Logo
Lab: Multistep clickjacking | Web Security AcademyWebSecAcademy
Logo