Clickjacking
An attack that loads your site in an invisible frame on another page, so a user’s click lands on your button, such as “delete” or “pay”.
In clickjacking (also called UI redressing) the attacker’s page embeds yours in a transparent iframe and places a decoy on top. The user thinks they click “play video” and in fact confirms a payment, changes a setting or grants a permission in their logged-in session on your site. The browser sends their cookies, so the server sees a legitimate request, and CSRF tokens do not help, because the real page submits them.
The defense is a response header that tells browsers who may frame your pages. The modern one is the CSP directive frame-ancestors, for example frame-ancestors 'self'. The older X-Frame-Options header with DENY or SAMEORIGIN covers older browsers; its ALLOW-FROM value is obsolete and ignored. OWASP’s clickjacking defense cheat sheet recommends sending both. They belong to the standard set of HTTP security headers.
Sources
- MDN: CSP frame-ancestors developer.mozilla.org
- MDN: X-Frame-Options developer.mozilla.org
- OWASP: Clickjacking Defense Cheat Sheet cheatsheetseries.owasp.org
Related terms
- CSP (Content Security Policy): An HTTP header that tells the browser which scripts, styles and connections a page may use, limiting the damage of injected code.
- HTTP security headers: Response headers such as CSP, HSTS, X-Content-Type-Options and Referrer-Policy that tell browsers to apply extra protections to your site.
- CSRF (cross-site request forgery): Another site making a logged-in user’s browser send a request to your app, which the app trusts because the cookie came along.
- XSS (cross-site scripting): Attacker-controlled script running in your page in another user’s browser, with that user’s session.
- WAF (web application firewall): A filter in front of a web app that blocks malicious HTTP requests before they reach your code.
