From bd42625b3216d6e8d2573fb51609eac0a69950ee Mon Sep 17 00:00:00 2001 From: Aadith Sukumar <62766172+aadi1011@users.noreply.github.com> Date: Sun, 8 Oct 2023 23:50:58 +0530 Subject: [PATCH 1/6] Create Clickjacking.md Added a directory to discuss clickjacking attacks --- Clickjacking/Clickjacking.md | 96 ++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 Clickjacking/Clickjacking.md diff --git a/Clickjacking/Clickjacking.md b/Clickjacking/Clickjacking.md new file mode 100644 index 0000000000..850324311a --- /dev/null +++ b/Clickjacking/Clickjacking.md @@ -0,0 +1,96 @@ +# Clickjacking: Web Application Security Vulnerability + +> Clickjacking is a type of web security vulnerability where a malicious website tricks a user into clicking on something different from what the user perceives, +> potentially causing the user to perform unintended actions without their knowledge or consent. Users are tricked into performing all sorts of unintended actions +> are such as typing in the password, clicking on ‘Delete my account’ button, liking a post, deleting a post, commenting on a blog. In other words all the actions +> that a normal user can do on a legitimate website can be done using clickjacking. + +## Summary +* [Tools](#tools) +* [Methodology](#methodology) + * [UI Redressing](#ui-redressing) + * [Invisible Frames](#invisible-frames) + * [Button/Form Hijacking](#button-form-hijacking) +* [Filter Bypasses](#filter-bypasses) +* [Practice Environments](#practice-environments) +* [Reference](#references) + +## Tools +* [Burp Suite](https://portswigger.net/burp) +* [OWASP ZAP](https://github.com/zaproxy/zaproxy) +* [Clickjack](https://github.com/machine1337/clickjack) + +## Methodology + +### UI Redressing +UI Redressing is a Clickjacking technique where an attacker overlays a transparent UI element on top of a legitimate website or application. +The transparent UI element contains malicious content or actions that are visually hidden from the user. By manipulating the transparency and positioning of elements, +the attacker can trick the user into interacting with the hidden content, believing they are interacting with the visible interface. +* **How UI Redressing Works:** + * Overlaying Transparent Element: The attacker creates a transparent HTML element (usually a `
`) that covers the entire visible area of a legitimate website. This element is made transparent using CSS properties like `opacity: 0;`. + * Positioning and Layering: By setting the CSS properties such as `position: absolute; top: 0; left: 0;`, the transparent element is positioned to cover the entire viewport. Since it's transparent, the user doesn't see it. + * Misleading User Interaction: The attacker places deceptive elements within the transparent container, such as fake buttons, links, or forms. These elements perform actions when clicked, but the user is unaware of their presence due to the overlaying transparent UI element. + * User Interaction: When the user interacts with the visible interface, they are unknowingly interacting with the hidden elements due to the transparent overlay. This interaction can lead to unintended actions or unauthorized operations. +```html +
+ Click me +
+``` + +### Invisible Frames +Invisible Frames is a Clickjacking technique where attackers use hidden iframes to trick users into interacting with content from another website unknowingly. +These iframes are made invisible by setting their dimensions to zero (height: 0; width: 0;) and removing their borders (border: none;). +The content inside these invisible frames can be malicious, such as phishing forms, malware downloads, or any other harmful actions. + +* **How Invisible Frames Work:** + * Hidden IFrame Creation: The attacker includes an ` + ``` + * Loading Malicious Content: The src attribute of the iframe points to a malicious website or resource controlled by the attacker. This content is loaded silently without the user's knowledge because the iframe is invisible. + * User Interaction: The attacker overlays enticing elements on top of the invisible iframe, making it seem like the user is interacting with the visible interface. For instance, the attacker might position a transparent button over the invisible iframe. When the user clicks the button, they are essentially clicking on the hidden content within the iframe. + * Unintended Actions: Since the user is unaware of the invisible iframe, their interactions can lead to unintended actions, such as submitting forms, clicking on malicious links, or even performing financial transactions without their consent. + + +### Button/Form Hijacking +```html + +
+ +
+ +``` + +## Preventive Measures + +### Implement X-Frame-Options Header +Implement the X-Frame-Options header with the DENY or SAMEORIGIN directive to prevent your website from being embedded within an iframe without your consent. +```apache +Header always append X-Frame-Options SAMEORIGIN +``` + +### Content Security Policy (CSP) +Use CSP to control the sources from which content can be loaded on your website, including scripts, styles, and frames. +Define a strong CSP policy to prevent unauthorized framing and loading of external resources. +Example in HTML meta tag: +```html + +``` + + + + + + +## Practice Environments +* [OWASP WebGoat](https://owasp.org/www-project-webgoat/) + +## References +* [Clickjacker.io](https://clickjacker.io) +* [Portswigger](https://portswigger.net/web-security/clickjacking) +* [Synopsys](https://www.synopsys.com/glossary/what-is-clickjacking.html#B) +* [OWASP](https://owasp.org/www-community/attacks/Clickjacking) From ce4affc79b783c4590803d649ab2ea2244adb23f Mon Sep 17 00:00:00 2001 From: Aadith Sukumar <62766172+aadi1011@users.noreply.github.com> Date: Mon, 9 Oct 2023 09:40:28 +0530 Subject: [PATCH 2/6] Update and rename Clickjacking.md to README.md --- Clickjacking/Clickjacking.md | 96 ---------------- Clickjacking/README.md | 207 +++++++++++++++++++++++++++++++++++ 2 files changed, 207 insertions(+), 96 deletions(-) delete mode 100644 Clickjacking/Clickjacking.md create mode 100644 Clickjacking/README.md diff --git a/Clickjacking/Clickjacking.md b/Clickjacking/Clickjacking.md deleted file mode 100644 index 850324311a..0000000000 --- a/Clickjacking/Clickjacking.md +++ /dev/null @@ -1,96 +0,0 @@ -# Clickjacking: Web Application Security Vulnerability - -> Clickjacking is a type of web security vulnerability where a malicious website tricks a user into clicking on something different from what the user perceives, -> potentially causing the user to perform unintended actions without their knowledge or consent. Users are tricked into performing all sorts of unintended actions -> are such as typing in the password, clicking on ‘Delete my account’ button, liking a post, deleting a post, commenting on a blog. In other words all the actions -> that a normal user can do on a legitimate website can be done using clickjacking. - -## Summary -* [Tools](#tools) -* [Methodology](#methodology) - * [UI Redressing](#ui-redressing) - * [Invisible Frames](#invisible-frames) - * [Button/Form Hijacking](#button-form-hijacking) -* [Filter Bypasses](#filter-bypasses) -* [Practice Environments](#practice-environments) -* [Reference](#references) - -## Tools -* [Burp Suite](https://portswigger.net/burp) -* [OWASP ZAP](https://github.com/zaproxy/zaproxy) -* [Clickjack](https://github.com/machine1337/clickjack) - -## Methodology - -### UI Redressing -UI Redressing is a Clickjacking technique where an attacker overlays a transparent UI element on top of a legitimate website or application. -The transparent UI element contains malicious content or actions that are visually hidden from the user. By manipulating the transparency and positioning of elements, -the attacker can trick the user into interacting with the hidden content, believing they are interacting with the visible interface. -* **How UI Redressing Works:** - * Overlaying Transparent Element: The attacker creates a transparent HTML element (usually a `
`) that covers the entire visible area of a legitimate website. This element is made transparent using CSS properties like `opacity: 0;`. - * Positioning and Layering: By setting the CSS properties such as `position: absolute; top: 0; left: 0;`, the transparent element is positioned to cover the entire viewport. Since it's transparent, the user doesn't see it. - * Misleading User Interaction: The attacker places deceptive elements within the transparent container, such as fake buttons, links, or forms. These elements perform actions when clicked, but the user is unaware of their presence due to the overlaying transparent UI element. - * User Interaction: When the user interacts with the visible interface, they are unknowingly interacting with the hidden elements due to the transparent overlay. This interaction can lead to unintended actions or unauthorized operations. -```html -
- Click me -
-``` - -### Invisible Frames -Invisible Frames is a Clickjacking technique where attackers use hidden iframes to trick users into interacting with content from another website unknowingly. -These iframes are made invisible by setting their dimensions to zero (height: 0; width: 0;) and removing their borders (border: none;). -The content inside these invisible frames can be malicious, such as phishing forms, malware downloads, or any other harmful actions. - -* **How Invisible Frames Work:** - * Hidden IFrame Creation: The attacker includes an ` - ``` - * Loading Malicious Content: The src attribute of the iframe points to a malicious website or resource controlled by the attacker. This content is loaded silently without the user's knowledge because the iframe is invisible. - * User Interaction: The attacker overlays enticing elements on top of the invisible iframe, making it seem like the user is interacting with the visible interface. For instance, the attacker might position a transparent button over the invisible iframe. When the user clicks the button, they are essentially clicking on the hidden content within the iframe. - * Unintended Actions: Since the user is unaware of the invisible iframe, their interactions can lead to unintended actions, such as submitting forms, clicking on malicious links, or even performing financial transactions without their consent. - - -### Button/Form Hijacking -```html - -
- -
- -``` - -## Preventive Measures - -### Implement X-Frame-Options Header -Implement the X-Frame-Options header with the DENY or SAMEORIGIN directive to prevent your website from being embedded within an iframe without your consent. -```apache -Header always append X-Frame-Options SAMEORIGIN -``` - -### Content Security Policy (CSP) -Use CSP to control the sources from which content can be loaded on your website, including scripts, styles, and frames. -Define a strong CSP policy to prevent unauthorized framing and loading of external resources. -Example in HTML meta tag: -```html - -``` - - - - - - -## Practice Environments -* [OWASP WebGoat](https://owasp.org/www-project-webgoat/) - -## References -* [Clickjacker.io](https://clickjacker.io) -* [Portswigger](https://portswigger.net/web-security/clickjacking) -* [Synopsys](https://www.synopsys.com/glossary/what-is-clickjacking.html#B) -* [OWASP](https://owasp.org/www-community/attacks/Clickjacking) diff --git a/Clickjacking/README.md b/Clickjacking/README.md new file mode 100644 index 0000000000..2bdead5b00 --- /dev/null +++ b/Clickjacking/README.md @@ -0,0 +1,207 @@ +# Clickjacking: Web Application Security Vulnerability + +> Clickjacking is a type of web security vulnerability where a malicious website tricks a user into clicking on something different from what the user perceives, +> potentially causing the user to perform unintended actions without their knowledge or consent. Users are tricked into performing all sorts of unintended actions +> are such as typing in the password, clicking on ‘Delete my account’ button, liking a post, deleting a post, commenting on a blog. In other words all the actions +> that a normal user can do on a legitimate website can be done using clickjacking. + +## Summary +* [Tools](#tools) +* [Methodology](#methodology) + * [UI Redressing](#ui-redressing) + * [Invisible Frames](#invisible-frames) + * [Button/Form Hijacking](#button-form-hijacking) + * [Execution Methods](#execution-methods) +* [Preventive Measures](#preventive-measures) + * [Implement X-Frame-Options Header](#implement-x-frame-options-header) + * [Content Security Policy (CSP)](#content-security-policy-csp) + * [Disabling JavaScript](#disabling-javascript) +* [OnBeforeUnload Event](#onbeforeunload-event) +* [XSS Filter](#xss-filter) + * [IE8 XSS filter](#ie8-xss-filter) + * [Chrome 4.0 XSSAuditor filter](#chrome-40-xssauditor-filter) +* [Practice Environments](#practice-environments) +* [Reference](#references) + +## Tools +* [Burp Suite](https://portswigger.net/burp) +* [OWASP ZAP](https://github.com/zaproxy/zaproxy) +* [Clickjack](https://github.com/machine1337/clickjack) + +## Methodology + +### UI Redressing +UI Redressing is a Clickjacking technique where an attacker overlays a transparent UI element on top of a legitimate website or application. +The transparent UI element contains malicious content or actions that are visually hidden from the user. By manipulating the transparency and positioning of elements, +the attacker can trick the user into interacting with the hidden content, believing they are interacting with the visible interface. +* **How UI Redressing Works:** + * Overlaying Transparent Element: The attacker creates a transparent HTML element (usually a `
`) that covers the entire visible area of a legitimate website. This element is made transparent using CSS properties like `opacity: 0;`. + * Positioning and Layering: By setting the CSS properties such as `position: absolute; top: 0; left: 0;`, the transparent element is positioned to cover the entire viewport. Since it's transparent, the user doesn't see it. + * Misleading User Interaction: The attacker places deceptive elements within the transparent container, such as fake buttons, links, or forms. These elements perform actions when clicked, but the user is unaware of their presence due to the overlaying transparent UI element. + * User Interaction: When the user interacts with the visible interface, they are unknowingly interacting with the hidden elements due to the transparent overlay. This interaction can lead to unintended actions or unauthorized operations. +```html +
+ Click me +
+``` + +### Invisible Frames +Invisible Frames is a Clickjacking technique where attackers use hidden iframes to trick users into interacting with content from another website unknowingly. +These iframes are made invisible by setting their dimensions to zero (height: 0; width: 0;) and removing their borders (border: none;). +The content inside these invisible frames can be malicious, such as phishing forms, malware downloads, or any other harmful actions. + +* **How Invisible Frames Work:** + * Hidden IFrame Creation: The attacker includes an ` + ``` + * Loading Malicious Content: The src attribute of the iframe points to a malicious website or resource controlled by the attacker. This content is loaded silently without the user's knowledge because the iframe is invisible. + * User Interaction: The attacker overlays enticing elements on top of the invisible iframe, making it seem like the user is interacting with the visible interface. For instance, the attacker might position a transparent button over the invisible iframe. When the user clicks the button, they are essentially clicking on the hidden content within the iframe. + * Unintended Actions: Since the user is unaware of the invisible iframe, their interactions can lead to unintended actions, such as submitting forms, clicking on malicious links, or even performing financial transactions without their consent. + + +### Button/Form Hijacking +Button/Form Hijacking is a Clickjacking technique where attackers trick users into interacting with invisible or hidden buttons/forms, leading to unintended actions on a legitimate website. By overlaying deceptive elements on top of visible buttons or forms, attackers can manipulate user interactions to perform malicious actions without the user's knowledge. + +* **How Button/Form Hijacking Works:** + * Visible Interface: The attacker presents a visible button or form to the user, encouraging them to click or interact with it. + ```html + + ``` + * Invisible Overlay: The attacker overlays this visible button or form with an invisible or transparent element that contains a malicious action, such as submitting a hidden form. + ```html + + ``` + * Deceptive Interaction: When the user clicks the visible button, they are unknowingly interacting with the hidden form due to the invisible overlay. The form is submitted, potentially causing unauthorized actions or data leakage. + ```html + +
+ +
+ + ``` + +### Execution Methods +* Creating Hidden Form: The attacker creates a hidden form containing malicious input fields, targeting a vulnerable action on the victim's website. This form remains invisible to the user. +```html + +``` +* Overlaying Visible Element: The attacker overlays a visible element (button or form) on their malicious page, encouraging users to interact with it. When the user clicks the visible element, they unknowingly trigger the hidden form's submission. + * Example in javascript: + ```js + function submitForm() { + document.getElementById('hidden-form').submit(); + } +``` + + +## Preventive Measures + +### Implement X-Frame-Options Header +Implement the X-Frame-Options header with the DENY or SAMEORIGIN directive to prevent your website from being embedded within an iframe without your consent. +```apache +Header always append X-Frame-Options SAMEORIGIN +``` + +### Content Security Policy (CSP) +Use CSP to control the sources from which content can be loaded on your website, including scripts, styles, and frames. +Define a strong CSP policy to prevent unauthorized framing and loading of external resources. +Example in HTML meta tag: +```html + +``` + +### Disabling JavaScript +* Since these type of client side protections relies on JavaScript frame busting code, if the victim has JavaScript disabled or it is possible for an attacker to disable JavaScript code, the web page will not have any protection mechanism against clickjacking. +* There are three deactivation techniques that can be used with frames: + * Restricted frames with Internet Explorer: Starting from IE6, a frame can have the "security" attribute that, if it is set to the value "restricted", ensures that JavaScript code, ActiveX controls, and re-directs to other sites do not work in the frame. + ```html + + ``` + * Sandbox attribute: with HTML5 there is a new attribute called “sandbox”. It enables a set of restrictions on content loaded into the iframe. At this moment this attribute is only compatible with Chrome and Safari. + ```html + + ``` + +## OnBeforeUnload Event +* The `onBeforeUnload` event could be used to evade frame busting code. This event is called when the frame busting code wants to destroy the iframe by loading the URL in the whole web page and not only in the iframe. The handler function returns a string that is prompted to the user asking confirm if he wants to leave the page. When this string is displayed to the user is likely to cancel the navigation, defeating target’s frame busting attempt. + +* The attacker can use this attack by registering an unload event on the top page using the following example code: + ```html +

