Skip to content

Commit aa0bd92

Browse files
authored
Add TAO destination check for navigation redirect chains
Timing-Allow-Origin (TAO) currently only opts-in "backwards" in terms of origins and doesn't constitute an opt-in to the destination origin, which is the appropriate opt-in for navigations (contrary to subresources). This PR adds the mechanisms that can enable such "forward" opt-in, and can enable a navigation response to a redirect chain to know that the redirect chain opted in to expose the redirects to its origin. Tests: web-platform-tests/wpt#60823 & web-platform-tests/wpt#60873. Corresponding HTML PR: whatwg/html#12513.
1 parent 45097d9 commit aa0bd92

1 file changed

Lines changed: 72 additions & 2 deletions

File tree

fetch.bs

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ urlPrefix:https://www.rfc-editor.org/rfc/rfc6454;type:dfn;spec:RFC6454
135135
<pre class=link-defaults>
136136
spec:dom; type:dfn; text:element
137137
spec:infra; type:dfn; text:implementation-defined
138+
spec:infra; type:dfn; text:success
138139
</pre>
139140

140141

@@ -2307,10 +2308,19 @@ Unless stated otherwise, it is unset.
23072308
<dfn export for=request id=timing-allow-failed>timing allow failed flag</dfn>. Unless stated
23082309
otherwise, it is unset.
23092310

2311+
<p>A <a for=/>request</a> has an associated
2312+
<dfn for=request>navigation timing allow values list</dfn> (a <a for=/>list</a> of
2313+
<a for=/>lists</a> of <a for=/>strings</a>). Unless stated otherwise, it is « ».
2314+
2315+
<p class=note>Each <a for=list>item</a> in the <a for=request>navigation timing allow values list</a>
2316+
holds the `<code>Timing-Allow-Origin</code>` values of one redirect <a for=/>response</a> in a
2317+
navigation's redirect chain.
2318+
23102319
<p class=note>A <a for=/>request</a>'s <a for=request>URL list</a>, <a for=request>current URL</a>,
23112320
<a for=request>redirect count</a>, <a for=request>response tainting</a>,
2312-
<a for=request>done flag</a>, and <a for=request>timing allow failed flag</a> are used as
2313-
bookkeeping details by the <a for=/>fetch</a> algorithm.
2321+
<a for=request>done flag</a>, <a for=request>timing allow failed flag</a>, and
2322+
<a for=request>navigation timing allow values list</a> are used as bookkeeping details by the
2323+
<a for=/>fetch</a> algorithm.
23142324

23152325
<p>A <a for=/>request</a> has an associated
23162326
<dfn export for=request id=concept-webdriver-id>WebDriver id</dfn>
@@ -2608,6 +2618,15 @@ allowed on the resource fetched by looking at the flag of the response returned.
26082618
the response of a redirect has to be set if it was set for previous responses in the redirect chain,
26092619
this is also tracked internally using the request's <a for=request>timing allow failed flag</a>.
26102620

2621+
<p>A <a for=/>response</a> has an associated
2622+
<dfn export for=response>navigation timing allow values list</dfn> (a <a for=/>list</a> of
2623+
<a for=/>lists</a> of <a for=/>strings</a>). Unless stated otherwise, it is « ».
2624+
2625+
<p class=note>This holds the `<code>Timing-Allow-Origin</code>` values of each redirect
2626+
<a for=/>response</a> in a navigation's redirect chain. It is used so that callers can determine,
2627+
once the navigation's destination origin is known, whether that origin is allowed by every redirect
2628+
in the redirect chain.
2629+
26112630
<p>A <a for=/>response</a> has an associated
26122631
<dfn export for=response id=concept-response-body-info>body info</dfn>
26132632
(a <a for=/>response body info</a>). Unless stated otherwise, it is a new
@@ -5104,6 +5123,11 @@ steps:
51045123
<li><p>Set <var>internalResponse</var>'s <a for=response>redirect taint</a> to <var>request</var>'s
51055124
<a for=request>redirect-taint</a>.
51065125

5126+
<li><p>If <var>request</var> is a <a>navigation request</a>, then set
5127+
<var>internalResponse</var>'s <a for=response>navigation timing allow values list</a> to a
5128+
<a for=list>clone</a> of <var>request</var>'s
5129+
<a for=request>navigation timing allow values list</a>.
5130+
51075131
<li><p>If <var>request</var>'s <a for=request>timing allow failed flag</a> is unset, then set
51085132
<var>internalResponse</var>'s <a for=response>timing allow passed flag</a>.
51095133

@@ -5884,6 +5908,10 @@ these steps:
58845908
<p>If <var>internalResponse</var>'s <a for=response>status</a> is a <a>redirect status</a>:
58855909

58865910
<ol>
5911+
<li><p>If <var>request</var> is a <a>navigation request</a>, then
5912+
<a>append to a request's navigation timing allow values list</a> given <var>request</var> and
5913+
<var>internalResponse</var>.
5914+
58875915
<li>
58885916
<p>If <var>internalResponse</var>'s <a for=response>status</a> is not 303, <var>request</var>'s
58895917
<a for=request>body</a> is non-null, and the <a>connection</a> uses HTTP/2, then user agents
@@ -7311,6 +7339,48 @@ agent's <a>CORS-preflight cache</a> for which there is a <a>cache entry match</a
73117339
</ol>
73127340
</div>
73137341

7342+
<div algorithm>
7343+
<p>To <dfn>append to a request's navigation timing allow values list</dfn>, given a
7344+
<a for=/>request</a> <var>request</var> and a <a for=/>response</a> <var>response</var>:
7345+
7346+
<ol>
7347+
<li><p><a for=/>Assert</a>: <var>request</var> is a <a>navigation request</a>.
7348+
7349+
<li><p>Let <var>taoValues</var> be the result of
7350+
<a for="header list">getting, decoding, and splitting</a> `<code>Timing-Allow-Origin</code>` from
7351+
<var>response</var>'s <a for=response>header list</a>.
7352+
7353+
<li><p>If <var>taoValues</var> is null, then set <var>taoValues</var> to « ».
7354+
7355+
<li><p><a for=list>Append</a> <var>taoValues</var> to <var>request</var>'s
7356+
<a for=request>navigation timing allow values list</a>.
7357+
</ol>
7358+
</div>
7359+
7360+
<div algorithm>
7361+
<p>To perform a <dfn export>navigation TAO check</dfn> for a
7362+
<a for=/>response</a> <var>response</var> and an <a for=/>origin</a>
7363+
<var>destinationOrigin</var>:
7364+
7365+
<ol>
7366+
<li>
7367+
<p><a for=list>For each</a> <var>taoValues</var> of <var>response</var>'s
7368+
<a for=response>navigation timing allow values list</a>:
7369+
7370+
<ol>
7371+
<li><p>If <var>taoValues</var> <a for=list>contains</a> "<code>*</code>", then
7372+
<a for=iteration>continue</a>.
7373+
7374+
<li><p>If <var>taoValues</var> <a for=list>contains</a> <var>destinationOrigin</var>,
7375+
<a lt="ASCII serialization of an origin">serialized</a>, then <a for=iteration>continue</a>.
7376+
7377+
<li><p>Return <a for=/>failure</a>.
7378+
</ol>
7379+
7380+
<li><p>Return <a for=/>success</a>.
7381+
</ol>
7382+
</div>
7383+
73147384
<h3 id=deferred-fetch>Deferred fetching</h3>
73157385

73167386
<p>Deferred fetching allows callers to request that a fetch is invoked at the latest possible

0 commit comments

Comments
 (0)