Skip to content

Commit 6b8a2c7

Browse files
author
Douglas Creager
committed
Handle errors in different phases differently
This patch clarifies the different phases that happen while servicing a request. A network error occurs during one of those phases, and we now handle errors differently depending on which phase they occur in: - `include_subdomains` policies can only be used to generate reports about DNS resolution errors, since the policy author can only confirm ownership of the DNS tree, and not of all of the servers that those domain names resolve to. - If the resolved IP address for an origin changes between when a policy is received, and when its used to generate a report, we don't report any details about the connection and application phases, and only report that the IP address changed. This prevents DNS rebinding attacks.
1 parent c4ef65d commit 6b8a2c7

File tree

1 file changed

+146
-5
lines changed

1 file changed

+146
-5
lines changed

Diff for: index.html

+146-5
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ <h2>Dependencies</h2>
165165
<li><dfn data-cite="!RFC7231#section-6.3.1" data-lt="200 response">200 status code</dfn></li>
166166
<li><dfn data-cite="!RFC7231#section-6.6">5xx status code</dfn></li>
167167
<li><dfn data-cite="!RFC7234">local cache</dfn></li>
168+
<li><dfn data-cite="!RFC7230#section-6.3">persistent connections</dfn></li>
168169
<li><dfn data-cite="!RFC7230#section-2.1" data-lt="requests">request</dfn></li>
169170
<li><dfn data-cite="!RFC7231#section-4">request method</dfn></li>
170171
<li><dfn data-cite="!RFC7231#section-3">resource representation</dfn></li>
@@ -274,6 +275,43 @@ <h2>Network requests</h2>
274275
<a>HTTP-network fetch</a> algorithm.
275276
</p>
276277

278+
<p>
279+
Regardless of which fetch algorithm and which underlying application and
280+
transport protocols are used, servicing a <a>network request</a> consists
281+
of the following <dfn data-lt="phase">phases</dfn>:
282+
</p>
283+
284+
<ol>
285+
<li>
286+
<dfn>DNS resolution</dfn>: The user agent uses the Domain Name System
287+
[[RFC1034]] to resolve a domain name into an IP address of a
288+
<a>server</a> can that service HTTP requests to that domain.
289+
</li>
290+
291+
<li>
292+
<dfn>Secure connection establishment</dfn>: The user agent opens a
293+
connection to the <a>server</a>, and establishes a secure channel over
294+
this connection.
295+
</li>
296+
297+
<li>
298+
<dfn>Transmission of request and response</dfn>: Once the secure
299+
channel is established, the user agent can transmit the HTTP request,
300+
and receive the response from the <a>server</a>.
301+
</li>
302+
</ol>
303+
304+
<p>
305+
The only mandatory phase is the <a>transmission of request and
306+
response</a>; the other phases might not be needed for every <a>network
307+
request</a>. For instance, DNS results can be cached locally in the
308+
user agent, eliminating <a>DNS resolution</a> for future requests to the
309+
same domain. Similarly, HTTP <a>persistent connections</a> allow open
310+
connections to be shared for multiple requests to the same <a>origin</a>.
311+
However, if multiple <a>phases</a> occur, they will occur in the above
312+
order.
313+
</p>
314+
277315
<p>
278316
A <a>network request</a> is <dfn
279317
data-lt="succeed|succeeded">successful</dfn> if the user agent is able
@@ -299,6 +337,28 @@ <h2>Network errors</h2>
299337
a string.
300338
</p>
301339

340+
<p>
341+
Each <a>network error</a> has a <dfn data-lt-nodefault
342+
data-lt="type-phase">phase</dfn>, which describes which <a>phase</a> the
343+
error occurred in:
344+
</p>
345+
346+
<dl>
347+
<dt><code>dns</code></dt>
348+
<dd>the error occurred during <a>DNS resolution</a></dd>
349+
350+
<dt><code>connection</code></dt>
351+
<dd>
352+
the error occurred during <a>secure connection establishment</a>
353+
</dd>
354+
355+
<dt><code>application</code></dt>
356+
<dd>
357+
the error occurred during the <a>transmission of request and
358+
response</a>
359+
</dd>
360+
</dl>
361+
302362
<p>
303363
There are several predefined <a>network error</a> <a>types</a> defined in
304364
<a href="#predefined-network-error-types"></a>.
@@ -315,6 +375,12 @@ <h2>NEL policies</h2>
315375
delivered to the user agent via HTTP <a>response headers</a>.
316376
</p>
317377

378+
<p>
379+
Each <a>NEL policy</a> has a <dfn>received IP address</dfn>, which is the
380+
IP address of the <a>server</a> that the user agent received this <a>NEL
381+
policy</a> from.
382+
</p>
383+
318384
<p>
319385
Each <a>NEL policy</a> has an <dfn data-lt-nodefault data-lt="policy
320386
origin">origin</dfn>.
@@ -611,6 +677,12 @@ <h2>Process policy headers</h2>
611677
</p>
612678

613679
<dl>
680+
<dt><a>received IP address</a></dt>
681+
<dd>
682+
the IP address of the <a>server</a> that the user agent received
683+
<var>response</var> from
684+
</dd>
685+
614686
<dt><a>origin</a></dt>
615687
<dd><var>origin</var></dd>
616688

