Skip to content

processResponseDone should receive a response #1202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Apr 21, 2021
Merged

Conversation

noamr
Copy link
Contributor

@noamr noamr commented Mar 25, 2021

Only call processResponseDone for responses that have their
timing info set, which are responses that have passed CORS
and redirects.

Closes #1201


Preview | Diff

@noamr
Copy link
Contributor Author

noamr commented Mar 25, 2021

@annevk

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is problematic as this would distinguish a CORS network error from other network errors. That they are indistinguishable is a desirable security property.

Can we still remove this from implementations?

I checked other network errors, such as a bad port, and we don't seem to be creating RT entries there, but I haven't done exhaustive testing for all possible network errors.

I'm also a bit concerned that somewhere we might do if "response is a network error, return a network error" which would drop this kind of information. I don't think we've audited that as there hasn't been a reason for it thus far.

cc @yoavweiss @npm1 @rniwa @bdekoz @sefeng211

fetch.bs Outdated
@@ -4019,7 +4027,7 @@ steps:

<li><p>Set <var>response</var>'s <a for="response">timing info</a> to <var>timingInfo</var>.

<li><p><a href="https://github.com/w3c/resource-timing/pull/261">Mark resource timing</a> for
<li><p><span>Mark resource timing</span> for
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You want to use <a> here.

fetch.bs Outdated
<a for=/>fetch timing info</a> with its <a for="fetch timing info">start time</a> and its
<a for="fetch timing info">post-redirect start time</a> set to <var>fetchParams</var>'s
<a for="fetch params">timing info</a>'s <a for="fetch timing info">start time</a>, and
its <a for="fetch timing info">end time</a> set to the <a for=/>coarsened shared current
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No newlines inside <a> et al.

fetch.bs Outdated
<a>CORS check</a> for <var>request</var> and <var>response</var> returns failure, then return a
<a>network error</a>.
<a>CORS check</a> for <var>request</var> and <var>response</var> returns failure, then:
<ul>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be an ordered list.

@annevk annevk added security/privacy There are security or privacy implications topic: cors labels Apr 13, 2021
@noamr
Copy link
Contributor Author

noamr commented Apr 13, 2021

I think this is problematic as this would distinguish a CORS network error from other network errors. That they are indistinguishable is a desirable security property.

All network errors that come after the CORS check should go through fetch finale and receive the RT entry, which only has a start/end time.
It's true that only CORS-or-after errors would receive an RT entry. Is that still too exposing?
I can remove this bit for now so that we can proceed with the other issues.

@noamr
Copy link
Contributor Author

noamr commented Apr 13, 2021

Added #1215 to address the CORS/network error issue
This PR handles other issues.

@npm1
Copy link
Contributor

npm1 commented Apr 13, 2021

I think this is problematic as this would distinguish a CORS network error from other network errors. That they are indistinguishable is a desirable security property.

We expose errors in RT to prevent an attacker from distinguishing HTTP status codes (success vs errors). Would something similar apply here for CORS or not really (distinguishing success vs failed)?

@annevk
Copy link
Member

annevk commented Apr 14, 2021

I see where the confusion lies. A HTTP status code of 4xx, 5xx, or even 9xx is not a network error. That's a normal response as far as fetch is concerned. A network error is something more fundamental or the result of a security policy, e.g.:

  • DNS error
  • TLS error
  • Broken H/2 framing
  • CORS error
  • CSP block
  • Mixed Content block

Whether a response with a non-2xx HTTP status code results in an "error" depends on the endpoint. For <object> and <script> it does, for <img> it does not. (I.e., unfortunately 2xx vs non-2xx is exposed to some extent.)

I think in principle we could do one of these:

  • expose timing information for all of these, including network errors (using TAO as a policy and treating network errors as not having TAO).
  • expose timing information for responses, but not network errors
  • expose timing information for responses that result in a "load" event on their endpoint

But what we cannot do (in my opinion) is distinguish between network errors.

fetch.bs Outdated
<var>timingInfo</var>, <var>originalURL</var>, <var>initiatorType</var>, and <var>global</var>.
<!-- TODO -->
<li><p>
<a href="https://w3c.github.io/resource-timing/#dfn-mark-resource-timing">Mark resource timing</a>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed, is it not exported? Let's export it first.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, waiting for Resource-Timing to be published to TR (bikeshed vs. Respec stuff).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this bit for now, will update once the refs are resolvable.

fetch.bs Outdated

