/
index.html
1618 lines (936 loc) · 71 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html lang="en">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Referrer Policy</title>
<link href="../default.css" rel="stylesheet" type="text/css">
<style>
body {
background: url("https://www.w3.org/StyleSheets/TR/logo-ED") top left no-repeat white;
background-attachment: fixed;
color: black;
font-family: sans-serif;
margin: 0 auto;
max-width: 50em;
padding: 2em 1em 2em 70px;
}
:link { color: #00C; background: transparent }
:visited { color: #609; background: transparent }
a[href]:active { color: #C00; background: transparent }
a[href]:hover { background: #ffa }
a[href] img { border-style: none }
h1, h2, h3, h4, h5, h6 { text-align: left }
h1, h2, h3 { color: #005A9C; }
h1 { font: 170% sans-serif }
h2 { font: 140% sans-serif }
h3 { font: 120% sans-serif }
h4 { font: bold 100% sans-serif }
h5 { font: italic 100% sans-serif }
h6 { font: small-caps 100% sans-serif }
.hide { display: none }
div.head { margin-bottom: 1em }
div.head h1 { margin-top: 2em; clear: both }
div.head table { margin-left: 2em; margin-top: 2em }
p.copyright { font-size: small }
p.copyright small { font-size: small }
pre { margin-left: 2em }
dt { font-weight: bold }
ul.toc, ol.toc {
list-style: none;
}
</style>
<meta content="Bikeshed 1.0.0" name="generator">
</head>
<body class="h-entry">
<div class="head">
<p data-fill-with="logo"><a class="logo" href="http://www.w3.org/">
<img alt="W3C" height="48" src="https://www.w3.org/Icons/w3c_home" width="72">
</a>
</p>
<h1 class="p-name no-ref" id="title">Referrer Policy</h1>
<h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">Editor’s Draft,
<time class="dt-updated" datetime="2015-02-10">10 February 2015</time></span></h2>
<div data-fill-with="spec-metadata">
<dl>
<dt>This version:
<dd><a class="u-url" href="https://w3c.github.io/webappsec/specs/referrer-policy/">https://w3c.github.io/webappsec/specs/referrer-policy/</a>
<dt>Latest version:
<dd><a href="http://www.w3.org/TR/referrer-policy/">http://www.w3.org/TR/referrer-policy/</a>
<dt>Version History:
<dd><a href="https://github.com/w3c/webappsec/commits/master/specs/referrer-policy/index.src.html">https://github.com/w3c/webappsec/commits/master/specs/referrer-policy/index.src.html</a>
<dt>Feedback:
<dd><span><a href="mailto:public-webappsec@w3.org?subject=%5BREFERRER%5D%20feedback">public-webappsec@w3.org</a> with subject line “<kbd>[REFERRER] <var>… message topic …</var></kbd>” (<a href="http://lists.w3.org/Archives/Public/public-webappsec/" rel="discussion">archives</a>)</span>
<dt class="editor">Editors:
<dd class="editor">
<div class="p-author h-card vcard"><a class="p-name fn u-email email" href="mailto:eisinger@google.com">Jochen Eisinger</a> (<span class="p-org org">Google Inc.</span>)</div>
<dd class="editor">
<div class="p-author h-card vcard"><a class="p-name fn u-email email" href="mailto:mkwst@google.com">Mike West</a> (<span class="p-org org">Google Inc.</span>)</div>
</dl>
</div>
<div data-fill-with="warning"></div>
<p class="copyright" data-fill-with="copyright"><a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> © 2015 <a href="http://www.w3.org/">
<acronym title="World Wide Web Consortium">W3C</acronym>
</a><sup>®</sup> (<a href="http://www.csail.mit.edu/">
<acronym title="Massachusetts Institute of Technology">MIT</acronym>
</a>, <a href="http://www.ercim.eu/">
<acronym title="European Research Consortium for Informatics and Mathematics">ERCIM</acronym>
</a>, <a href="http://www.keio.ac.jp/">Keio</a>, <a href="http://ev.buaa.edu.cn/">Beihang</a>). W3C <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>, <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a> rules apply.
</p>
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc no-ref heading settled" id="abstract"><span class="content">Abstract</span></h2>
<div class="p-summary" data-fill-with="abstract">
<p>This document describes how an author can set a referrer policy for documents they create, and the impact of such a policy on the <code>Referer</code> HTTP header for outgoing requests and navigations.</p>
</div>
<h2 class="no-num no-toc no-ref heading settled" id="status"><span class="content">Status of this document</span></h2>
<div data-fill-with="status">
<p>
This is a public copy of the editors’ draft.
It is provided for discussion only and may change at any moment.
Its publication here does not imply endorsement of its contents by W3C.
Don’t cite this document other than as work in progress.
</p>
<p>
<strong>Changes to this document may be tracked at
<a href="https://github.com/w3c/webappsec">https://github.com/w3c/webappsec</a>.</strong>
</p>
<p>
The (<a href="http://lists.w3.org/Archives/Public/public-webappsec/">archived</a>) public mailing list
<a href="mailto:public-webappsec@w3.org?Subject=%5BREFERRER%5D%20PUT%20SUBJECT%20HERE">public-webappsec@w3.org</a>
(see <a href="http://www.w3.org/Mail/Request">instructions</a>)
is preferred for discussion of this specification.
When sending e-mail,
please put the text “REFERRER” in the subject,
preferably like this:
“[REFERRER] <em>…summary of comment…</em>”
</p>
<p>
This document was produced by the
<a href="http://www.w3.org/2011/webappsec/">Web Application Security Working Group</a>.
</p>
<p>
This document was produced by a group operating under
the <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February 2004 W3C Patent Policy</a>.
W3C maintains a <a href="http://www.w3.org/2004/01/pp-impl/49309/status" rel="disclosure">public list of any patent disclosures</a>
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 <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential Claim(s)</a>
must disclose the information in accordance with <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section 6 of the W3C Patent Policy</a>.
</p>
<p>
This document is governed by the <a href="http://www.w3.org/2014/Process-20140801/" id="w3c_process_revision">1 August 2014 W3C Process Document</a>.
</p></div>
<div data-fill-with="at-risk"></div>
<h2 class="no-num no-toc no-ref heading settled" id="contents"><span class="content">Table of Contents</span></h2>
<div data-fill-with="table-of-contents" role="navigation">
<ul class="toc" role="directory">
<li><a href="#intro"><span class="secno">1</span> <span class="content">Introduction</span></a>
<ul class="toc">
<li><a href="#intro-privacy"><span class="secno">1.1</span> <span class="content">Privacy</span></a>
<li><a href="#intro-security"><span class="secno">1.2</span> <span class="content">Security</span></a>
<li><a href="#intro-trackback"><span class="secno">1.3</span> <span class="content">Trackback</span></a>
</ul>
<li><a href="#terms"><span class="secno">2</span> <span class="content">Key Concepts and Terminology</span></a>
<ul class="toc">
<li><a href="#terms-defined-here"><span class="secno">2.1</span> <span class="content">Terms defined by this specification</span></a>
<li><a href="#terms-defined-by-reference"><span class="secno">2.2</span> <span class="content">Terms defined by reference</span></a>
</ul>
<li><a href="#referrer-policy-states"><span class="secno">3</span> <span class="content">Referrer Policy States</span></a>
<ul class="toc">
<li><a href="#referrer-policy-state-no-referrer"><span class="secno">3.1</span> <span class="content">No Referrer</span></a>
<li><a href="#referrer-policy-state-no-referrer-when-downgrade"><span class="secno">3.2</span> <span class="content">No Referrer When Downgrade</span></a>
<li><a href="#referrer-policy-state-origin"><span class="secno">3.3</span> <span class="content">Origin Only</span></a>
<li><a href="#referrer-policy-state-origin-when-cross-origin"><span class="secno">3.4</span> <span class="content">Origin When Cross-Origin</span></a>
<li><a href="#referrer-policy-state-unsafe-url"><span class="secno">3.5</span> <span class="content">Unsafe URL</span></a>
</ul>
<li><a href="#referrer-policy-delivery"><span class="secno">4</span> <span class="content">Referrer Policy Delivery</span></a>
<ul class="toc">
<li><a href="#directive-referrer"><span class="secno">4.1</span> <span class="content">Delivery via CSP</span></a>
<ul class="toc">
<li><a href="#referrer-usage"><span class="secno">4.1.1</span> <span class="content">Usage</span></a>
</ul>
<li><a href="#referrer-policy-delivery-meta"><span class="secno">4.2</span> <span class="content">Delivery via <span data-lt="meta">meta</span></span></a>
<li><a href="#referrer-policy-delivery-implicit"><span class="secno">4.3</span> <span class="content">Implicit Delivery</span></a>
<ul class="toc">
<li><a href="#referrer-policy-delivery-implicit-nested"><span class="secno">4.3.1</span> <span class="content">
Nested Browsing Contexts
</span></a>
<li><a href="#referrer-policy-delivery-implicit-workers"><span class="secno">4.3.2</span> <span class="content">
Workers
</span></a>
</ul>
</ul>
<li><a href="#integration-with-fetch"><span class="secno">5</span> <span class="content">Integration with Fetch</span></a>
<li><a href="#algorithms"><span class="secno">6</span> <span class="content">Algorithms</span></a>
<ul class="toc">
<li><a href="#set-referrer-policy"><span class="secno">6.1</span> <span class="content">
Set <var>environment</var>’s referrer policy to <var>policy</var>
</span></a>
<li><a href="#determine-requests-referrer"><span class="secno">6.2</span> <span class="content">
Determine <var>request</var>’s Referrer
</span></a>
<li><a href="#strip-url"><span class="secno">6.3</span> <span class="content">
Strip <var>url</var> for use as a referrer
</span></a>
<li><a href="#determine-policy-for-token"><span class="secno">6.4</span> <span class="content">
Determine <var>token</var>’s Policy
</span></a>
</ul>
<li><a href="#privacy"><span class="secno">7</span> <span class="content">Privacy Considerations</span></a>
<ul class="toc">
<li><a href="#user-controls"><span class="secno">7.1</span> <span class="content">User Controls</span></a>
</ul>
<li><a href="#acknowledgements"><span class="secno">8</span> <span class="content">Acknowledgements</span></a>
<li><a href="#conformance"><span class="secno"></span> <span class="content">Conformance</span></a>
<ul class="toc">
<li><a href="#conventions"><span class="secno"></span> <span class="content">Document conventions</span></a>
<li><a href="#conformant-algorithms"><span class="secno"></span> <span class="content">Conformant Algorithms</span></a>
<li><a href="#conformance-classes"><span class="secno"></span> <span class="content">Conformance Classes</span></a>
</ul>
<li><a href="#references"><span class="secno"></span> <span class="content">References</span></a>
<ul class="toc">
<li><a href="#normative"><span class="secno"></span> <span class="content">Normative References</span></a>
<li><a href="#informative"><span class="secno"></span> <span class="content">Informative References</span></a>
</ul>
<li><a href="#index"><span class="secno"></span> <span class="content">Index</span></a>
</ul></div>
<main>
<section>
<h2 class="heading settled" data-level="1" id="intro"><span class="secno">1. </span><span class="content">Introduction</span><a class="self-link" href="#intro"></a></h2>
<p><em>This section is not normative.</em></p>
<p>Requests made from a document, and for navigations away from that document
are associated with a <a data-link-type="dfn" href="#referer-http-header-field"><code>Referer</code> header</a>. While the header
can be suppressed for links with the <a data-link-type="dfn" href="#noreferrer"><code>noreferrer</code></a> link
type, authors might wish to control the <a data-link-type="dfn" href="#referer-http-header-field"><code>Referer</code> header</a>
more directly for a number of reasons:</p>
<h3 class="heading settled" data-level="1.1" id="intro-privacy"><span class="secno">1.1. </span><span class="content">Privacy</span><a class="self-link" href="#intro-privacy"></a></h3>
<p>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).</p>
<p>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.</p>
<h3 class="heading settled" data-level="1.2" id="intro-security"><span class="secno">1.2. </span><span class="content">Security</span><a class="self-link" href="#intro-security"></a></h3>
<p>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.</p>
<p>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. <a data-link-type="biblio" href="#biblio-capability-urls">[CAPABILITY-URLS]</a></p>
<h3 class="heading settled" data-level="1.3" id="intro-trackback"><span class="secno">1.3. </span><span class="content">Trackback</span><a class="self-link" href="#intro-trackback"></a></h3>
<p>A blog hosted over HTTPS might wish to link to a blog hosted over HTTP and
receive trackback links.</p>
</section>
<section>
<h2 class="heading settled" data-level="2" id="terms"><span class="secno">2. </span><span class="content">Key Concepts and Terminology</span><a class="self-link" href="#terms"></a></h2>
<h3 class="heading settled" data-level="2.1" id="terms-defined-here"><span class="secno">2.1. </span><span class="content">Terms defined by this specification</span><a class="self-link" href="#terms-defined-here"></a></h3>
<dl>
<dt>
<dfn data-dfn-type="dfn" data-export="" data-local-lt="policy" id="referrer-policy">referrer policy<a class="self-link" href="#referrer-policy"></a></dfn>
<dd>
A <strong>referrer policy</strong> is a property of a <a data-link-type="dfn" href="#javascript-global-environment">JavaScript
global environment</a> that defines the algorithm used to populate the
<a data-link-type="dfn" href="#referer-http-header-field"><code>Referer</code> header</a> when <a data-link-type="dfn" href="#fetch">fetching</a> subresources,
prefetching, or performing navigations.
<p>If no referrer policy is explicitly set for a <a data-link-type="dfn" href="#javascript-global-environment">global environment</a>,
then the value of the property is <code>null</code>. Otherwise, the value
is whatever has been explicitly set, as explained in the
<a href="#set-referrer-policy">§6.1
Set environment’s referrer policy to policy
</a> algorithm.</p>
</dl>
<h3 class="heading settled" data-level="2.2" id="terms-defined-by-reference"><span class="secno">2.2. </span><span class="content">Terms defined by reference</span><a class="self-link" href="#terms-defined-by-reference"></a></h3>
<dl>
<dt><dfn data-dfn-type="dfn" data-local-lt="Referer|Referer header" data-noexport="" id="referer-http-header-field">Referer HTTP header field<a class="self-link" href="#referer-http-header-field"></a></dfn>
<dd>
The <strong>"Referer" [sic] HTTP header field</strong> is sent along with
HTTP requests, and informs the server where the reference for the
requested resource was found. It is specified in
<a href="http://tools.ietf.org/html/rfc7231#section-5.5.2">Section 5.5.2</a>
of HTTP/1.1 -- Semantics and Content <a data-link-type="biblio" href="#biblio-rfc7231">[RFC7231]</a>
<dt><dfn data-dfn-type="dfn" data-noexport="" id="origin">origin<a class="self-link" href="#origin"></a></dfn>
<dd>
An origin defines the scope of authority or privilege under which a
resource operates. It is defined in detail in the Origin specification.
<a data-link-type="biblio" href="#biblio-rfc6454">[RFC6454]</a>
<dt><dfn data-dfn-type="dfn" data-noexport="" id="ascii-serialization-of-an-origin">ASCII serialization of an origin<a class="self-link" href="#ascii-serialization-of-an-origin"></a></dfn>
<dd>
This algorithm is defined in
<a href="http://tools.ietf.org/html/rfc6454#section-6.2">Section 6.2</a>
of the Origin specification. <a data-link-type="biblio" href="#biblio-rfc6454">[RFC6454]</a>
<dt><dfn data-dfn-type="dfn" data-noexport="" id="ascii-case_insensitive-match">ASCII case-insensitive match<a class="self-link" href="#ascii-case_insensitive-match"></a></dfn>
<dd>
Two strings are an <strong>ASCII case-insensitive match</strong> if they
match according to the <a data-link-type="dfn" href="http://dev.w3.org/csswg/css-syntax-3/#ascii-case-insensitive">ASCII case-insensitive</a> algorithm defined in
<a data-link-type="biblio" href="#biblio-html5">[HTML5]</a>;
<dt><dfn data-dfn-type="dfn" data-local-lt="same-origin" data-noexport="" id="same_origin-request">same-origin request<a class="self-link" href="#same_origin-request"></a></dfn>
<dd>
A <a data-link-type="dfn" href="#request">request</a> is a <strong>same-origin request</strong> if the
request’s <code>origin</code> and the <a data-link-type="dfn" href="#origin">origin</a> of request’s
<code>url</code> are "the same", as defined by
<a href="http://tools.ietf.org/html/rfc6454#section-5">Section 5</a>
of the Origin specification. <a data-link-type="biblio" href="#biblio-rfc6454">[RFC6454]</a>
<dt><dfn data-dfn-type="dfn" data-local-lt="cross-origin" data-noexport="" id="cross_origin-request">cross-origin request<a class="self-link" href="#cross_origin-request"></a></dfn>
<dd>
A <a data-link-type="dfn" href="#request">request</a> is a <strong>cross-origin request</strong> if it is
<em>not</em> <a data-link-type="dfn" href="#same_origin-request">same-origin</a>.
<dt><dfn data-dfn-type="dfn" data-noexport="" id="fetch">fetch<a class="self-link" href="#fetch"></a></dfn>
<dd>
"fetching" is the process by which a user agent requests resources, and
delivers responses. It is defined in detail in the Fetch living standard.
<a data-link-type="biblio" href="#biblio-fetch">[FETCH]</a>
<dt><dfn data-dfn-type="dfn" data-noexport="" id="request">request<a class="self-link" href="#request"></a></dfn>
<dt><dfn data-dfn-type="dfn" data-lt="request client|client" data-noexport="" id="request-client">request client<a class="self-link" href="#request-client"></a></dfn>
<dt><dfn data-dfn-type="dfn" data-lt="request context|context" data-noexport="" id="request-context">request context<a class="self-link" href="#request-context"></a></dfn>
<dd>
These terms are defined in
<a href="http://fetch.spec.whatwg.org/#requests">Section 2.2</a> of the
Fetch living standard. <a data-link-type="biblio" href="#biblio-fetch">[FETCH]</a>
<dt><dfn data-dfn-type="dfn" data-noexport="" id="a-priori-insecure-origin"><em>a priori</em> insecure origin<a class="self-link" href="#a-priori-insecure-origin"></a></dfn>
<dd>
This term is defined in
<a href="http://w3c.github.io/webappsec/specs/mixedcontent/#a-priori-insecure-origin">Section 2.1</a>
of the Mixed Content specification. <a data-link-type="biblio" href="#biblio-mix">[MIX]</a>.
<dt><dfn data-dfn-type="dfn" data-lt="JavaScript global environment|global environment" data-noexport="" id="javascript-global-environment">JavaScript global environment<a class="self-link" href="#javascript-global-environment"></a></dfn>
<dd>
This term is defined in <a data-link-type="dfn" href="#javascript-global-environment">Section
2.2.2</a> of the HTML5 specification. <a data-link-type="biblio" href="#biblio-html5">[HTML5]</a>
<dt><dfn data-dfn-type="dfn" data-noexport="" id="global-object">global object<a class="self-link" href="#global-object"></a></dfn>
<dd>
This term is defined in the ECMAScript specification. <a data-link-type="biblio" href="#biblio-ecma-262">[ECMA-262]</a>
<dt><dfn data-dfn-type="dfn" data-noexport="" id="document-environment">document environment<a class="self-link" href="#document-environment"></a></dfn>
<dt><dfn data-dfn-type="dfn" data-noexport="" id="worker-environment">worker environment<a class="self-link" href="#worker-environment"></a></dfn>
<dd>
These terms are defined in
<a data-link-type="dfn" href="#document-environment">Section 6.1.3.1</a> of the
HTML5 specification. [[!!HTML5]]
<dt><dfn data-dfn-type="dfn" data-noexport="" id="api-referrer-source">API referrer source<a class="self-link" href="#api-referrer-source"></a></dfn>
<dd>
This term is defined in
<a data-link-type="dfn" href="#api-referrer-source">Section 8.1.3.1</a> of the
HTML5 specification. <a data-link-type="biblio" href="#biblio-html5">[HTML5]</a>
<dt><dfn data-dfn-type="dfn" data-noexport="" id="entry-settings-object">Entry settings object<a class="self-link" href="#entry-settings-object"></a></dfn>
<dd>
This term is defined in
<a data-link-type="dfn" href="#entry-settings-object">Section 8.1.3.3</a> of the
HTML5 specification. <a data-link-type="biblio" href="#biblio-html5">[HTML5]</a>
<dt><dfn data-dfn-type="dfn" data-noexport="" id="tls_protected">TLS-protected<a class="self-link" href="#tls_protected"></a></dfn>
<dd>
This term is defined in
<a href="http://www.w3.org/TR/2010/REC-wsc-ui-20100812/#typesoftls">Section
5.2 of "Web Security Context: User Interface Guidelines"</a>. <a data-link-type="biblio" href="#biblio-wsc-ui">[WSC-UI]</a>.
<dt><dfn data-dfn-type="dfn" data-noexport="" id="relative-scheme">relative scheme<a class="self-link" href="#relative-scheme"></a></dfn>
<dd>
The set of <strong>relative schemes</strong> is defined in
<a href="http://url.spec.whatwg.org/#relative-scheme">Section 5 of the
URL specification</a>. <a data-link-type="biblio" href="#biblio-url">[URL]</a>
<dt><dfn data-dfn-type="dfn" data-noexport="" id="runs-a-worker">runs a worker<a class="self-link" href="#runs-a-worker"></a></dfn> algorithm
<dd>
This algorithm is
<a href="http://www.w3.org/TR/workers/#run-a-worker">defined in the Web
Workers spec</a>. <a data-link-type="biblio" href="#biblio-workers">[WORKERS]</a>
<dt><dfn data-dfn-type="dfn" data-noexport="" id="noreferrer">noreferrer<a class="self-link" href="#noreferrer"></a></dfn> link type
<dd>
This link type is
<a href="http://www.w3.org/TR/html5/links.html#link-type-noreferrer">defined
in HTML</a>. <a data-link-type="biblio" href="#biblio-html5">[HTML5]</a>
</dl>
</section>
<section>
<h2 class="heading settled" data-level="3" id="referrer-policy-states"><span class="secno">3. </span><span class="content">Referrer Policy States</span><a class="self-link" href="#referrer-policy-states"></a></h2>
<p>Every <a data-link-type="dfn" href="#javascript-global-environment">global environment</a> has a <a data-link-type="dfn" href="#referrer-policy">referrer policy</a> which governs
the referrer information sent along with requests made for subresources, and
for navigations. The <a data-link-type="dfn" href="#referrer-policy">policy</a> will be <code>null</code> if no policy has
been set, otherwise it will be one of the following five values:
<code><a data-link-type="dfn" href="#no-referrer">No Referrer</a></code>, <code><a data-link-type="dfn" href="#no-referrer-when-downgrade">No Referrer When
Downgrade</a></code>, <code><a data-link-type="dfn" href="#origin-only">Origin Only</a></code>, <code><a data-link-type="dfn" href="#origin-when-cross_origin">Origin When
Cross-origin</a></code>, and <code><a data-link-type="dfn" href="#unsafe-url">Unsafe URL</a></code>. Each is explained
below, and a detailed algorithm for evaluating their effect is given in the
<a href="#integration-with-fetch">§5 Integration with Fetch</a> and
<a href="#algorithms">§6 Algorithms</a> sections:</p>
<p class="note" role="note">Note: The referrer policy for a <a data-link-type="dfn" href="#javascript-global-environment">global environment</a> provides a default
baseline policy for requests. This policy may be tightened for specific
requests via mechanisms like the <code><a data-link-type="dfn" href="#noreferrer">noreferrer</a></code> link type.</p>
<h3 class="heading settled" data-level="3.1" id="referrer-policy-state-no-referrer"><span class="secno">3.1. </span><span class="content">No Referrer</span><a class="self-link" href="#referrer-policy-state-no-referrer"></a></h3>
<p>The simplest policy is <dfn data-dfn-type="dfn" data-noexport="" id="no-referrer">No Referrer<a class="self-link" href="#no-referrer"></a></dfn>, which specifies that no
referrer information is to be sent along with requests made from a particular
<a data-link-type="dfn" href="#javascript-global-environment">global environment</a> to any <a data-link-type="dfn" href="#origin">origin</a>. The header will be omitted
entirely.</p>
<div class="example">
If a document at <code>https://example.com/page.html</code> sets a policy of
<code>No Referrer</code>, then navigations to
<code>https://example.com/</code> (or any other URL) would send no
<a data-link-type="dfn" href="#referer-http-header-field"><code>Referer</code> header</a>.
</div>
<h3 class="heading settled" data-level="3.2" id="referrer-policy-state-no-referrer-when-downgrade"><span class="secno">3.2. </span><span class="content">No Referrer When Downgrade</span><a class="self-link" href="#referrer-policy-state-no-referrer-when-downgrade"></a></h3>
<p>The <dfn data-dfn-type="dfn" data-noexport="" id="no-referrer-when-downgrade">No Referrer When Downgrade<a class="self-link" href="#no-referrer-when-downgrade"></a></dfn> policy sends a full URL along with
requests from <a data-link-type="dfn" href="#tls_protected">TLS-protected</a> <a data-link-type="dfn" href="#javascript-global-environment">global environments</a> to a
non-<a data-link-type="dfn" href="#a-priori-insecure-origin"><em>a priori</em> insecure origin</a>, and requests from <a data-link-type="dfn" href="#javascript-global-environment">global
environments</a> which are <em>not</em> <a data-link-type="dfn" href="#tls_protected">TLS-protected</a> to any
<a data-link-type="dfn" href="#origin">origin</a>.</p>
<p>Requests from <a data-link-type="dfn" href="#tls_protected">TLS-protected</a> <a data-link-type="dfn" href="#javascript-global-environment">global environments</a> to <a data-link-type="dfn" href="#a-priori-insecure-origin"><em>a
priori</em> insecure origins</a>, on the other hand, will contain no referrer
information. A <code><a data-link-type="dfn" href="#referer-http-header-field">Referer</a></code> HTTP header will not be sent.</p>
<div class="example">
If a document at <code>https://example.com/page.html</code> sets a policy of
<code>No Referrer When Downgrade</code>, then navigations to
<code>https://not.example.com/</code> would send a
<code><a data-link-type="dfn" href="#referer-http-header-field">Referer</a></code> HTTP header with a value of
<code>https://example.com/page.html</code>, as neither resource’s origin is an
<a data-link-type="dfn" href="#a-priori-insecure-origin"><em>a priori</em> insecure origin</a>.
<p>Navigations from that same page to
<code><strong>http</strong>://not.example.com/</code> would send no
<a data-link-type="dfn" href="#referer-http-header-field"><code>Referer</code> header</a>.</p>
</div>
<p>This is a user agent’s default behavior, if no policy is otherwise specified.</p>
<h3 class="heading settled" data-level="3.3" id="referrer-policy-state-origin"><span class="secno">3.3. </span><span class="content">Origin Only</span><a class="self-link" href="#referrer-policy-state-origin"></a></h3>
<p>The <dfn data-dfn-type="dfn" data-noexport="" id="origin-only">Origin Only<a class="self-link" href="#origin-only"></a></dfn> policy specifies that only the
<a data-link-type="dfn" href="#ascii-serialization-of-an-origin">ASCII serialization</a> of the
<a data-link-type="dfn" href="#origin">origin</a> of the <a data-link-type="dfn" href="#javascript-global-environment">global environment</a> from which a request is
made is sent as referrer information when making both <a data-link-type="dfn" href="#same_origin-request">same-origin
requests</a> and <a data-link-type="dfn" href="#cross_origin-request">cross-origin requests</a> from a particular
<a data-link-type="dfn" href="#javascript-global-environment">global environment</a>.</p>
<p class="note" role="note">Note: The serialization of an origin looks like
<code>https://example.com</code>. To ensure that a valid URL is sent in the
`<code>Referer</code>` header, user agents will append a U+002F SOLIDUS
("<code>/</code>") character to the origin (e.g.
<code>https://example.com/</code>).</p>
<p class="note" role="note">Note: The <code>Origin Only</code> policy causes the origin of HTTPS referrers
to be sent over the network as part of unencrypted HTTP requests.</p>
<div class="example">
If a document at <code>https://example.com/page.html</code> sets a policy of
<code>Origin Only</code>, then navigations to any <a data-link-type="dfn" href="#origin">origin</a> would send a
<a data-link-type="dfn" href="#referer-http-header-field"><code>Referer</code> header</a> with a value of
<code>https://example.com/</code>, even to <a data-link-type="dfn" href="#a-priori-insecure-origin"><em>a priori</em> insecure
origins</a>.
</div>
<h3 class="heading settled" data-level="3.4" id="referrer-policy-state-origin-when-cross-origin"><span class="secno">3.4. </span><span class="content">Origin When Cross-Origin</span><a class="self-link" href="#referrer-policy-state-origin-when-cross-origin"></a></h3>
<p>The <dfn data-dfn-type="dfn" data-noexport="" id="origin-when-cross_origin">Origin When Cross-Origin<a class="self-link" href="#origin-when-cross_origin"></a></dfn> policy specifies that a full URL,
<a href="#strip-url">stripped for use as a referrer</a>, is sent as referrer
information when making <a data-link-type="dfn" href="#same_origin-request">same-origin requests</a> from a particular
<a data-link-type="dfn" href="#javascript-global-environment">global environment</a>, and only the
<a data-link-type="dfn" href="#ascii-serialization-of-an-origin">ASCII serialization</a> of the
<a data-link-type="dfn" href="#origin">origin</a> of the <a data-link-type="dfn" href="#javascript-global-environment">global environment</a> from which a request is
made is sent as referrer information when making <a data-link-type="dfn" href="#cross_origin-request">cross-origin requests</a>
from a particular <a data-link-type="dfn" href="#javascript-global-environment">global environment</a>.</p>
<p class="note" role="note">Note: For the <code>Origin When Cross-Origin</code> policy, we also consider
protocol upgrades, e.g. requests from <code>http://example.com/</code> to
<code>https://example.com/</code> to be <a data-link-type="dfn" href="#cross_origin-request">cross-origin requests</a>.</p>
<p class="note" role="note">Note: The <code>Origin When Cross-Origin</code> policy causes the origin of
HTTPS referrers to be sent over the network as part of unencrypted HTTP
requests.</p>
<div class="example">
If a document at <code>https://example.com/page.html</code> sets a policy of
<code>Origin When Cross-Origin</code>, then navigations to any
<code>https://example.com/not-page.html</code> would send a
<a data-link-type="dfn" href="#referer-http-header-field"><code>Referer</code> header</a> with a value of
<code>https://example.com/page.html</code>.
<p>Navigations from that same page to <code>https://not.example.com/</code>
would send a <a data-link-type="dfn" href="#referer-http-header-field"><code>Referer</code> header</a> with a value of
<code>https://example.com/</code>, even to <a data-link-type="dfn" href="#a-priori-insecure-origin"><em>a priori</em> insecure
origins</a>.</p>
</div>
<h3 class="heading settled" data-level="3.5" id="referrer-policy-state-unsafe-url"><span class="secno">3.5. </span><span class="content">Unsafe URL</span><a class="self-link" href="#referrer-policy-state-unsafe-url"></a></h3>
<p>The <dfn data-dfn-type="dfn" data-noexport="" id="unsafe-url">Unsafe URL<a class="self-link" href="#unsafe-url"></a></dfn> policy specifies that a full URL,
<a href="#strip-url">stripped for use as a referrer</a>, is sent along with
both <a data-link-type="dfn" href="#cross_origin-request">cross-origin requests</a> and <a data-link-type="dfn" href="#same_origin-request">same-origin requests</a> made from
a particular <a data-link-type="dfn" href="#javascript-global-environment">global environment</a>.</p>
<div class="example">
If a document at <code>https://example.com/sekrit.html</code> sets a policy
of <code>Unsafe URL</code>, then navigations to
<code>http://not.example.com/</code> (and every other origin) would send a
<code><a data-link-type="dfn" href="#referer-http-header-field">Referer</a></code> HTTP header with a value of
<code>https://example.com/sekrit.html</code>.
</div>
<p class="note" role="note">Note: The policy’s name doesn’t lie; it is unsafe. This policy will leak
origins and paths from <a data-link-type="dfn" href="#tls_protected">TLS-protected</a> resources to insecure origins.
Carefully consider the impact of setting such a policy for potentially
sensitive documents.</p>
</section>
<section>
<h2 class="heading settled" data-level="4" id="referrer-policy-delivery"><span class="secno">4. </span><span class="content">Referrer Policy Delivery</span><a class="self-link" href="#referrer-policy-delivery"></a></h2>
<p>A <a data-link-type="dfn" href="#javascript-global-environment">JavaScript global environment</a>’s <a data-link-type="dfn" href="#referrer-policy">referrer policy</a> is delivered
in one of four ways:</p>
<ul>
<li>
Via the <code>referrer</code> Content Security Policy directive (defined
in <a href="#directive-referrer">§4.1 Delivery via CSP</a>), delivered via the
<a href="https://w3c.github.io/webappsec/specs/content-security-policy/#content-security-policy-header-field"><code>Content-Security-Policy</code></a>
HTTP header. <a data-link-type="biblio" href="#biblio-csp">[CSP]</a>
<li>
Via the <code>referrer</code> Content Security Policy directive (defined
in <a href="#directive-referrer">§4.1 Delivery via CSP</a>), delivered via a
<a href="https://w3c.github.io/webappsec/specs/content-security-policy/#delivery-html-meta-element"><code><meta></code> element</a>
<a data-link-type="biblio" href="#biblio-csp">[CSP]</a>
<li>
Via a <code><a data-link-type="element" href="https://html.spec.whatwg.org/#meta">meta</a></code> element with a <code><a data-link-type="element-attr" href="http://www.w3.org/TR/html5/document-metadata.html#attr-meta-name">name</a></code> of <code>referrer</code>.
<li>
Implicitly, via inheritance.
</ul>
<h3 class="heading settled" data-level="4.1" id="directive-referrer"><span class="secno">4.1. </span><span class="content">Delivery via CSP</span><a class="self-link" href="#directive-referrer"></a></h3>
<p>The <code><dfn data-dfn-type="dfn" data-lt="referrer directive" data-noexport="" id="referrer-directive">referrer<a class="self-link" href="#referrer-directive"></a></dfn></code> directive
specifies the referrer policy that the user agent applies when determining
what referrer information should be included with requests made, and with
<a data-link-type="dfn" href="http://www.w3.org/TR/html5/browsers.html#browsing-context">browsing contexts</a> created from the context of the protected resource.
The syntax for the name and value of the directive are described by the
following ABNF grammar:</p>
<pre>directive-name = "referrer"
directive-value = "no-referrer" / "no-referrer-when-downgrade" / "origin" / "origin-when-cross-origin" / "unsafe-url"
</pre>
<p class="note" role="note">Note: The directive name does not share the HTTP header’s misspelling.</p>
<p>When
<a href="https://w3c.github.io/webappsec/specs/content-security-policy/#enforce">enforcing</a>
the <code>referrer</code> directive, the user agent MUST execute
<a href="#set-referrer-policy">§6.1
Set environment’s referrer policy to policy
</a> on the protected resource’s <a data-link-type="dfn" href="http://www.w3.org/TR/html5/webappapis.html#incumbent-settings-object">incumbent settings
object</a>, using the result of executing <a href="#determine-policy-for-token">§6.4
Determine token’s Policy
</a>
on the <code>referrer</code> directive’s value.</p>
<section class="informative">
<h4 class="heading settled" data-level="4.1.1" id="referrer-usage"><span class="secno">4.1.1. </span><span class="content">Usage</span><a class="self-link" href="#referrer-usage"></a></h4>
<p><em>This section is not normative.</em></p>
<p>A protected resource can prevent referrer leakage by specifying
<code>no-referrer</code> as the value of its policy’s
<code>referrer</code> directive:</p>
<pre>Content-Security-Policy: referrer no-referrer;
</pre>
<p>This will cause all requests made from the protected resource’s
context to have an empty <code>Referer</code> [sic] header.</p>
</section>
<h3 class="heading settled" data-level="4.2" id="referrer-policy-delivery-meta"><span class="secno">4.2. </span><span class="content">Delivery via <a data-link-type="element" href="https://html.spec.whatwg.org/#meta">meta</a></span><a class="self-link" href="#referrer-policy-delivery-meta"></a></h3>
<p>A referrer policy may be set when an HTML <code><a data-link-type="element" href="https://html.spec.whatwg.org/#meta">meta</a></code>
element with a name attribute that is an <a data-link-type="dfn" href="#ascii-case_insensitive-match">ASCII case-insensitive match</a>
for the string "<code>Referrer</code>" is inserted into a document, for
example:</p>
<pre class="example"><meta name="referrer" content="origin">
</pre>
<p>The following values for the <code>content</code> attribute are valid, and map
to the listed <a data-link-type="dfn" href="#referrer-policy">referrer policy</a> values:</p>
<dl>
<dt>no-referrer
<dd><a data-link-type="dfn" href="#no-referrer"><code>No Referrer</code></a>
<dt>origin
<dd><a data-link-type="dfn" href="#origin"><code>Origin</code></a>
<dt>no-referrer-when-downgrade
<dd><a data-link-type="dfn" href="#no-referrer-when-downgrade"><code>No Referrer When Downgrade</code></a>
<dt>origin-when-crossorigin
<dd><a data-link-type="dfn" href="#origin-when-cross_origin"><code>Origin When Cross-Origin</code></a>
<dt>unsafe-url
<dd><a data-link-type="dfn" href="#unsafe-url"><code>Unsafe URL</code></a>
</dl>
<p>Add the following entry to the
<a href="http://www.w3.org/TR/html5/document-metadata.html#pragma-directives">pragma directives</a>
for the <code><a data-link-type="element" href="https://html.spec.whatwg.org/#meta">meta</a></code> element:</p>
<dl>
<dt>
Referrer policy
(<code>name="Referrer"</code>)
<dd>
<ol>
<li>If the Document’s <code><a data-link-type="element" href="https://html.spec.whatwg.org/#the-head-element">head</a></code> element is
not an ancestor of the <code><a data-link-type="element" href="https://html.spec.whatwg.org/#meta">meta</a></code> element, abort
these steps.
<li>
If the <code><a data-link-type="element" href="https://html.spec.whatwg.org/#meta">meta</a></code> element lacks a
<code><a data-link-type="element-attr" href="https://html.spec.whatwg.org/#attr-meta-content">content</a></code> attribute then abort these
steps.
<li>
Let <var>environment</var> be the <a data-link-type="dfn" href="#javascript-global-environment">global environment</a> associated
with the Document.
<li>
Let <var>meta-value</var> be the value of the element’s
<code><a data-link-type="element-attr" href="https://html.spec.whatwg.org/#attr-meta-content">content</a></code> attribute, after
<a data-link-type="dfn" href="http://www.w3.org/TR/html5/infrastructure.html#strip-leading-and-trailing-whitespace">stripping
leading and trailing whitespace</a>.
<li>
If <var>meta-value</var> is the empty string, then abort these steps.
<li>
Let <var>policy</var> be the result of executing the
<a href="#determine-policy-for-token">§6.4
Determine token’s Policy
</a> algorithm on <var>meta-value</var>.
<li>
Execute the <a href="#set-referrer-policy">§6.1
Set environment’s referrer policy to policy
</a> algorithm on
<var>environment</var> using <var>policy</var>, if <var>policy</var>
is not <code>null</code>.
</ol>
<p class="note" role="note">Note: Authors are encouraged to avoid the legacy keywords
<code>never</code>, <code>default</code>, and <code>always</code>. The
keywords <code>no-referrer</code>,
<code>no-referrer-when-downgrade</code>, and <code>unsafe-url</code>
respectively are preferred.</p>
<p class="note" role="note">Note: Implementors are advised to also respect a <a data-link-type="dfn" href="#referrer-policy">referrer policy</a>
delivered via a <code><a data-link-type="element" href="https://html.spec.whatwg.org/#meta">meta</a></code> element during
speculative resource loads.</p>
</dl>
<h3 class="heading settled" data-level="4.3" id="referrer-policy-delivery-implicit"><span class="secno">4.3. </span><span class="content">Implicit Delivery</span><a class="self-link" href="#referrer-policy-delivery-implicit"></a></h3>
<p>A <a data-link-type="dfn" href="#javascript-global-environment">global environment</a> inherits the <a data-link-type="dfn" href="#referrer-policy">referrer policy</a> of another
environment in several circumstances:</p>
<h4 class="heading settled" data-level="4.3.1" id="referrer-policy-delivery-implicit-nested"><span class="secno">4.3.1. </span><span class="content">
Nested Browsing Contexts
</span><a class="self-link" href="#referrer-policy-delivery-implicit-nested"></a></h4>
<p>Whenever a user agent creates a <a data-link-type="dfn" href="http://www.w3.org/TR/html5/browsers.html#nested-browsing-context">nested browsing context</a> containing
<a data-link-type="dfn" href="http://www.w3.org/TR/html5/embedded-content-0.html#an-iframe-srcdoc-document">an iframe srcdoc document</a> or a resource whose <a data-link-type="dfn" href="#origin">origin</a>’s scheme
is not a <a data-link-type="dfn" href="#relative-scheme">relative scheme</a> (for instance, a <code>blob</code> or
<code>data</code> resource):</p>
<ol>
<li>
Let <var>environment</var> be the <a data-link-type="dfn" href="http://www.w3.org/TR/html5/browsers.html#nested-browsing-context">nested browsing context</a>’s
<a data-link-type="dfn" href="#javascript-global-environment">JavaScript global environment</a>.
<li>
Let <var>policy</var> be the <a data-link-type="dfn" href="http://www.w3.org/TR/html5/browsers.html#parent-browsing-context">parent browsing context</a>’s
<a data-link-type="dfn" href="#javascript-global-environment">JavaScript global environment</a>’s <a data-link-type="dfn" href="#referrer-policy">referrer policy</a>.
<li>
Execute the <a href="#set-referrer-policy">§6.1
Set environment’s referrer policy to policy
</a> algorithm on
<var>environment</var> using <var>policy</var>, if <var>policy</var>