📘
Gitbook on React and NextJS
  • Welcome!
  • Performance
    • Performance Monitoring
    • Analyzing Bundle Sizes
    • How to speed up your app
  • How to avoid expensive re-calculations
  • How to decrease unnecessary re-renders
  • How to handle CPU-intensive tasks
  • Design System
    • Styled Components
    • Theme UI
    • Base Web
    • Styled JSX
    • Reach UI
    • Evergreen
  • Security
  • Third-Party Assets
  • Clickjacking
  • Cross-Site Request Forgery
  • Next JS
    • Why Next.js
    • How to style Next JS
    • How to configure Next.js
    • API in Next JS
    • How to fetch data in Next.js
    • Dynamic imports
Powered by GitBook
On this page

Was this helpful?

Clickjacking

PreviousThird-Party AssetsNextCross-Site Request Forgery

Last updated 4 years ago

Was this helpful?

A clickjacking attack may affect any type of application independently of the technology or framework used to build it. So, React and other apps are vulnerable.

Client-side attempts to block clickjacking attacks usually don't work well since they are easy to get around.

A better approach to prevent clickjacking attacks is to ask the browser to block any attempt to load your website within an iframe. You can do it by sending the X-Frame-Options HTTP header.

The X-Frame-Options header is added on the server-side, not the client. This is because the header is used to control how the browser should render the page.

The deny directive completely disables the loading of the page in a frame, regardless of what site is trying. Below is what the header request will look like if this is enabled.

X-Frame-Options: deny

The sameorigin directive allows the page to be loaded in a frame on the same origin as the page itself. Below is what the header request will look like if this is enabled.

X-Frame-Options: sameorigin

Browsers Supporting X-Frame-Options

  • IE8+

  • Opera 10.50+

  • Safari 4+

  • 4.1.249.1042+ ()

  • Firefox (or earlier with )

Major browsers support the X-Frame-Options header. However, , so there might be browsers not supporting it.

A standard approach to prevent clickjacking attacks, including Cross Site Scripting () and data injection attacks, is by using specific (CSP) directives.

Browsers Supporting Content-Security-Policy 1.0

  • IE10+ partially supports

  • Microsoft Edge 12+

  • Opera 15+

  • Safari 15+

  • Chrome 14+

  • Firefox 4+

- Evaluate your Content Security Policy

Chrome
Allow-From not yet supported
3.6.9
NoScript
it has never been standardized
XSS
Content Security Policy
CSP Evaluator