This repository was archived by the owner on May 19, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDifferentTakeOnOE.html
More file actions
1324 lines (1218 loc) · 60.3 KB
/
DifferentTakeOnOE.html
File metadata and controls
1324 lines (1218 loc) · 60.3 KB
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>
<head>
<title>Getting to 100% secure with an "https-transitional" mode.</title>
<style>
body {
font-family: Roboto, sans-serif;
background: #fff;
}
h1, h2 {
font-weight: 600;
}
h3 {
font-weight: 600;
}
circle {
fill-opacity: .5;
stroke: black;
stroke-width: 1;
}
circle.packingGroup {
fill-opacity: .2;
fill: none;
stroke: none;
}
.resource {
fill-opacity: 1;
}
text {
font: 12px sans-serif;
}
.https {
fill: #8f8;
}
.http {
fill: #f88;
}
.mixed {
fill: #ff8;
}
.transitional {
fill: #88f;
}
.hyperlinkText {
fill: #f00;
font-weight: 800;
font-size: 20px;
}
.http_to_transitional {
animation-duration: 2s;
animation-name: http_to_transitional;
-webkit-animation-duration: 2s;
-webkit-animation-name: http_to_transitional;
}
.http_to_https {
animation-duration: 2s;
animation-name: http_to_https;
-webkit-animation-duration: 2s;
-webkit-animation-name: http_to_https;
}
@keyframes http_to_transitional {
from {
fill: #f88;
}
to {
fill: #88f;
}
}
@keyframes http_to_https {
from {
fill: #f88;
}
to {
fill: #8f8;
}
}
@-webkit-keyframes http_to_transitional {
from {
fill: #f88;
}
to {
fill: #88f;
}
}
@-webkit-keyframes http_to_https {
from {
fill: #f88;
}
to {
fill: #8f8;
}
}
.hyperlink {
fill: none;
}
.hyperlink.http {
stroke-width: 1.5px;
stroke: #fff;
}
.hyperlink.https {
stroke-width: 1.5px;
stroke: #000;
}
.hyperlink.underlay {
fill: none;
stroke: #000;
/* setting the underlay stroke slightly less than the overlay reduces
anti-aliasing artifacts with the dashed line but introduces some
jaggies to solid lines. no way to really win here.*/
stroke-width: 1.2px;
}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
</head>
<body>
<script>
function drawFigure(targetName, data) {
var targetNode = document.getElementById(targetName);
var jsonData = JSON.parse(document.getElementById(data).textContent);
// set default sizes for resources for packing if not
// explicitly set: container diameter = 80, item = 15
jsonData.origins.forEach( function(rsc) {
if(!rsc.size) { rsc.size = 80; }
rsc.children.forEach( function(child) {
if(!child.size) { child.size = 15; }
});
});
var width = targetNode.getBoundingClientRect().width,
height = targetNode.getBoundingClientRect().height;
var svg = d3.select(targetNode).append("svg")
.attr("width", width)
.attr("height", height);
// Per-type markers, as they don't inherit styles.
svg.append("defs").selectAll("marker")
.data(["http", "https", "transitional"])
.enter().append("marker")
.attr("id", function(d) { return d; })
.attr("viewBox", "0 -5 10 10")
// TODO can we adjust based on target radius?
.attr("refX", 26)
.attr("refY", -1.5)
.attr("markerWidth", 8)
.attr("markerHeight", 6)
.attr("orient", "auto")
.append("path")
.attr("d", "M0,-5L10,0L0,5");
// build origin containers and layout first
var origin = svg.append("g").selectAll(".node")
.data(jsonData.origins)
.enter().append("g")
.attr("transform", function(d) {
return "translate("+ d.x +","+ d.y +")"
})
.attr("state", function(d) {
return d.state;
})
.attr("id", function(d) {
return targetName + "_origins_" + d.name;
});
origin.append("circle")
.attr("x", 0)
.attr("y", 0)
.attr("r", function(d) { return d.size; })
.attr("class", function(d) { return d.state + " " + d.name; });
origin.append("text")
.style("text-anchor", "middle")
.text(function(d) {
return (d.state == "transitional" ? "http" : d.state)
+ "://" + d.name;
})
.attr("transform", function(d) {
return "translate(0," + -(d.size + 5) + ")";
});
// insert hyperlinks after origins, before resources.
// draw two paths - an underlay and an identical path
// on top, which allows us to create either dashed
// or solid patterns with just CSS (set color of
// overlay and underlay the same for a solid line,
// or different colors for a dashed line)
var hyperlink_underlay = svg.append("g").selectAll("path")
.data(jsonData.links)
.enter().append("path")
.attr("class", "hyperlink underlay");
var hyperlink = svg.append("g").selectAll("path")
.data(jsonData.links)
.enter().append("path")
.attr("id", function(d) {
return targetName + "_hyperlinks_" +
d.fromResource + "_to_" + d.toResource;
})
.attr("stroke-dasharray", "5,5")
.attr("class", function(d) {
return "hyperlink " + (d.scheme ? d.scheme : "")
})
.attr("marker-end", function(d) {
return "url(#" + d.scheme + ")";
});
var hyperlink_text = svg.append("g").selectAll("text")
.data(jsonData.links)
.enter().append("text")
.attr("class", "hyperlinkText")
.style("text-anchor", "middle")
.append("textPath")
.attr("startOffset", "50%")
.attr("xlink:href", function(d) {
return "#" + targetName + "_hyperlinks_" +
d.fromResource + "_to_" + d.toResource
})
.append("tspan")
.attr("dy", "7")
.text(function(d) {
if (d.mixed) {
return "X";
} else {
return "";
}
});
// we need to insert the links before the resources so
// they are underneath, but we don't know the layout
// yet of the nodes they're connecting, so do the
// resource layout then call hyperlinkArc() to
// draw the actual connections.
// TODO - can we do this in a more literate style
// using d3 selectors and third normal form for the
// data structure?
// layout the resources with circle packing inside
// their origin.
var resources = jsonData.origins;
for(var i = 0; i < resources.length; i++) {
var originNode = d3.select("#" + targetName + "_origins_" + resources[i].name)
.node();
var pack = d3.layout.pack()
.padding(30)
.size([150, 150])
.value(function(d) { return d.size; });
var g = svg.append("g")
.attr("transform", originNode.attributes.transform.value);
var pnode = g.datum(resources[i]).selectAll(".node")
.data(pack.nodes)
.enter().append("g")
.attr("transform", function(d) {
return "translate(" + (d.x - 75) + "," + (d.y - 75) + ")";
});
pnode.append("circle")
.attr("r", function(d) { return d.size; })
.attr("id", function(d) {
return targetName + "_resources_" +
(d.id ? d.id : "packingGroup");
})
.attr("class", function(d) {
var depthClass = d.depth > 0 ? "resource" : "packingGroup";
var stateClass = d.depth == 0 ? "" :
(d.state ? d.state : originNode.attributes.state.value);
var originClass = d.depth == 0 ? "" : resources[i].name;
return depthClass + " " + stateClass + " " + originClass;
});
pnode.filter(function(d) { return d.depth > 0; }).append("text")
.attr("dy", ".3em")
.style("text-anchor", "middle")
.text(function(d) { return d.name.substring(0, d.r / 3); })
}
svg.selectAll(".hyperlink").attr("d", hyperlinkArc);
function hyperlinkArc(d) {
var target = d3.select("#" + targetName + "_resources_" + d.toResource)
.node();
var source = d3.select("#" + targetName + "_resources_" + d.fromResource)
.node();
// This is the magic to find our target node position
// and still draw links at the right render depth.
// (not as childern inheriting the <g> transform,
// which would put them on top) Get the bounding
// rectangle and the coordinate transformation matrix
// and apply these to find the "true" center of each
// resource circle.
var offset = svg.node().getBoundingClientRect();
var tMatrix = target.getScreenCTM();
var sMatrix = source.getScreenCTM();
var sCoords = getXformedCoords(
source.cx.baseVal.value, source.cy.baseVal.value, offset, sMatrix);
var tCoords = getXformedCoords(
target.cx.baseVal.value, target.cy.baseVal.value, offset, tMatrix);
var dx = tCoords.x - sCoords.x,
dy = tCoords.y - sCoords.y,
dr = Math.sqrt(dx * dx + dy * dy);
return "M" + sCoords.x + "," + sCoords.y +
"A" + dr + "," + dr + " 0 0,1 " +
tCoords.x + "," + tCoords.y;
};
function getXformedCoords(x, y, offset, matrix) {
return {
x: (matrix.a * x) + (matrix.c * y) +
matrix.e - offset.left,
y: (matrix.b * x) + (matrix.d * y) +
matrix.f - offset.top
}
}
}
</script>
<h1>
Why isn't HTTPS everywhere yet?
</h1>
<p>
Encryption. We all like it and want more of it. Why isn't HTTPS
everywhere yet?
</p>
<h2>
Is it certificates?
</h2>
<p>
The first and most commonly cited barrier to HTTPS everywhere is
the cost (both time and effort) of
obtaining, configuring, presenting and maintaining a valid
certificate. You must find a certificate authority, prove your
identity, pay for a certificate, set it up on your server (you
probably need to have a dedicated IPv4 address to support old
clients that don't do Server Name Indication, but that's a
different issue) and renew it before it expires.
</p>
<p>
Most proposals for "opportunistic" encryption are targeted
at this level of the problem, and amount to: "The NSA is
recording all of our traffic, so why don't we just encrypt even if
we don't have a certificate?" The goal of such proposals is to
raise the cost of passive bulk surveillance, not to address more
sophisticated or targeted attacks by active network attackers.
</p>
<p>
I appreciate the spirit of this solution, but I have come
to believe it is actually targeting the wrong obstacles. First, because
this flavor of OE lacks authentication even when it appears to
succeed, it doesn't offer any guarantees that other resources can
build meaningful security contracts with. Since users
and resource authors who also care about active attackers can never
rely on it, even optimistically, it doesn't remove any obstacles or
provide a meaningfully improved upgrade path to a Web that is
comprehensively secure against both active and passive adversaries.
Second, I don't think the certificate problem is actually the
biggest challenge blocking HTTPS everywhere anymore.
</p>
<p>
The fine folks over at
<a href="https://letsencrypt.org/">Let's Encrypt</a>
already realized that the
certficate problem is mostly amenable to automation, and that
automating the issuance, installation, configuration, deployment
and renewal of certificates and TLS on a relatively few of the major
servers+platforms can cover a substantial supermajority of the
Internet. This is amazing work, and while there is still much of
that race left to be run, I think we can optimistcally call it a
solved problem.
</p>
<h2>
Now we have a certificate, we can turn on HTTPS, right?
</h2>
<p>
Well, maybe. But probably not. If all of the HTML resources you
serve have subresources (images, scripts, etc.) loaded from the
same host AND you used only relative urls (e.g. "/foo.jpg" instead
of "http://example.com/foo.jpg") then you are good to go! Otherwise
things are probably broken for you at your "https://" URLs.
</p>
<p>
<i>Wait, what? HTTPS is supposed to be good. Why is everything
broken?</i>
</p>
<p>
It's broken because you almost certainly have
<a href="http://w3.org/TR/mixed-content">Mixed Content</a>
in your pages.
</p>
<h2>What is Mixed Content and why should I care?</h2>
<p>
Mixed Content is the term that has arisen out of practice
for the situation when a document loaded over https includes content
loaded over http.
</p>
<p>
Consider the following set of resources, where you are the operator
of "OriginA". Green circles represent resources avialable over
both https and http schemes, red circles represent resources only
available over http schemes. Dashed lines represent subresource
includes made with an http scheme. Solid lines represent subresource
includes made with an https scheme. Assume that all links are absolute,
not relative. A red "X" indicates a resource load that will fail.
</p>
<script id="figure2data" type="application/json">
{
"origins" : [
{
"name": "OriginA",
"x": 300,
"y": "100",
"state": "http",
"children" : [
{"name" : "HTML", "id" : "1", "size" : 18},
{"name" : "JS", "id" : "2" },
{"name" : "JPG", "id" : "3" }
]
},
{
"name": "OriginB",
"x": 200,
"y": "300",
"state": "http",
"children" : [
{"name" : "HTML", "id" : "4", "size" : 18},
{"name" : "JSON", "id" : "5"},
{"name" : "JS", "id" : "6"}
]
},
{
"name": "OriginC",
"x": 100,
"y": "100",
"state": "https",
"children" : [
{"name" : "JS", "id" : "10"}
]
}
],
"links": [
{"fromResource": "1", "toResource":"2", "scheme":"http"},
{"fromResource": "1", "toResource":"3", "scheme":"http"},
{"fromResource": "1", "toResource":"6", "scheme":"http"},
{"fromResource": "1", "toResource":"10", "scheme":"http"}
]
}
</script>
<div id="figure2" style="height: 425px"></div>
<script>drawFigure("figure2", "figure2data");</script>
<p>
Now let's say you acquire a certificate and turn on https for OriginA.
What does the resource graph look like now?
</p>
<script id="figure3data" type="application/json">
{
"origins" : [
{
"name": "OriginA",
"x": 300,
"y": "100",
"state": "https",
"children" : [
{"name" : "HTML", "id" : "1", "size" : 18, "state" : "mixed"},
{"name" : "JS", "id" : "2" },
{"name" : "JPG", "id" : "3" }
]
},
{
"name": "OriginB",
"x": 200,
"y": "300",
"state": "http",
"children" : [
{"name" : "HTML", "id" : "4", "size" : 18},
{"name" : "JSON", "id" : "5"},
{"name" : "JS", "id" : "6"}
]
},
{
"name": "OriginC",
"x": 100,
"y": "100",
"state": "https",
"children" : [
{"name" : "JS", "id" : "10"}
]
}
],
"links": [
{"fromResource": "1", "toResource":"2", "scheme":"http", "mixed":true},
{"fromResource": "1", "toResource":"3", "scheme":"http", "mixed":true},
{"fromResource": "1", "toResource":"6", "scheme":"http", "mixed":true},
{"fromResource": "1", "toResource":"10", "scheme":"http", "mixed":true}
]
}
</script>
<div id="figure3" style="height: 400px"></div>
<script>drawFigure("figure3", "figure3data");</script>
<p>
If you haven't updated absolute links in the HTML document, it will
still be attempting to load all of its resources with an http scheme.
Most web browsers block such loads or give negative UI feedback when
they occur, and they have been getting more and more strict about it
over time. The HTML resource at OriginA will be broken because
attempts to load the three JS resources it depends on will be blocked,
and it will be marked with a mixed content warning for the JPG, even
if we didn't have the JS resources. Note that even though some
resources are available over https, because the existing links use
the http scheme, they will still fail.
</p>
<h3>
Why do browsers block mixed content loads?
Why can't I as a site operator make that decision?
</h3>
<p>
In most of the Web security model, Origins (the scheme+host+port
tuple of a URL) are authoritative for their own information. A
document loaded from HTTPS can navigate the user to an insecure
destination with sensitive data in the GET string or fragment,
it can POST or postMessage() to insecure schemes or origins, and
an https resource can receive GET, POST or onMessage() from documents
loaded over http. So, if we don't have formal information flow controls
on the Web, why is Mixed Content Blocking a thing? If I can POST,
why can't I XHR?
</p>
<p>
It turns out there is one formal security property that
browsers try to enforce on documents. That is a property
first formulated as <i>"Tranquility"</i> by
<a href="https://en.wikipedia.org/wiki/Bell%E2%80%93LaPadula_model">
Bell and LaPadula in their 1973 integrity model.</a>
In simple terms, the tranquility enforced by web browsers is that
a secure document will not become insecure while you are interacting
with it.
</p>
<p>
Among all the complexity and
potential pitfalls of Web security, browsers have come to
the conclusion that there is only one semi-reliable and usable security
indicator: the URL bar and HTTPS lock. If you type "https://" into
the address bar, or at any point check to see if there is a lock
icon for the document you are interacting with, the browser has made
you a promise that the content is protected from threats involving a
hostile network. Another way to look at it is that, the browser is
conveying a promise to the user from the site operator which it is
unwilling to let it reneg on. Site operators may also expect and
rely on browsers to fulfill this promise, so one typo or missed link
by a single developer somewhere doesn't undo all the hard work they've
done to provide a secure experience for their users.
</p>
<p>
If your https
document were to load a script, perform a fetch or even load an image
over http, that promise would be broken. How broken and what the
exact consequences would be
might vary widely, but the browser isn't in a position to know, and
doesn't want to impose the burden of that subtlety on the user, so
they simply block. This is done not only to protect users who
wouldn't otherwise be aware that, e.g., a webmail application which
shows https in the address bar but includes script over http isn't
safe to use in a coffeeshop in the
hacker part of town, but also to highlight the same issue to content
authors who might themselves otherwise miss this subtle point.
</p>
<p>
This is a good thing for users, but it puts site operators newly in
posession of a certificate in a bit of difficulty when it comes to
turning on https. All of their HTML resources which reference
insecure content are going to break outright or alarm some population
of users, either by showing a warning or simply not showing the lock
they expect for https. <b>This dependency problem, I assert, is the real
cost barrier we must surmount in order to move the rest of the Web
to 100% HTTPS.</b>
</p>
<h2>
Fixing Mixed Content
</h2>
<p>
As soon as you have to fix Mixed Content, the cost
of migrating to HTTPS starts to get real. Much more so than any
kind of server configuration or acquisition of a certificate, removing
mixed content is expensive and not always well-suited to automation because it often
requires understanding all the possible content served by a host,
modifying it (conditionally) and (possibly most expensively) testing
to verify that everything works.
</p>
<p>
For a complex site, it's not as simple as running s/http/https/g
across all of your resources, on disk or with a mod_rewrite rule.
You might encounter http-schemed resources in many places: static
content, dynamic content generated on the server, on the client,
stored in databases (on the server or client), retrieved from other
third party redirects, etc.
</p>
<p>
A new specification under development, (and already supported by
Chrome and Firefox)
<a href="http://www.w3.org/TR/upgrade-insecure-requests/">Upgrade
Insecure Requests</a>, aims to ease this burden by automatically
upgrading http subresource fetches to https, along with same-origin
navigations.
</p>
<script id="figure4data" type="application/json">
{
"origins" : [
{
"name": "OriginA",
"x": 300,
"y": "100",
"state": "https",
"children" : [
{"name" : "HTML", "id" : "1", "size" : 18, "state": "mixed"},
{"name" : "JS", "id" : "2" },
{"name" : "JPG", "id" : "3" },
{"name" : "HTML", "id" : "11", "size" : 18, "state" : "mixed"}
]
},
{"name": "OriginB", "x": 200, "y": "300", "state": "http",
"children" : [
{"name" : "HTML", "id" : "4", "size" : 18},
{"name" : "JSON", "id" : "5"},
{"name" : "JS", "id" : "6"}
]
},
{"name": "OriginC", "x": 100, "y": "100", "state": "https",
"children" : [
{"name" : "JS", "id" : "10"}
]
}
],
"links": [
{"fromResource": "1", "toResource":"2", "scheme":"http", "mixed":true},
{"fromResource": "1", "toResource":"3", "scheme":"http", "mixed":true},
{"fromResource": "1", "toResource":"6", "scheme":"http", "mixed":true},
{"fromResource": "1", "toResource":"10", "scheme":"http", "mixed":true},
{"fromResource": "11", "toResource":"2", "scheme":"http", "mixed":true},
{"fromResource": "11", "toResource":"10", "scheme":"http", "mixed":true}
]
}
</script>
<script id="figure5data" type="application/json">
{
"origins" : [
{
"name": "OriginA",
"x": 300,
"y": "100",
"state": "https",
"children" : [
{"name" : "HTML", "id" : "1", "size" : 18, "state": "mixed"},
{"name" : "JS", "id" : "2" },
{"name" : "JPG", "id" : "3" },
{"name" : "HTML", "id" : "11", "size" : 18}
]
},
{"name": "OriginB", "x": 200, "y": "300", "state": "http",
"children" : [
{"name" : "HTML", "id" : "4", "size" : 18},
{"name" : "JSON", "id" : "5"},
{"name" : "JS", "id" : "6"}
]
},
{"name": "OriginC", "x": 100, "y": "100", "state": "https",
"children" : [
{"name" : "JS", "id" : "10"}
]
}
],
"links": [
{"fromResource": "1", "toResource":"2", "scheme":"https"},
{"fromResource": "1", "toResource":"3", "scheme":"https"},
{"fromResource": "1", "toResource":"6", "scheme":"https", "mixed":true},
{"fromResource": "1", "toResource":"10", "scheme":"https"},
{"fromResource": "11", "toResource":"2", "scheme":"https"},
{"fromResource": "11", "toResource":"10", "scheme":"https"}
]
}
</script>
<h3>Before</h3>
<div id="figure4" style="height: 400px; width: 500px"></div>
<h3>After Upgrade-Insecure-Requests</h3>
<div id="figure5" style="height: 400px; width: 500px"></div>
<script>drawFigure("figure4", "figure4data");</script>
<script>drawFigure("figure5", "figure5data");</script>
<p>
Upgrade-Insecure-Resources has helped OriginA here.
One of its HTML resources is now
free of mixed content because all of the link schemes have been transparently
upgraded and all its remote dependencies are available over https.
However, we still have one broken resource because the JS dependency
from OriginB is still not available over https.
This illustrates why, until all of their dependencies have upgraded
to https, many sites are reluctant to offer any of their own content
over https, to avoid presenting users with broken experiences and
worrying error messages.
</p>
<p>
This leads to the unfortunate circumstance that the least
accountable actors at the end of long dependency chains can hold
back progress for everyone upstream. Cyclical dependencies
(as certainly exist in the large scale structure of the web) can
create deadlocks which totally prevent upgrades without coordination.
</p>
<h3>None of these sites can turn on https</h3>
<script id="figure6data" type="application/json">
{
"origins" : [
{"name": "OriginA", "x": 300, "y": "300", "state": "http",
"children" : [
{"name" : "HTML", "id" : "1", "size" : 18},
{"name" : "JS", "id" : "2" }
]},
{"name": "OriginB", "x": 200, "y": "100", "state": "http",
"children" : [
{"name" : "HTML", "id" : "3", "size" : 18},
{"name" : " JS", "id" : "4" }
]},
{"name": "OriginC", "x": 100, "y": "300", "state": "http",
"children" : [
{"name" : "HTML", "id" : "5", "size" : 18},
{"name" : "JS", "id" : "6" }
]}
],
"links": [
{"fromResource": "1", "toResource":"4", "scheme":"http"},
{"fromResource": "3", "toResource":"6", "scheme":"http"},
{"fromResource": "5", "toResource":"2", "scheme":"http"}
]
}
</script>
<div id="figure6" style="height: 400px"></div>
<script>drawFigure("figure6", "figure6data");</script>
<p>
To make matters even worse, it is not trivial to even determine if
your dependencies are ready! Once you go HTTPS, errors will
just start happening for your users, and you have no obvious way to
catch them in advance. (A "<tt>default-src https:</tt>" Content Security
Policy directive can tell you when things actually broke, but you
can't easily compose it with an optimistic upgrade to test without
actual breakage.)
</p>
<p>For modern applications with complex client-side logic,
serving large user bases, and using things like Real-Time-Bidding
advertising networks, the difficulty of creating a reasonable simulation of
traffic and user experience for test purposes is quite real. Just
the set of domain names you reference may be emergent runtime
behavior with substantial variance over time.
</p>
<h2>
Breaking the deadlock
</h2>
<p>
What we lack is an intermediate state between http and https.
Ideally, such a state would have the following properties:
<ol>
<li>
Allow secure origins which depend on resources you serve to
retrieve them in way which does not violate their secure
tranquility.
</li>
<li>
Do not force resources to make premature or unverified
guarantees of secure tranquility / lack of mixed content.
</li>
<li>
Be extremely low-cost and low-risk to deploy; ideally
requiring zero content-level changes, only server
configuration updates. (including possibly adding one or
more http headers)
</li>
<li>
Allow detection of dependencies which would violate secure
tranquility / produce mixed content errors without
negatively impacting the user experience.
</li>
</ol>
</p>
<script id="figure7data" type="application/json">
{
"origins" : [
{"name": "OriginA", "x": 300, "y": "300", "state": "http",
"children" : [
{"name" : "HTML", "id" : "1", "size" : 18},
{"name" : "JS", "id" : "2" }
]},
{"name": "OriginB", "x": 200, "y": "100", "state": "http",
"children" : [
{"name" : "HTML", "id" : "3", "size" : 18},
{"name" : " JS", "id" : "4" }
]},
{"name": "OriginC", "x": 100, "y": "300", "state": "http",
"children" : [
{"name" : "HTML", "id" : "5", "size" : 18},
{"name" : "JS", "id" : "6" }
]},
{"name": "OriginD", "x": 400, "y": "100", "state": "http",
"children" : [
{"name" : "JS", "id" : "7" }
]}
],
"links": [
{"fromResource": "1", "toResource":"4", "scheme":"http"},
{"fromResource": "3", "toResource":"6", "scheme":"http"},
{"fromResource": "3", "toResource":"7", "scheme":"http"},
{"fromResource": "5", "toResource":"2", "scheme":"http"}
]
}
</script>
<h3>Click on the figure below to see how introducing an intermediate
state (indicated with blue) with these properties can break an upgrade deadlock cycle.</h3>
<div id="figure7" style="height: 400px" onclick="animateFigure7()"></div>
<script>
function h2h2t(d) {
return d.replace(/\bhttp\b/, "http_to_transitional");
}
function h2t2t(d) {
return d.replace(/\bhttp_to_transitional\b/, "transitional ");
}
function h2h2s(d) {
return d.replace(/http /, "http_to_https ");
}
function h2s2s(d) {
return d.replace(/http_to_https /, "https ");
}
function h2s(d) {
return d.replace(/http/, "https");
}
function animateFigure7() {
var e_0 = document.getElementById("figure7_origins_OriginB").firstChild;
e_0.addEventListener("animationend", step1, false);
e_0.addEventListener("webkitAnimationEnd", step1, false);
// step 0
document.getElementById("figure7_origins_OriginB")
.lastChild
.textContent = "http[s]://OriginB";
d3.selectAll("#figure7 circle.OriginB")
.attr("class", function(d) { return h2h2t(d3.select(this).attr("class")) });
function step1() {
d3.selectAll("#figure7 circle.OriginB")
.attr("class", function(d) { return h2t2t(d3.select(this).attr("class")) });
var e_1 = document.getElementById("figure7_origins_OriginA").firstChild;
e_1.addEventListener("animationend", step2, false);
e_1.addEventListener("webkitAnimationEnd", step2, false);
document.getElementById("figure7_origins_OriginA")
.lastChild
.textContent = "https://OriginA";
d3.selectAll("#figure7 circle.OriginA")
.attr("class", function(d) { return h2h2s(d3.select(this).attr("class")) });
}
function step2() {
d3.selectAll("#figure7 circle.OriginA")
.attr("class", function(d) { return h2s2s(d3.select(this).attr("class")) });
var e_2 = document.getElementById("figure7_origins_OriginC").firstChild;
e_2.addEventListener("animationend", step3, false);
e_2.addEventListener("webkitAnimationEnd", step3, false);
document.getElementById("figure7_origins_OriginC")
.lastChild
.textContent = "https://OriginC";
d3.selectAll("#figure7 circle.OriginC")
.attr("class", function(d) { return h2h2s(d3.select(this).attr("class")) });
d3.select("#figure7_hyperlinks_5_to_2")
.attr("class", function(d) { return h2s(d3.select(this).attr("class")) });
}
function step3() {
d3.selectAll("#figure7 circle.OriginC")
.attr("class", function(d) { return h2s2s(d3.select(this).attr("class")) });
// TODO reset figure?
}
}
drawFigure("figure7", "figure7data");
</script>
<p>
First, OriginB turns on "https-transitional" mode. This means that is resources are
still not available at URLs with an https scheme, but are optimistically available
over TLS with the full guarantees, including a valid certificate. This is essentially
zero-cost for OriginB because it makes no new guarantees to users or browsers about
the security state or tranquility of its own resources.
</p>
<p>
Now that OriginB's resources are available via "https-transitional", OriginA turns on
https. It has an HTML file with an http dependency on the JS file at OriginB. A
browser that knows about "https-transitional" can try to initiate a TLS connection
to OriginB and ask for the resource with its original http scheme. If this
optimistic upgrade fails, it would be treated as insecure and trigger mixed content
blocking, so we haven't reduced the guarantees to users of OriginA. If it succeeds,
all of the standard guarantees required for OriginA to be secure and tranquil are met,
and no mixed content warning or blocking would be triggered, even though the reference
to the JS file at OriginB still used the http scheme.
</p>
<p>
Now that OriginA has upgraded, OriginC can upgrade, too. OriginB still has a dependency
to OriginD which is only http, so it can't yet go to https, but by turning on
transitional mode, it has unblocked upgrades for A and B, without creating any negative
user experiences for its own users due to mixed content from D. Without the transitional
state, none of these sites could have upgraded.
</p>
<p>
The interesting bit here is the link from OriginA's HTML resource to OriginB's JS resource.
It needs to satisfy all the properties of TLS - but whether it remains an http scheme that
is transparently upgraded during the fetch from OriginB, or whether it is upgraded at OriginA
before a fetch is even attempted depends on how this transitional state might be implemented.
</p>
<h2>
How could we introduce this state?
</h2>
<p>
A first take, just to break resource dependency deadlocks without introducing documents
with mixed content into the world, would be to enable https
with a server filter that returns a 404 whenever it would otherwise return a Content-Type of text/html.
In fact, it's probably a surprisingly good approximation, modulo some edge cases involving
CORS. Of the four properties we are interested in, this even gets us a pretty good take on three of them.
<p>
What is missing is the 4th property - the ability to detect the state of your own dependencies so
you can know when it's OK to flip the "real https" switch. What if browsers could do
Content-Security-Policy-Report-Only with "upgrade-insecure-requests" for http documents?
<ol>
<li>attempt to upgrade</li>
<li>if upgrade fails</li>
<ol>
<li>fall back to http fetch</li>