--- url: "https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html" titulek: "Clickjacking Defense - OWASP Cheat Sheet Series" h1: "Clickjacking Defense Cheat Sheet¶" popis: "Website with the collection of all the cheat sheets of the project." jazyk: "en" kanonicka: "https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html" drobecky: [] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-14 01:17:48" znaku: 14895 slov: 2136 kodovani: "utf-8" sha256: "02ffdc95395c694457fb9359b71f1d427650c5b31ea41df85ffcf0ae72909b95" --- # Clickjacking Defense Cheat Sheet¶ ## 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. There are three main mechanisms that can be used to defend against these attacks: - Preventing the browser from loading the page in frame using the [X-Frame-Options](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options) or [Content Security Policy (frame-ancestors)](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors) HTTP headers. - Preventing session cookies from being included when the page is loaded in a frame using the [SameSite](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite) cookie attribute. - Implementing JavaScript code in the page to attempt to prevent it being loaded in a frame (known as a "frame-buster"). Note that these mechanisms are all independent of each other, and where possible more than one of them should be implemented in order to provide defense in depth. ## Defending with Content Security Policy (CSP) frame-ancestors directive¶ The `frame-ancestors` directive can be used in a Content-Security-Policy HTTP response header to indicate whether or not a browser should be allowed to render a page in a `` or ` ``` **Firefox:** Activate [designMode](https://developer.mozilla.org/en-US/docs/Web/API/Document/designMode) in parent page. While designMode is still supported in modern browsers, its effectiveness as a clickjacking attack vector may vary in current browser versions. ``` document.designMode = "on"; ```