<li><p>Set <var>timingInfo</var>'s <a for="fetch timing info">end time</a> to
the <a for=/>coarsened shared current time</a> given <var>fetchParams</var>'s
<a for="fetch params">cross-origin isolated capability</a>.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to set end time twice?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't actually. Removing.

fetch.bs Outdated
<!-- TODO -->
<li><p>
<a href="https://w3c.github.io/resource-timing/#dfn-mark-resource-timing">Mark resource timing</a>
for <var>timingInfo</var>, <var>originalURL</var>, <var>initiatorType</var>, <var>global</var> and
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oxford comma.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

fetch.bs Outdated
<a for="fetch timing info">start time</a> and
<a for="fetch timing info">post-redirect start time</a> are <var>timingInfo</var>'s
<a for="fetch timing info">start time</a>.
<li><p>If <var>response</var>'s <a for=response>timing allow passed flag</a> is not set, then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this <li> contains multiple flow elements the <p> needs to indented on a newline.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

@annevk
Copy link
Member

annevk commented Apr 14, 2021

(I'm still okay with landing this modulo the above comments and leaving the error question to #1215.)

@noamr
Copy link
Contributor Author

noamr commented Apr 15, 2021

I see where the confusion lies. A HTTP status code of 4xx, 5xx, or even 9xx is not a network error. That's a normal response as far as fetch is concerned. A network error is something more fundamental or the result of a security policy, e.g.:

  • DNS error
  • TLS error
  • Broken H/2 framing
  • CORS error
  • CSP block
  • Mixed Content block

Whether a response with a non-2xx HTTP status code results in an "error" depends on the endpoint. For <object> and <script> it does, for <img> it does not. (I.e., unfortunately 2xx vs non-2xx is exposed to some extent.)

I think in principle we could do one of these:

  • expose timing information for all of these, including network errors (using TAO as a policy and treating network errors as not having TAO).
  • expose timing information for responses, but not network errors
  • expose timing information for responses that result in a "load" event on their endpoint

But what we cannot do (in my opinion) is distinguish between network errors.

Let's continue the discussion in #1215.

fetch.bs Outdated
<li><p>Set <var>fetchParams</var>'s <a for="fetch params">request</a>'s
<a for=request>done flag</a>.

<li><p>If <var>timingInfo</var> is null, then return.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have this here and also below in finalize and report timing? It seems this doesn't need to be here and you should get process response done either way?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right.

fetch.bs Outdated
<p>If <var>response</var>'s <a for=response>timing allow passed flag</a> is not set, then
perform the following steps:
<ol>
<li><p>Set <var>timingInfo</var> to a new <a for=/>fetch timing info</a> whose
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Single-space indentation.

@@ -4017,9 +4029,10 @@ steps:

<li><p>Set <var>response</var>'s <a for="response">timing info</a> to <var>timingInfo</var>.

<li><p><a href="https://github.com/w3c/resource-timing/pull/261">Mark resource timing</a> for
<var>timingInfo</var>, <var>originalURL</var>, <var>initiatorType</var>, and <var>global</var>.
<!-- TODO -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's restore the TODO.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -1932,10 +1932,6 @@ message as HTTP/2 does not support them.
<dfn export for=response id=concept-response-cache-state>cache state</dfn> (the empty string or
"<code>local</code>"). Unlesss stated otherwise, it is the empty string.

<p class=note>This is intended solely for usage by service workers. [[SW]]
<!-- If we ever expand the utility of this we need to carefully consider whether filtered responses
need to mask it, whether the cache API needs to store it, etc. -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep this including the comment and instead say something like

This is intended for usage by <cite>Service Workers</cite> and <cite>Resource Timing</cite>.

I guess for Resource Timing we also need opaque responses (that have TAO) to leak this information. I'll have a look if that needs more work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@annevk
Copy link
Member

annevk commented Apr 21, 2021

@noamr I think it would be good if there was a corresponding PR to Resource Timing the commit could link to for it acknowledging the new cacheState argument.

@noamr
Copy link
Contributor Author

noamr commented Apr 21, 2021

@noamr I think it would be good if there was a corresponding PR to Resource Timing the commit could link to for it acknowledging the new cacheState argument.

It’s already there in the editors draft.

@annevk
Copy link
Member

annevk commented Apr 21, 2021

I found the link above, it's w3c/resource-timing#266.

@annevk annevk merged commit 5fac9e8 into whatwg:main Apr 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
security/privacy There are security or privacy implications topic: cors
Development

Successfully merging this pull request may close these issues.

New Resource Timing issues
3 participants