.. _SpringSecurityLinkageWithBrowser: Coordinating with browser security countermeasure function ================================================================================ .. only:: html .. contents:: Table of contents :local: Overview -------------------------------------------------------------------------------- This chapter explains how to coordinate with the security countermeasure function provided by browser. Main Web browser provides a few security countermeasure functions so that the functions provided by the browser are not affected. Some security countermeasure functions provided by the browser can control the operations by displaying response header of HTTP at the server side. Spring Security provides a system to enhance security of Web application by offering function to output the security response header. .. note:: **Security risk** Even if the security response header is displayed, it does not guarantee 100% elimination of security risk. Ultimately, user should consider it as a support function to reduce the security risk. Note that, the support status of security header varies depending on the browser. .. note:: **Overwriting HTTP header** HTTP header may be overwritten by the application even though the following settings are done. Security headers supported by default ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The following 7 response headers are supported by Spring Security by default. * Cache-Control (Pragma, Expires) * X-Frame-Options * X-Content-Type-Options * X-XSS-Protection * Strict-Transport-Security * Content-Security-Policy(Content-Security-Policy-Report-Only) * Public-Key-Pins(Public-Key-Pins-Report-Only) .. tip:: **Support status of browser** Some browsers do not support handling these headers. Refer official site of the browser or the following pages. * https://www.owasp.org/index.php/HTTP_Strict_Transport_Security_Cheat_Sheet (Strict-Transport-Security) * https://www.owasp.org/index.php/Clickjacking_Defense_Cheat_Sheet (X-Frame-Options) * https://www.owasp.org/index.php/OWASP_Secure_Headers_Project#tab=Headers (X-Content-Type-Options, X-XSS-Protection, Content-Security-Policy, Public-Key-Pins) Cache-Control """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Cache-Control header indicates a method to cache the contents. Risk of unauthorized users viewing the protected contents can be reduced by disabling caching for the protected contents of the browser.. The following header is output to disable caching the contents. * Output example of response header .. code-block:: text Cache-Control: no-cache, no-store, max-age=0, must-revalidate Pragma: no-cache Expires: 0 .. note:: **Overwriting Cache-Control header** Cache-Control header is overwritten when Controller class of Spring MVC defines form class of \ ``@SessionAttributes`` \ or uses Model of \ ``@SessionAttributes`` \ attribute in the request handler. .. note:: **Browser compatible with HTTP1.0** Pragma header and Expires header are also output to enable Spring Security support the browser compatible with HTTP1.0 as well. X-Frame-Options """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" X-Frame-Options header indicates whether the contents within the frame (\ ````\ or \ ``