相关文章推荐

Oracle recommends that you set the values of the HTTP headers listed in this section to prevent exploitation of known vulnerabilities caused due to these headers not being set, or set with wrong/default values.

The following are some of the commonly used secure headers:

  • Headers to Mitigate XSS Attacks
  • HTTP Strict Transport Security Header
  • Referrer-Policy
  • X-Frame-Options Header to Mitigate Clickjacking Attempts
  • X-Content-Type-Options
  • ServerSignature
  • ServerTokens
  • Secure Flag for Cookies
  • SameSite Flag for Cookies
  • Note:

    Best practice is to set these headers at the application level. If it is not possible or if you want to exercise extra precaution, you can configure them in Oracle HTTP Server. See My Oracle Support document ID 2370975.1 .

    Headers to Mitigate XSS Attacks

    Cross-Site Scripting (XSS) attacks occur when an attacker sends malicious code to a different end user through a web application, in the form of a browser side script. Faults in web applications allows XSS attacks to succeed and can occur wherever a web application uses input from a user without validating or encoding it.

    For example, an attacker may use XSS to send a malicious script to an user. Unaware of the situation, the end user’s browser might execute the script assuming that the script is from a trusted source and might let the malicious script to access cookies, session tokens, or other sensitive information retained by the browser and used with that site.

    Headers to mitigate XSS attacks include:
  • Content Security Policy
  • X-XSS-Protection
  • HttpOnly
  • Content Security Policy

    A Content Security Policy header helps to mitigate the risk of content injection by giving developers control over resources that can be requested on behalf of a worker.

    The Content Security Policy is a browser side mechanism which allows you to create source whitelists such as JavaScript, CSS, images, and so on, for client side resources of your web application. The Content Security Policy instructs the browser through a special HTTP header, to only execute or render resources from those sources.

    It is not possible for the web server to implement Content Security Policy because the web server does not know the list of domains from which an end-user’s web application is allowed to load style sheets, images and so on. The web server also does not know if the application makes use of plugins, media, and so on and if these are to be allowed to be loaded.

    Oracle recommends that a policy based on the application characteristics be defined and implemented using the Content Security Policy header.

    The following are examples to use Content Security Policy rules:

    Example: Rule 1
    Content-Security-Policy: default-src 'self'
    This is a restrictive rule and works in applications in which:
  • All resources are hosted by the same domain of the given page.
  • There are no inlines or evaluationss for scripts and style resources.
  • Example: Rule 2
    Content-Security-Policy: default-src 'none'; script-src 'self'; connect-src 'self'; img-src 'self'; style-src 'self';
    This policy:
  • Does not allow resources like object, frame, and media to load.
  • Allows images, scripts, AJAX, and CSS from the same origin.
  • Note:

    The X-XSS-Protection header has been deprecated by modern browsers and its use can introduce additional security issues on the client side. Therefore, Oracle recommends you to set the header as X-XSS-Protection: 0 to disable the XSS Auditor, and not allow it to take the default behavior of the browser handling the response. Use Content-Security-Policy instead. See
    Content Security Policy .

    The X-XSS-Protection header re-enables the XSS filter for a particular website, if the user has disabled it. It is a security best practice to include the X-XSS-Protection header in all HTTP responses.

    This enables browser detection of reflected XSS attacks. Underlying reflected XSS vulnerabilities still need to be fixed in the underlying application. A browser detecting an XSS and blocking it does not mean that the application has an XSS vulnerability. In some cases, this header may block legitimate responses, for example, a message board where javascript programming is discussed.

    Table 3-1 describes the X-XSS-Protection header values.

    Table 3-1 Header Values and Descriptions

    To mitigate the Cross-Site Scripting (XSS) attack, Oracle recommends that you make the following configuration changes:
  • Open the httpd.conf file using the Advanced Server Configuration page in Fusion Middleware Control or a text editor.
  • Add the following header configuration, after the LoadModule section:
    <IfModule mod_headers.c>
    Header set X-XSS-Protection "1; mode=block"
    </IfModule>

    Referrer-Policy

    The Referrer-Policy header contains the address of the previous web page that a user follows to accesses the currently requested page.

    The Referrer-Policy header has many uses including analytics, logging, optimized caching, and more problematic uses such as tracking, or stealing information. It also has side effects such as inadvertent leaking of sensitive information.

    To enable Referrer-Policy, set the Referrer-Policy header to:

    Header always set Referrer-Policy "same-origin"

    This ensures that a referrer is sent for same-site origins, and the cross-origin requests does not contain referrer information.

    ServerSignature

    The ServerSignature directive allows you to configure a footer in the web server generated documents.

    In a chain of proxies, the footer tells which of the chained servers produced a returned error message. The syntax is:

    ServerSignature On | Off | EMail

    The default value is Off , which suppresses the footer line. The value On adds a footer with the server version number and the server name of the serving virtual host. The value EMail additionally creates a mailto: reference to the value specified in the ServerAdmin directive of the referenced document.

    ServerTokens

    The ServerTokens directive allows you to configure the server HTTP response header.

    This directive controls whether the server response header field which is sent back to the clients includes a description of the generic OS-type of the server as well as the information about compiled-in modules. The syntax is:

    ServerTokens Full | OS | Minor | Minimal | Major | Prod | None | Custom

    The default value is Full , which includes information about the OS-type of the server and the compiled-in modules. The value Prod includes the least information. The value None removes the server header. The value custom takes a string as a second argument, which is used as the value of the server header.

    You can use ServerTokens Custom some-server-string to disguise the web server software when Oracle HTTP Server generates the response header. When a backend server generates the response, the server response header may come from the backend server depending on the proxy mechanism.

    Note:

    ServerTokens Custom some-server-string is a replacement for the ServerHeader Off setting in Oracle HTTP Server 10g.
  •  
    推荐文章