Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes issue #1577 #1605

Closed

Conversation

caffeine-rohit
Copy link
Contributor

This pull request Closes #1577 . I updated the Clickjacking Cheat Sheet by adding all the necessary information regarding double-click jacking. Please let me know if any further improvements are required, otherwise feel free to merge it as soon as possible.

@kwwall
Copy link
Collaborator

kwwall commented Feb 1, 2025

@caffeine-rohit - Please do not combine commits related to different issues and different cheat sheets into a single PR. Please make these 2 commits into separate PRs as the address 2 different issues. Thanks!

Copy link
Collaborator

@kwwall kwwall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a windows dev, but these changes look fine to me.

OTOH, please remove this commit from PR #1605 (because these changes have nothing to do with GitHub issue #1577) and move it to a separate PR. Thanks.


## Introduction

This cheat sheet is intended to provide guidance for developers on how to defend against [Clickjacking](https://owasp.org/www-community/attacks/Clickjacking), also known as UI redress attacks.
This cheat sheet is intended to provide guidance for developers on how to defend against [Clickjacking](https://owasp.org/www-community/attacks/Clickjacking), also known as UI redress attacks and Double Click Jacking.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be "Double Clickjacking", not "Double Click Jacking".

Also, let's give credit where credit is due, shall we and link the "Double Clickjackin" to Yibelo's blog post at https://www.paulosyibelo.com/2024/12/doubleclickjacking-what.html?m=1.

Comment on lines +339 to +343
<script>
if (self !== top) {
top.location = self.location;
}
</script>
Copy link
Collaborator

@kwwall kwwall Feb 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a JavaScript expert by any means, but it's my understanding that this simple script is not even enough to mitigate simple Clickjacking, so why do you think this would be effective against Double Clickjacking?

The currently suggested script is way more complex. That's why I suggested you refer to as part of my reply in OWASP Slack. This is what we currently recommend for simple Clickjacking frame breaking techniques:
https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html#best-for-now-legacy-browser-frame-breaking-script

Can you explain why this wouldn't work? (If I had to guess--I've not tested it--I think that it would.) But I don't think the trivial script above is likely to be effective for the same reasons it's been found ineffective for simple Clickjacking attacks.

In fact Yibelo suggests this as framebusting script:

    (function(){
    if (window.matchMedia && window.matchMedia("(hover: hover)").matches) {
        var buttons = document.querySelectorAll('form button, form input[type="submit"]');
        buttons.forEach(button => button.disabled = true);
        
        function enableButtons() {
            buttons.forEach(button => button.disabled = false);
        }
        
        document.addEventListener("mousemove", enableButtons);
        document.addEventListener("keydown", e => {
            if(e.key === "Tab") enableButtons();
        });
    }
})();

I for one have no idea how this works, but I would tend to put more faith in this than the simple JavaScript you have proposed.

Comment on lines +351 to +377
### 2. X-Frame-Options Header

Use the X-Frame-Options HTTP header to restrict iframe embedding:

X-Frame-Options: DENY

Alternatively, allow only trusted domains:

X-Frame-Options: SAMEORIGIN

#### Limitations:

Some browsers do not support X-Frame-Options.

Attackers can still use UI redressing techniques to manipulate users into clicking unintended elements.

### 3. Content Security Policy (CSP) Frame-Ancestors

Use CSP to control which domains can embed your site:

Content-Security-Policy: frame-ancestors 'self' https://trusted.example.com;

#### Limitations:

CSP-based protections only work when enforced properly and do not protect against all forms of Clickjacking.

Attackers can still use overlays or timing-based click manipulation to deceive users.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you not read Yibelo's post that I linked to in issue #1577? There Yibelo states (emphasis mine):

DoubleClickjacking is a new variation on this classic theme: instead of relying on a single click, it takes advantage of a double-click sequence. While it might sound like a small change, it opens the door to new UI manipulation attacks that bypass all known clickjacking protections, including the X-Frame-Options header, CSP's frame-ancestors and SameSite: Lax/Strict cookies. This technique seemingly affects almost every website, leading to account takeovers on many major platforms.

It is pointless to mention these as defenses if they are ineffective for Double Clickjacking. In addition, they are already thoroughly discussed in the original simple Clickjacking defense. So, IMO, this adds zero value and it in fact detrimental as it is misleading. Please delete it.

Comment on lines +384 to +393
<button onclick="confirmAction()">Submit</button>
<script>
function confirmAction() {
if (!this.clickedOnce) {
this.clickedOnce = true;
alert('Click again to confirm action.');
} else {
// Proceed with the action
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmanico @mackowski @szh - JavaScript is not my forte. In fact, I only learn enough of it to create some very simple PoC exploits, so I am not qualified to review this. If I were, I would have submitted a PR myself.

Comment on lines +406 to +412
Highlighting clicked elements.

Requiring explicit user confirmation through modal dialogs.

Disabling buttons for a short time after the first click to prevent rapid unintended actions.

Implementing progressive disclosure, where critical actions require an additional confirmation step.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make these bullet items.


Double Clickjacking is a sophisticated attack that leverages multiple user interactions to bypass traditional Clickjacking defenses. Implementing a combination of X-Frame-Options, Content-Security-Policy, JavaScript-based frame-busting techniques, UI feedback mechanisms, and real-time user behavior analysis can help mitigate this risk effectively. Organizations should adopt a layered security approach to protect against evolving threats and continuously assess the effectiveness of their Clickjacking defenses.

### For a more in-depth understanding of double-click jacking and its implications, you can refer to the following articles:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it curious that all 3 of these referenced in-depth links start out by giving direct credit to Paulos Yibelo who is the one who first discussed (and presumably discovered) Double Clickjacking, and yet you don't link to Yibelo's blog post, https://www.paulosyibelo.com/2024/12/doubleclickjacking-what.html?m=1. That should be the primary reference. I think it's inexcusable to do otherwise.

Copy link
Collaborator

@kwwall kwwall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think significant revisions (many of which I've noted) are needed before I can approve this. Please make the requested changes. And let's start by getting commit ID #95ed6819103eca43bcaa0a4b73ebf4502a4c13c0 out of this PR and into a separate one associated with a separate GH issue. Thanks.

@caffeine-rohit
Copy link
Contributor Author

This PR was closed and opened a new PR #1609, which includes all the requested changes while ensuring a more refined and improved implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update: Clickjacking_Defense_Cheat_Sheet.md to address Double Clickjacking
2 participants