www.fictitious.site

+ + +
+ +``` +Determine the Clickjacking vulnerability within this code snippet. Identify how the hidden iframe is being used to exploit the user's actions when they click the button, leading them to a malicious website. + ## Practice Environments * [OWASP WebGoat](https://owasp.org/www-project-webgoat/) From 19f138d4add15de9e45d6c8b60d9047b59f946f9 Mon Sep 17 00:00:00 2001 From: Swissky <12152583+swisskyrepo@users.noreply.github.com> Date: Mon, 9 Oct 2023 20:52:28 +0200 Subject: [PATCH 6/6] Update README.md --- Clickjacking/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Clickjacking/README.md b/Clickjacking/README.md index 512a11779b..5502ac383b 100644 --- a/Clickjacking/README.md +++ b/Clickjacking/README.md @@ -2,7 +2,7 @@ > Clickjacking is a type of web security vulnerability where a malicious website tricks a user into clicking on something different from what the user perceives, > potentially causing the user to perform unintended actions without their knowledge or consent. Users are tricked into performing all sorts of unintended actions -> are such as typing in the password, clicking on ‘Delete my account’ button, liking a post, deleting a post, commenting on a blog. In other words all the actions +> as such as typing in the password, clicking on ‘Delete my account’ button, liking a post, deleting a post, commenting on a blog. In other words all the actions > that a normal user can do on a legitimate website can be done using clickjacking. ## Summary @@ -175,6 +175,7 @@ _Attacker's Page_ ``` ## XSS Filter + ### IE8 XSS filter This filter has visibility into all parameters of each request and response flowing through the web browser and it compares them to a set of regular expressions in order to look for reflected XSS attempts. When the filter identifies a possible XSS attacks; it disables all inline scripts within the page, including frame busting scripts (the same thing could be done with external scripts). For this reason an attacker could induce a false positive by inserting the beginning of the frame busting script into a request’s parameters. ```html @@ -189,6 +190,7 @@ This filter has visibility into all parameters of each request and response flow ```html