@@ -803,6 +875,13 @@ <h2>Generate a network error report</h2>
803875
fetch and when it was completed or aborted by the user agent.
804876
</dd>
805877

878+
<dt><code>phase</code></dt>
879+
<dd>
880+
If <var>request</var> <a>failed</a>, the <a>phase</a> of its
881+
<a>network error</a>. If <var>request</var> <a>succeeded</a>,
882+
<code>"application"</code>.
883+
</dd>
884+
806885
<dt><code>type</code></dt>
807886
<dd>
808887
If <var>request</var> <a>failed</a>, the <a>type</a> of its
@@ -812,6 +891,33 @@ <h2>Generate a network error report</h2>
812891
</dl>
813892
</li>
814893

894+
<li>
895+
If <var>request body</var>'s <code>server_ip</code> property is
896+
non-empty, and not equal to <var>policy</var>'s <a>received IP
897+
address</a>:
898+
899+
<ol>
900+
<li>
901+
Set <var>request body</var>'s <code>phase</code> to
902+
<code>dns</code>.
903+
</li>
904+
<li>
905+
Set <var>request body</var>'s <code>type</code> to
906+
<code>dns.changed_address</code>.
907+
</li>
908+
<li>
909+
Clear <var>request body</var>'s <code>status_code</code> and
910+
<code>elapsed_time</code> properties.
911+
</li>
912+
</ol>
913+
</li>
914+
915+
<li>
916+
If <var>policy</var>'s <a>subdomains</a> flag is <code>include</code>,
917+
and <var>request body</var>'s <code>phase</code> property is not
918+
<code>dns</code>, abort these steps.
919+
</li>
920+
815921
<li>
816922
<p><a data-cite="!REPORTING#queue-report">Queue the report for delivery</a> via the Reporting API. [[!REPORTING]]</p>
817923

@@ -849,16 +955,40 @@ <h2>Predefined network error types</h2>
849955
and/or one or multiple subgroups.
850956
</p>
851957

852-
<dl class="reportTypeGroup">
958+
<section>
959+
<h2>DNS resolution errors</h2>
960+
961+
<p>
962+
All of the <a>network errors</a> in this section occur during the
963+
<a>DNS resolution</a> <a>phase</a>, and therefore have a <a data-lt="type
964+
phase">phase</a> of <code>dns</code>.
965+
</p>
966+
967+
<dl>
853968
<dt><code>dns.unreachable</code></dt>
854969
<dd>DNS server is unreachable</dd>
855970
<dt><code>dns.name_not_resolved</code></dt>
856971
<dd>DNS server responded but is unable to resolve the address</dd>
857972
<dt><code>dns.failed</code></dt>
858973
<dd>Request to the DNS server failed due to reasons not covered by previous errors</dd>
974+
<dt><code>dns.changed_address</code></dt>
975+
<dd>
976+
Indicates that the resolved IP address for a request's <a>origin</a> has
977+
changed since the corresponding <a>NEL policy</a> was received
978+
</dd>
859979
</dl>
980+
</section>
981+
982+
<section>
983+
<h2>Secure connection establishment errors</h2>
860984

861-
<dl class="reportTypeGroup">
985+
<p>
986+
All of the <a>network errors</a> in this section occur during the
987+
<a>secure connection establishment</a> <a>phase</a>, and therefore have a
988+
<a data-lt="type phase">phase</a> of <code>connection</code>.
989+
</p>
990+
991+
<dl>
862992
<dt><code>tcp.timed_out</code></dt>
863993
<dd>TCP connection to the server timed out</dd>
864994

@@ -884,7 +1014,7 @@ <h2>Predefined network error types</h2>
8841014
<dd>The TCP connection failed due to reasons not covered by previous errors</dd>
8851015
</dl>
8861016

887-
<dl class="reportTypeGroup">
1017+
<dl>
8881018
<dt><code>tls.version_or_cipher_mismatch</code></dt>
8891019
<dd>The TLS connection was aborted due to version or cipher mismatch</dd>
8901020

@@ -915,8 +1045,18 @@ <h2>Predefined network error types</h2>
9151045
<dt><code>tls.failed</code></dt>
9161046
<dd>The TLS connection failed due to reasons not covered by previous errors</dd>
9171047
</dl>
1048+
</section>
1049+
1050+
<section>
1051+
<h2>Transmission of request and response errors</h2>
9181052

919-
<dl class="reportTypeGroup">
1053+
<p>
1054+
All of the <a>network errors</a> in this section occur during the
1055+
<a>transmission of request and response</a> <a>phase</a>, and therefore
1056+
have a <a data-lt="type phase">phase</a> of <code>application</code>.
1057+
</p>
1058+
1059+
<dl>
9201060
<dt><code>http.protocol.error</code></dt>
9211061
<dd>The connection was aborted due to an HTTP protocol error</dd>
9221062

@@ -931,13 +1071,14 @@ <h2>Predefined network error types</h2>
9311071

9321072
</dl>
9331073

934-
<dl class="reportTypeGroup">
1074+
<dl>
9351075
<dt><code>abandoned</code></dt>
9361076
<dd>User aborted the resource fetch before it is complete</dd>
9371077

9381078
<dt><code>unknown</code></dt>
9391079
<dd>error type is unknown</dd>
9401080
</dl>
1081+
</section>
9411082

9421083
</section>
9431084

0 commit comments

Comments
 (0)