X-Frame-Options response header configuration for web security


During project detection, there is a missing "X-Frame-Options" response header in the security report, indicating that cross-frame scripting attacks may occur, as follows:

After inquiries, it was found that:

X-Frame-Options: There are three values:
  (1) DENY: Indicates that the page is not allowed to be displayed in the frame, even if it is nested in pages with the same domain name.
  (2) SAMEORIGIN: Indicates that the page can be displayed in the frame of the page with the same domain name.
  (3) ALLOW-FROM https://example.com/: Indicates that the page can be displayed in the frame of the specified source.


Current solutions used:

1. Configure Apache:

  (If it is local, it is configured in httpd.conf; if it is linux (ubuntu), it is in apache2.conf), find an empty location加入这行代码,具体看你是选择哪种

<span style="font-size:14px;">Header always append X-Frame-Options SAMEORIGIN</span>  

There may be a situation where I try to restart Apache after configuring apache on the server, but an error is reported:

Invalid command ‘Header’, perhaps misspelled or defined by a module not included in the server configuration

  The header method module is not installed, we need to install it by ourselves first:

  First enter a2enmod heade, then you need to restart Apache, enter service apache2 restart


2. Configure Nginx:

  To configure nginx to send the X-Frame-Options response header, add the following line to the 'http', 'server' or 'location' configuration:

<span style="font-size:14px;">add_header X-Frame-Options SAMEORIGIN;</span>

3. Configure IIS:

  To configure IIS to send the X-Frame-Options response header, add the following configuration to the Web.config file:

  1. <system.webServer>
  2. ...
  3. <httpProtocol>
  4. <customHeaders>
  5. <add name="X-Frame-Options" value="SAMEORIGIN" />
  6. </customHeaders>
  7. </httpProtocol>
  8. ...
  9. </system.webServer>

4. The way to set on the server is as follows:

Java code:
response.addHeader("x-frame-options","SAMEORIGIN");



Related


X-Frame-Options response header configuration for web security

During project detection, there is a missing "X-Frame-Options" response header in the security report, indicating that cross-frame scripting attacks may occur, as follows: After inquiries, it was found that: X-Frame-Options: There are three values:   (1) DENY:

How to set X-Frame-Options as response header in angularJS?

pix1289 I receive the X-Frame-Options header from the response from the API, but as I understand it, to prevent clickjacking attacks, I need to add it in the UI code. The UI code (written in angularjs) is deployed in a Tomcat (version 7.0.72) server. I try to

How to set X-Frame-Options as response header in angularJS?

pix1289 I receive the X-Frame-Options header from the response from the API, but as I understand it, to prevent clickjacking attacks, I need to add it in the UI code. The UI code (written in angularjs) is deployed in a Tomcat (version 7.0.72) server. I try to

How to set X-Frame-Options as response header in angularJS?

pix1289 I receive the X-Frame-Options header from the response from the API, but as I understand it, to prevent clickjacking attacks, I need to add it in the UI code. The UI code (written in angularjs) is deployed in a Tomcat (version 7.0.72) server. I try to

How to set X-Frame-Options as response header in angularJS?

pix1289 I receive the X-Frame-Options header from the response from the API, but as I understand it, to prevent clickjacking attacks, I need to add it in the UI code. The UI code (written in angularjs) is deployed in a Tomcat (version 7.0.72) server. I try to

How to set X-Frame-Options as response header in angularJS?

pix1289 I receive the X-Frame-Options header from the response from the API, but as I understand it, to prevent clickjacking attacks, I need to add it in the UI code. The UI code (written in angularjs) is deployed in a Tomcat (version 7.0.72) server. I try to

How to set X-Frame-Options as response header in angularJS?

pix1289 I receive the X-Frame-Options header from the response from the API, but as I understand it, to prevent clickjacking attacks, I need to add it in the UI code. The UI code (written in angularjs) is deployed in a Tomcat (version 7.0.72) server. I try to

What is the meaning of the X-Frame-Options header?

sch I'm working on an app where users can embed their website in surrounding content by loading it in an iframe. Apparently this depends on the X-Frame-Options not being set on the user site for this to work. The client asked me to create a reverse proxy becau

X-Frame-Options header not set to Nginx

Karina My website is on nginx server. I will add to /etc/nginx/nginx.conf add_header X-Frame-Options SAMEORIGIN; add_header X-Content-Type-Options nosniff; Header not showing on site, please enter image description here Pierre Anissol We need more information

aspnetboilerplate: remove x-frame-options header

Nitin In my aspnetboilerplate based site how to remove headers X-Frame-Options: SAMEORIGINfrom asp.net core response . 1 of the ones I tried . string MyAllowSpecificOrigins = "_myAllowSpecificOrigins"; services.AddCors(options => {

X-Frame-Options header not set to Nginx

Karina My website is on nginx server. I will add to /etc/nginx/nginx.conf add_header X-Frame-Options SAMEORIGIN; add_header X-Content-Type-Options nosniff; Header not showing on site, please enter image description here Pierre Anissol We need more information

X-Frame-Options header not set to Nginx

Karina My website is on nginx server. I will add to /etc/nginx/nginx.conf add_header X-Frame-Options SAMEORIGIN; add_header X-Content-Type-Options nosniff; Header not showing on site, please enter image description here Pierre Anissol We need more information

X-Frame-Options header not set to Nginx

Karina My website is on nginx server. I will add to /etc/nginx/nginx.conf add_header X-Frame-Options SAMEORIGIN; add_header X-Content-Type-Options nosniff; Header not showing on site, please enter image description here Pierre Anissol We need more information

X-Frame-Options and Content-Security-Policy for frames in Firefox

Sergey Litvinov Content Security Policy Specification says The frame-ancestors directive obsoletes the X-Frame-Options header. If the resource has both policies, the frame ancestor policy should be enforced and the X-Frame-Options policy should be ignored. So

X-Frame-Options and Content-Security-Policy for frames in Firefox

Sergey Litvinov Content Security Policy Specification says The frame-ancestors directive obsoletes the X-Frame-Options header. If the resource has both policies, the frame ancestor policy should be enforced and the X-Frame-Options policy should be ignored. So

X-Frame-Options and Content-Security-Policy for frames in Firefox

Sergey Litvinov Content Security Policy Specification says The frame-ancestors directive obsoletes the X-Frame-Options header. If the resource has both policies, the frame ancestor policy should be enforced and the X-Frame-Options policy should be ignored. So

X-Frame-Options header not set: how to set it?

Nicole I am using Apache server for Wamp application. While doing security testing, I got the following bug report which states: The X-Frame-Options header is not set. For this, I know that there are 3 types of X frame options. However, where do I implement th