Copyright © 2014 W3C® (MIT, ERCIM, Keio, Beihang), All Rights Reserved. W3C liability, trademark and document use rules apply.
This document describes how an author can set a referrer policy for documents they create, and the impact of such a policy on the referer
HTTP header for outgoing requests and navigations.
This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.
This document was published by the Web Application Security Working Group as a Working Draft. This document is intended to become a W3C Recommendation.
The (archived) public mailing list public-webappsec@w3.org (see instructions) is preferred for discussion of this specification. When sending e-mail, please put the text “REFERRER” in the subject, preferably like this: “[REFERRER] …summary of comment…”
This document is a First Public Working Draft.
Publication as a First Public Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.
This document was produced by the Web Application Security Working Group.
This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.
This section is not normative.
Requests made from a document, and for navigations away from that document
are associated with a referer
header. While the header
can be suppressed for links with the noreferrer
link
type, authors might wish to control the referer
header
more directly for a number of reasons:
A social networking site has a profile page for each of its users, and users add hyperlinks from their profile page to their favorite bands. The social networking site might not wish to leak the user’s profile URL to the band web sites when other users follow those hyperlinks (because the profile URLs might reveal the identity of the owner of the profile).
Some social networking sites, however, might wish to inform the band web sites that the links originated from the social networking site but not reveal which specific user’s profile contained the links.
A web application uses HTTPS and a URL-based session identifier. The web application might wish to link to HTTPS resources on other web sites without leaking the user’s session identifier in the URL.
Alternatively, a web application may use URLs which themselves grant some capability. Controlling the referrer can help prevent these capability URLs from leaking via referrer headers. [CAPABILITY-URLS]
A blog hosted over HTTPS might wish to link to a blog hosted over HTTP and receive trackback links.
referer
header when fetching subresources,
prefetching, or performing navigations.
If no referrer policy is explicitly set for a global environment,
then the value of the property is null
. Otherwise, the value
is whatever has been explicitly set, as explained in the
§6.1
Set environment’s referrer policy to policy.
algorithm.
origin
and the origin of request’s
url
are "the same", as defined by
Section 5
of the Origin specification. [RFC6454]
Every global environment has a referrer policy which governs
the referrer information sent along with requests made for subresources, and
for navigations. The policy will be null
if no policy has
been set, otherwise it will be one of the following five values:
None
, None when downgrade
,
Origin Only
, Origin when cross-origin
,
and Unsafe URL
. Each is explained below, and a detailed
algorithm for evaluating their effect is given in the
§5 Integration with Fetch and
§6 Algorithms sections:
Note: The referrer policy for a global environment provides a default
baseline policy for requests. This policy may be tightened for specific
requests via mechanisms like the noreferrer
link type.
The simplest policy is None, which specifies that no referrer information is to be sent along with requests made from a particular global environment to any origin. The header will be omitted entirely.
https://example.com/page.html
sets a policy of
None
, then navigations to https://example.com/
(or any other URL) would send no referer
header.
The None When Downgrade policy sends a full URL along with requests from TLS-protected global environments to a non-a priori insecure origin, and requests from global environments which are not TLS-protected to any origin.
Requests from TLS-protected global environments to a
priori insecure origins, on the other hand, will contain no referrer
information. A referer
will not be sent.
https://example.com/page.html
sets a policy of
None When Downgrade
, then navigations to
https://not.example.com/
would send a
referer
HTTP header with a value of
https://example.com/page.html
, as neither resource’s origin is an
a priori insecure origin.
Navigations from that same page to
http://not.example.com/
would send no
referer
header.
This is a user agent’s default behavior, if no policy is otherwise specified.
The Origin Only policy specifies that only the ASCII serialization of the origin of the global environment from which a request is made is sent as referrer information when making both same-origin requests and cross-origin requests from a particular global environment.
Note: The serialization of an origin looks like
https://example.com
. To ensure that a valid URL is sent in the
`Referer
` header, user agents will append a U+002F SOLIDUS
("/
") character to the origin (e.g.
https://example.com/
).
https://example.com/page.html
sets a policy of
Origin Only
, then navigations to any origin would send a
referer
header with a value of
https://example.com/
, even to a priori insecure
origins.
The Origin When Cross-Origin policy specifies that a full URL, stripped for use as a referrer, is sent as referrer information when making same-origin requests from a particular global environment, and only the ASCII serialization of the origin of the global environment from which a request is made is sent at referrer information when making cross-origin requests from a particular global environment.
Note: For the Origin When Cross-Origin
policy, we also consider
protocol upgrades, e.g. requests from http://exmaple.com/
to
https://example.com/
to be cross-origin requests.
https://example.com/page.html
sets a policy of
Origin When Cross-Origin
, then navigations to any
https://example.com/not-page.html
would send a
referer
header with a value of
https://example.com/page.html
.
Navigations from that same page to https://not.example.com/
would send a referer
header with a value of
https://example.com/
, even to a priori insecure
origins.
The Unsafe URL policy specifies that a full URL, stripped for use as a referrer, is sent along with both cross-origin requests and same-origin requests made from a particular global environment.
https://example.com/sekrit.html
sets a policy
of Unsafe URL
, then navigations to
http://not.example.com/
(and every other origin) would send a
referer
HTTP header with a value of
https://example.com/sekrit.html
.
Note: The policy’s name doesn’t lie; it is unsafe. This policy will leak origins and paths from TLS-protected resources to insecure origins. Carefully consider the impact of setting such a policy for potentially sensitive documents.
A JavaScript global environment’s referrer policy is delivered in one of four ways:
referrer
Content Security Policy directive, delivered via the
Content-Security-Policy
HTTP header. [CSP]
referrer
Content Security Policy directive, delivered via a
<meta>
element
[CSP]
referrer
.
The CSP-based delivery mechanisms are defined in the Content Security Policy specification. [CSP] The meta and implicit mechanisms are defined below.
When an HTML meta
element with a name attribute
that is a case-insensitive match for the string "Referrer
" is
inserted into a document, for example:
<meta name="referrer" content="origin">
Add the following entry to the
pragma directives
for the meta
element:
name="Referrer"
)
head
element is
not an ancestor of the meta
element, abort
these steps.meta
element lacks a
content
attribute, or if that
attribute’s value is the empty string, then abort these steps.
content
attribute, after
stripping
leading and trailing whitespace.
None
Origin
None When Downgrade
Origin When Cross-Origin
Unsafe URL
null
.
Note: Authors are encouraged to avoid the legacy keywords
never
, default
, and always
. The
keywords none
, none-when-downgrade
, and
unsafe-url
respectively are preferred.
A global environment inherits the referrer policy of another environment in several circumstances:
Whenever a user agent creates a nested browsing context containing
an iframe srcdoc document or a resource whose origin’s scheme
is not a relative scheme (for instance, a blob
or
data
resource):
null
.
Whenever a user agent runs a worker: scheme is not a relative scheme:
None when downgrade
The Fetch specification calls out to the
Determine request’s
referrer algorithm as
Step 2 of the
Fetching algorithm, and uses the response to set the request’s
referrer
property. Fetch is responsible for serializing the
URL provided, and setting the `Referer
` header on
request.
If no referrer policy has been set for a global environment, then
setting its value is straightforward. If a policy has previously been set,
however, then we need to deal with potential conflict. We handle conflict
in a draconian fashion: conflicts resolve to None
, as described
below.
None
,
None when downgrade
, Origin Only
,
Origin when cross-origin
, or
Unsafe URL
, then set policy to
None
.null
(that is, if no policy has
been explicitly set), then:
Never
.
Given a Request request, we can determine the correct
referrer information to send by examining the policy associated with
its client
’s global environment, as detailed in the
following steps, which returns either none
or a URL:
Note: If Fetch is performing a navigation in response to a link of type
noreferrer
, then request’s
referrer
will be none
, and Fetch won’t call into
this algorithm.
client
.
referrer
is a URL, then let
referrerSource be request’s
referrer
. Otherwise:
Document
object of the
active document of the browsing context of
environment’s global object.
none
and abort these steps.
Document
.
origin-only flag
set to
true
.
None
none
Origin
Unsafe URL
Origin When Cross-Origin
None When Downgrade
null
URL
is
an a priori insecure origin, then return
none
.
Note: Nothing here should be interpreted as preventing user agents from
offering options to users which would reduce the information sent out via a
`Referer
` header. For instance, user agents MAY allow users to
suppress the referrer header entirely, regardless of the referrer
policy.
Certain portions of URLs MUST not be included when sending a URL as the value
of a `Referer
` header: a URLs fragment, username, and password
components should be stripped from the URL before it’s sent out. This
algorithm accepts a origin-only flag
, which defaults
to false
. If set to true
, the algorithm will
additionally remove the URL’s path and query components, leaving only the
scheme, host, and port.
null
, return none
.
scheme
is not a relative
scheme, then return none
.
username
to the empty string.
password
to null
.
fragment
to null
.
origin-only flag
is true
,
then:
path
to null
.
query
to null
.
This specification is based in large part on Adam Barth and Jochen Eisinger’s Meta referrer document.
Conformance requirements are expressed with a combination of descriptive assertions and RFC 2119 terminology. The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in the normative parts of this document are to be interpreted as described in RFC 2119. However, for readability, these words do not appear in all uppercase letters in this specification.
All of the text of this specification is normative except sections explicitly marked as non-normative, examples, and notes. [RFC2119]
Examples in this specification are introduced with the words "for example"
or are set apart from the normative text with class="example"
,
like this:
This is an example of an informative example.
Informative notes begin with the word "Note" and are set apart from the
normative text with class="note"
, like this:
Note, this is an informative note.
Requirements phrased in the imperative as part of algorithms (such as "strip any leading space characters" or "return false and abort these steps") are to be interpreted with the meaning of the key word ("must", "should", "may", etc) used in introducing the algorithm.
Conformance requirements phrased as algorithms or specific steps can be implemented in any manner, so long as the end result is equivalent. In particular, the algorithms defined in this specification are intended to be easy to understand and are not intended to be performant. Implementers are encouraged to optimize.
A conformant user agent must implement all the requirements listed in this specification that are applicable to user agents.
A conformant server must implement all the requirements listed in this specification that are applicable to servers.