Search⌘ K
AI Features

X Frame Options

Explore how the X-Frame-Options header mitigates clickjacking attacks by restricting iframe embedding of web pages. Understand its possible values such as DENY, SAMEORIGIN, and ALLOW-FROM, and learn to implement it using Helmet middleware in Node.js for enhanced web security.

The X-Frame-Options HTTP header was introduced to mitigate an attack called Clickjacking. Clickjacking allows an attacker to disguise page elements such as buttons and text inputs by hiding their view behind real web pages which render on the screen using an iframe HTML element or similar objects.

Deprecation Notice: The X-Frame-Options header was never standardized as part of an official specification but many popular browsers today still support it. Its successor is the Content-Security-Policy (CSP) header which will be covered in the next section. Generally, you should focus on implementing CSP for newly built web applications.

The risk

Clickjacking attacks, also known as UI redressing, involve misleading the user to perform a seemingly harmless operation. In reality, the user is clicking buttons that secretly belong to other elements or typing text into an input field that is under the attacker’s control.

Common examples of employing a Clickjacking attack:

  1. If a bank or email account website doesn’t
...