WEBSEC | D. Ross |
Internet-Draft | Microsoft |
Intended status: Informational | T. Gondrom |
Expires: February 28, 2014 | Thames Stanley |
August 27, 2013 |
HTTP Header Field X-Frame-Options
draft-ietf-websec-x-frame-options-12
To improve the protection of web applications against Clickjacking, this definition describes the X-Frame-Options HTTP response header field that declares a policy communicated from the server to the client browser on whether the browser may display the transmitted content in frames that are part of other web pages. This informational document serves to document the existing use and specification of this X-Frame-Options HTTP response header field.
This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at http://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."
This Internet-Draft will expire on February 28, 2014.
Copyright (c) 2013 IETF Trust and the persons identified as the document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.
In 2009 and 2010 many browser vendors ([Microsoft-X-Frame-Options], [CLICK-DEFENSE-BLOG], [Mozilla-X-Frame-Options]) introduced the use of a non-standard HTTP [RFC2616] header field "X-Frame-Options" to protect against Clickjacking [Clickjacking]. HTML-based web applications can embed or "frame" other web pages. Clickjacking is a type of attack that occurs when an attacker uses multiple transparent or opaque layers in the user interface to trick a user into clicking on a button or link on another page from server B when they were intending to click on the same place of the overlaying page from server A. Thus, the attacker is "hijacking" clicks meant for their page A and routing them to another page B. The attacker is tricking the user (who sees the overlaying user interface content from page A) into clicking specific locations on the underlying page from server B, triggering some actions on server B and potentially using an existing session context in that step. This is an attack on both the user and on server B. And server A may or may not be the attacker.
This specification provides informational documentation about the current use and definition of the X-Frame-Options HTTP header field. As described in Section 2.3.2.2 not all browsers implement X-Frame-Options exactly in the sames way, which can lead to unintended results. And given that the "X-" construction is deprecated [RFC6648], the X-Frame-Options header field will in the future be replaced by the Frame-Options directive in the Content Security Policy Version 1.1 [CSP-1-1].
Existing anti-ClickJacking measures, e.g. Frame-breaking Javascript, have weaknesses so that their protection can be circumvented as a study [FRAME-BUSTING] demonstrated.
Short of configuring the browser to disable frames and script entirely, which massively impairs browser utility, browser users are vulnerable to this type of attack.
"X-Frame-Options" allows a web page from host B to declare that its content (for example a button, links, text, etc.) must not be displayed in a frame (<frame> or <iframe>) of another page (e.g. from host A). This is done by a policy declared in the HTTP header and enforced by browser implementations as documented here.
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 [RFC2119].
The X-Frame-Options HTTP response header field indicates a policy on whether the browser should render the transmitted resource within a <frame> or <iframe>. Servers can declare this policy in the header of their HTTP responses to prevent clickjacking attacks, and by this ensuring that their content is not embedded into other pages or frames.
The header field name is:
X-Frame-Options
There are three different values for the header field. These values are mutually exclusive, that is exactly one of the three values MUST be set.
The meaning of the term "serialized-origin" is given in [RFC6454].
If the ALLOW-FROM value is used, it MUST be followed by a valid origin [RFC6454] (as a subset of URI [RFC3986])
Any data beyond the domain address (i.e. any data after the "/" separator) is to be ignored. And the algorithm to compare origins from [RFC6454] SHOULD be used to verify that a referring page is of the same origin as the content (in the case of SAMEORIGIN) or that the referring page's origin is identical with the ALLOW-FROM serialized-origin (in the case of ALLOW-FROM). Though in conflict with [RFC6454], current implementations do not consider the port as a defining component of the origin. I.e. existing implementations differ with [RFC6454] in that origins with the same protocol but different port values are considered equivalent.
Wildcards or lists to declare multiple domains in one ALLOW-FROM statement are not permitted (see Section 2.3.2.3).
X-Frame-Options = "DENY" / "SAMEORIGIN" / ( "ALLOW-FROM" RWS SERIALIZED-ORIGIN ) RWS = 1*( SP / HTAB ) ; required whitespace
The RFC 5234 [RFC5234] ABNF of the X-Frame-Options header field value is the following.
[RFC6454] and the definition of RWS (required whitespace) is the same as in [HTTPbis-P1].
RWS is used when at least one linear whitespace octet is required to separate field tokens. RWS SHOULD be generated as a single space (SP). Multiple RWS octets that occur within field-content SHOULD either be replaced with a single SP or transformed to all SP octets before interpreting the field value or forwarding the message downstream.
And SP (space) and HTAB (horizontal tab) are as defined in RFC 5234 [RFC5234], Appendix B.1.
The values are specified as ABNF strings, and therefore are case-insensitive.
X-FRAME-OPTIONS: DENY X-FRAME-OPTIONS: SAMEORIGIN X-FRAME-OPTIONS: ALLOW-FROM https://example.com/
There are a number of main direct vectors that enable HTML content from other domains and browser implementations of X-Frame-Options cover all of them:
Besides these, other ways to host HTML content can be possible. For example some plugins may host HTML views directly. If these plugins appear essentially as frames (as opposed to top-level windows), the plugins must conform to the X-FRAME-OPTIONS policy as specified in this document as well.
To allow secure implementations, browsers must behave in a consistent and reliable way.
If an X-Frame-Options HTTP header field prohibits framing, the user-agent of the browser MAY immediately abort downloading or parsing of the document.
When a browser discovers that loaded content with the X-FRAME-OPTIONS header field would be displayed in a frame against the specified orders of the header, the browser SHOULD redirect as soon as possible to a "No-Frame" page. For example this can be a noframe.html page that also states the full URL and hostname of the protected page.
The NoFrame page could provide the user with an option to open the target URL in a new window.
Implementations of this vary, some browsers will show a message that allows the user to safely open the target page in a new window. Other implementations will simply render an empty frame.
There are currently variations in the implementation of the X-FRAME-OPTIONS header. For example not all browsers support the "ALLOW-FROM" option. "ALLOW-FROM" was initially an Internet Explorer extension and at the time of writing has not been uniformly implemented by other user agents.
Furthermore the criteria for the SAMEORIGIN (and ALLOW-FROM) directive may not be evaluated unanimously either: The known implementations in Appendix A evaluate the SAMEORIGIN directive based on the origin of the framed page and the top-level browsing-context, while other implementations might evaluate based on the framed page and the framing page, or the whole chain of nested frames inbetween.
Web page A <html> .... <frame src="https://URI_of_web_page_B" /> </html> Web Page B <html> .... <frame src="https://URI_of_web_page_C" /> </html> And so forth...
To illustrate the difference between the comparison with "framing page" and the "top-level browsing-context" consider the following scenario: Web pages may embed frames with other pages which in turn embed frames with other pages as well and so on. In theory this can result in an infinite nesting of framed pages. For example web page A may contain in a frame web page B, and web page B contains in a frame web page C.
In this example, for the nested frames with the inner framed web page C, the most outer web page A would be the "top-level browsing-context" and web page B would be the "framing page"
These potential variations in the evaluation of the header by different implementations impair the useage and reliability of this http header and have security implications as described in section 5. A revised version of x-frame-options in the form of a frame-options directive in the CSP 1.1[CSP-1-1] will unify the behaviour and it is expected that newer implementations will use it rather than the mechanisms documented here.
As the "ALLOW-FROM" field only supports one serialized-origin, in cases when the server wishes to allow more than one resource to frame its content, the following design pattern can fulfil that need:
It is not recommended to cache the X-Frame-Options header for a resource. Caching the X-Frame-Options response could result in problems because:
However, we found that none of the major browsers listed in Appendix A cache the responses.
This document was derived from input from specifications published by various browser vendors such as Microsoft (Eric Lawrence, David Ross), Mozilla, Google, Opera and Apple.
This memo is a request to IANA to include the specified HTTP header in the registry as outlined in Registration Procedures for Message Header Fields [RFC3864]
PERMANENT MESSAGE HEADER FIELD REGISTRATION TEMPLATE: Header field name: X-Frame-Options Applicable protocol: http [RFC2616] Status: informational Author/Change controller: IETF Specification document(s): draft-ietf-websec-x-frame-options Related information:
Figure 1
The introduction of the X-FRAME-OPTIONS http header field does improve the protection against Clickjacking. However, it is not self-sufficient on its own to protect against all kinds of these attack vectors. It must be used in conjunction with other security measures like secure coding (e.g. input validation, output encoding, ...) and the Content Security Policy [CSP].
It is important to note that current implementations do not check the origins of the entire ancestor tree of frames of the framing resources, and this may expose the resource to attack in multiple-nested scenarios.
The browser implementations evaluate based on the origin of the framed page and the top-level browsing-context (i.e. most outer frame):
If a resource from origin A embeds untrusted content from origin B, that untrusted content can embed another resource from origin A with an X-Frame-Options: SAMEORIGIN policy and that check would pass when the user agent only verifies the top-level browsing context. Therefore web developers should be aware that embedding content from other sites can leave their web pages vulnerable to clickjacking even if the X-Frame-Options header is used.
Furthermore, X-Frame-Options must be sent as an HTTP header field and is explicitly ignored by user agents when declared with a meta http-equiv tag.
There are two kinds of potential data leakage to consider:
[RFC2119] | Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997. |
[RFC5234] | Crocker, D. and P. Overell, "Augmented BNF for Syntax Specifications: ABNF", STD 68, RFC 5234, January 2008. |
[RFC3986] | Berners-Lee, T., Fielding, R. and L. Masinter, "Uniform Resource Identifier (URI): Generic Syntax", STD 66, RFC 3986, January 2005. |
[RFC6454] | Barth, A., "The Web Origin Concept", RFC 6454, December 2011. |
More detailed explanation of Clickjacking scenarios
An Internet Marketplace/Shop offering a feature with a link/button to "Buy this" Gadget
The marketplace wants their affiliates (who could be malicious attackers) to be able to stick the "Buy such-and-such from XYZ" IFRAMES into their pages. There is a possible Clickjacking threat here, which is why the marketplace/onlineshop needs to then immediately navigate the main browsing context (or a new window) to a confirmation page which is protected by anti-Clickjacking protections.
The "Confirm Purchase" page of an online shop must be shown to the end user without the risk of an overlay or misuse by an attacker. For that reason, the confirmation page uses a combination of anti-CSRF (Cross Site Request Forgery, [CSRF]) tokens and the X-FRAME-OPTIONS HTTP header field, mitigating ClickJacking attacks.
Macromedia Flash configuration settings are set by a Flash object which can run only from a specific configuration page on Macromedia's site. The object runs inside the page and thus can be subject to a ClickJacking attack. In order to prevent ClickJacking attacks against the security settings, the configuration page uses the X-FRAME-OPTIONS directive.