Skip to content
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

Using navigationStart as a baseline may expose cross-origin timing information #160

Open
noamr opened this issue Sep 30, 2021 · 69 comments
Open
Projects

Comments

@noamr
Copy link
Contributor

noamr commented Sep 30, 2021

When we have a navigation with cross-origin redirects, we're hiding redirectStart and redirectEnd from the final document.

However, because the timeOrigin for all the navigation timing entries is the navigation start, the redirect timing info can (somewhat) easily be inferred.

Consider the following:

  • User clicks a link to domain A at timestamp ts1 (e.g. a search engine click handler URL or an ad broker like outbrain)
  • Domain A takes a while to handle the request
  • The request redirects to domain B at timestamp ts2
  • Domain B handles the request and serves the document
  • ts1 is available to the document, directly or indirectly, as it's the navigationStart which is the base timestamp for all navigation timing / resource timing entries (as well as the timeOrigin).

I believe we have three ways to go about it (but maybe there are more):

  • Enable all the navigation timing properties, based on the notion that the cross-origin information is already exposed by navigationStart.
  • Change navigationStart to be the timestamp of the first redirect in the current origin redirect chain
  • Make use of TAO (in its current form or with some amendments) to give redirect chains the opportunity to expose their timing to the destination.

This came from discussing whether to enable or zero-out navigation timing properties.
See previous discussions here, here and here.

Thoughts?`

@noamr noamr changed the title Using navigationStart as a base line may expose cross-origin timing information Using navigationStart as a baseline may expose cross-origin timing information Sep 30, 2021
@noamr
Copy link
Contributor Author

noamr commented Sep 30, 2021

@yoavweiss
Copy link
Contributor

Also @bdekoz @mikewest @arturjanc

@annevk
Copy link
Member

annevk commented Sep 30, 2021

If "current origin redirect chain" means the origin boundary is not crossed therein, that option seems reasonable to me. The current model does indeed seem problematic.

w3c/resource-timing#220 is also related.

@noamr
Copy link
Contributor Author

noamr commented Sep 30, 2021

If "current origin redirect chain" means the origin boundary is not crossed therein, that option seems reasonable to me.

Yes, it means something like "after all the redirects that are not same-origin as the document's final origin are complete"

@achristensen07
Copy link

This does need fixing. I oppose the first option. The third option seems most like what we do with other cross-origin timing exposure.

@mikewest
Copy link
Member

I think I agree with @annevk and @achristensen07. This does seem like something we ought to change, and the third option seems like the most robust (and consistent) way of doing so. I think the second is justifiable from a security standpoint as well, but I'm not sure the complexity it introduces is worthwhile.

@noamr
Copy link
Contributor Author

noamr commented Sep 30, 2021

Note that (3) includes (2) inside it, in the cases where TAO headers are not there.

With option 3 I want to be careful when we overload the meaning of TAO (see concerns here). Though it could be that since TAO was ignored inside redirects so far it's not a problem since it's new usage of an existing header.

Perhaps a good way to go about it would be that the TAO Header would have to specify the same origin as the Location header, rather than *, like this:

Location: my-site.com/page.html
Timing-Allow-Origin: my-site.com

Not having the above in a cross-origin redirect would push the navigation start time (and timeOrigins) to the beginning of the next fetch after this redirect, and having it would act as if this redirect is same-origin for the purposes of navigation timing.

@annevk
Copy link
Member

annevk commented Sep 30, 2021

As I noted in w3c/resource-timing#220 accounting for TAO here is in essence a new model and therefore also a source of complexity. For Resource Timing we have a document A that fetches B which redirects to C. B and C need to consent. Here we have a document A that is navigated to B which redirects to C. B needs to consent? I think it's acceptable, but it's quite a bit different.

@yoavweiss
Copy link
Contributor

I have to say that the second and third options are not mutually exclusive - we could set navigation time at the first same-origin redirect and extend it backwards pending on an opt-in from the cross-origin redirects.

Note that in any case, we'd need some point in time for navigation start even if there's no opt-in. At worst, we can have that be the request to the eventual request for the document, but setting it to the first request in the last same-origin portion of the redirect chain doesn't seem overly complex.

@yoavweiss
Copy link
Contributor

As I noted in w3c/resource-timing#220 accounting for TAO here is in essence a new model and therefore also a source of complexity. For Resource Timing we have a document A that fetches B which redirects to C. B and C need to consent. Here we have a document A that is navigated to B which redirects to C. B needs to consent? I think it's acceptable, but it's quite a bit different.

I agree that TAO may not be the opt-in we want here.

@noamr
Copy link
Contributor Author

noamr commented Sep 30, 2021

I agree that TAO may not be the opt-in we want here.

Opting for a new opt-in? 😬

@jyasskin
Copy link
Member

Yoav pointed out that in cases where the redirection domain is trying to help the source and destination track the user, and the user agent has blocked the query parameters they had been using to do this, this timing information might help them continue to transfer at least a partial identifier. I don't think the navigational-tracking threat model (privacycg/nav-tracking-mitigations#12) is developed enough to be much help in making decisions here, but heads up that the Privacy CG might come back to this later.

@noamr
Copy link
Contributor Author

noamr commented Sep 30, 2021

Yoav pointed out that in cases where the redirection domain is trying to help the source and destination track the user, and the user agent has blocked the query parameters they had been using to do this, this timing information might help them continue to transfer at least a partial identifier. I don't think the navigational-tracking threat model (privacycg/nav-tracking-mitigations#12) is developed enough to be much help in making decisions here, but heads up that the Privacy CG might come back to this later.

Hmm this makes it more interesting - it means that if we accept this as a threat to be mitigated, the user agent should have a say in this for the purpose of tracking prevention and not just the two domains, which means something along option (2) would be the (only?) way to go (the "navigation" starts from the last same-origin chain).

Note that if we go with option (2), some value will be lost for RUM. Sites that load "slowly" will only know what happened from the point the redirect chain arrived at their domain, and they would have no insight into delays caused by 3rd party redirects.

@yoavweiss
Copy link
Contributor

Indeed. As long as query parameters are allowed to be passed with the navigation URLs, acting against this doesn't matter much. So for now, I don't think we should take that into account.

But if and when we start mitigating query parameters as an information-passing channel, we'd need to also mitigate the redirection timing channel, either by not exposing it entirely, or have browsers lie about those times in smarter ways (e.g. for known trackers, when they're highly variable, etc).

@annevk
Copy link
Member

annevk commented Oct 1, 2021

There are user agents doing experiments around query parameters (and some might have shipped?) so we might as well account for it now.

@yoavweiss
Copy link
Contributor

I agree this is an area we should remain vigilant on to see how it develops, but I don't believe we have consensus on the threat model and what the solutions to this threat would look like. So it seems premature to e.g. eliminate an opt-in option before that settles.

@annevk
Copy link
Member

annevk commented Oct 1, 2021

Maybe, I have to say that since we have some tentative plans in this area, I'm actually hesitant now to support an opt-in model here.

@yoavweiss
Copy link
Contributor

^^ @miketaylr

It's true that we could go with option (2) and expand it later with an opt-in, once things in that area settle.

It may also be interesting to think about the incentive model here - if this would make redirectors unaccountable for their performance, that'd not be a great outcome. An opt-in model may not be effective in driving such accountibility.

@noamr
Copy link
Contributor Author

noamr commented Oct 1, 2021

^^ @miketaylr

It's true that we could go with option (2) and expand it later with an opt-in, once things in that area settle.

Feels to me from this discussion that this might be the way forward as a first step, while contemplating the opt-in. Interesting if something else would come up in TPAC.

It may also be interesting to think about the incentive model here - if this would make redirectors unaccountable for their performance, that'd not be a great outcome. An opt-in model may not be effective in driving such accountibility.

I'm not sure a redirecting URL is accountable for timing to its destination... Maybe it's accountable to the domain that started the navigation, e.g. where the banner was?

Maybe the interested party in this information is neither domain, but rather the user (and the user agent), and user agents should be encouraged to show some UI indication during a cross-origin navigation redirect ("You are now redirected via Outbrain" or such), to show the user that the delay comes from an ad broker etc and not from the originating domain / destination domain, rather than counting on the origin/destination URLs to do something about it? </Thoughts.>

@npm1
Copy link
Contributor

npm1 commented Oct 1, 2021

Just to clarify, sounds like this applies to https://w3c.github.io/hr-time/#dfn-time-origin as well? If it does then this would be a pretty big change impacting any high resolution timestamps received by developers.

@yoavweiss
Copy link
Contributor

Just to clarify, sounds like this applies to https://w3c.github.io/hr-time/#dfn-time-origin as well? If it does then this would be a pretty big change impacting any high resolution timestamps received by developers.

Indeed! We'll definitely have to be careful about rolling this out.

@noamr
Copy link
Contributor Author

noamr commented Oct 4, 2021

See demo here. A minimal use case without an intermediate domain.

The originating domain does some form processing of POST before redirecting to a URL at a different domain.
Because the timeOrigin includes the time it took to process the POST at the originating domain, in this case the destination domain can detect whether the user subscribed to a newsletter.

@sgomes
Copy link
Contributor

sgomes commented Oct 15, 2021

Hey folks!

As someone working in performance full-time, I have some concerns regarding this proposal, and its impact on well-established metrics like TTFB.

Unless I'm misunderstanding the proposal, wouldn't option 2 ("Change navigationStart to be the timestamp of the first redirect in the current origin redirect chain") mean that we would be redefining TTFB and all metrics that build upon it to mean different things on different situations? That is:

  • In-origin redirects only if there's no TAO or alternatively proposed header
  • Both in-origin redirects and cross-origin redirects if TAO or alternatively proposed header are present

This seems inconsistent and difficult to account for, given that RUM libraries don't have any visibility into the HTTP headers on the document.

Furthermore, would this also change the definition of TTFB and all metrics that build upon it for native browser measurements, such as the ones taken for the Chrome User Experience Report? If not, this could be even worse, as it would remove the last bit of visibility we have into what happens before a request gets to the ultimate origin.
At Automattic, we've relied on this information in the past to understand what is happening before a request gets to the origin, so that we can find unnecessary redirects where it's impractical or impossible to set up TAO across authentication chains, URL shortening services, etc.

It's extremely important for us to be able to account for every portion of the time that goes into TTFB or a higher-level metric, when we're being ranked for it via CrUX.

In general, Navigation Timing is a well established API that is relied upon by every RUM library out there, so it seems dangerous to redefine the meaning of the most fundamental value that the entire API relies on.

@noamr
Copy link
Contributor Author

noamr commented Oct 15, 2021

Thank you @sgomes, yes, this voice has to be heard to.
Seems like the implications of this on RUM metrics would be pretty big. That would have to be weighed against the current breach of same-origin policy. Hoping for a lively discussion at TPAC.

@tdresser
Copy link

It's unclear to me how excluding redirect time in the timeOrigin prevents any realistic attack.

For this attack to work today, we need:

  • a redirector which forwards to a site we own
  • which leaks privacy / security sensitive info through it's redirect time
  • and has users which navigate to our pages via that redirector

Suppose we exclude redirect time from the timeOrigin. For the above attack to work, I already need users on a site I own. If I then modify links on my site to:

  • record the click timestamp
  • forward to the redirector which forwards back to the site I own

then I'm still able to measure the redirect time and execute the attack.

@annevk
Copy link
Member

annevk commented Oct 26, 2021

mysite.host.example has security implications for host.example, due to the boundary of cookies (and document.domain). But to the user these are often presented as the same "entity" due to them sharing a registrable domain, so the privacy implications are different from mysite.example.

@sgomes
Copy link
Contributor

sgomes commented Oct 26, 2021

I would be sad to see the cross-origin data disappear by default, because it is a great discovery tool for cross-origin redirects within an organisation (as it would be difficult to ensure that the required headers would always be present across a potentially wide variety of systems). If that is to happen for privacy concerns, though, the above approach seems like a good way for RUM libraries to be able to make sense of the situation.

I am a little bit confused about this statement. The highlighted sentence would only prove that this is something we should fix? We don't want to provide great discovery tools for a cross-origin redirects in general.

I apologise, I should have provided more context. My concern is ensuring that these cross-origin issues are visible when they happen within the context of the same organisation, or a context of trust, in general. I understand that's difficult to define.

@sgomes
Copy link
Contributor

sgomes commented Oct 26, 2021

mysite.host.example has security implications for host.example, due to the boundary of cookies (and document.domain). But to the user these are often presented as the same "entity" due to them sharing a registrable domain, so the privacy implications are different from mysite.example.

Thank you, I can understand the distinction with your explanation 👍

I'm not sure there's a good solution to meet all of the concerns expressed. The proposal we're discussing would make some categories of performance problems undiscoverable to the organisations that would be able to fix them, but I don't see a good mechanism for preserving that ability in the context of the current proposal.

@terjanq
Copy link

terjanq commented Oct 26, 2021

I apologise, I should have provided more context. My concern is ensuring that these cross-origin issues are visible when they happen within the context of the same organisation, or a context of trust, in general. I understand that's difficult to define.

@sgomes I am curious how could this be applied? Does "within the context of the same organisation" change the difficulty on making such measurement (e.g. in contrast to two non-related websites)? Without having some backend information, it's hard to imagine that this is indeed that simple in the current state. With backend information at the other hand, it's easier and without calling the client side API - you just compare two timings on your side (well, you have to somehow fingerprint the initial request).

@yoavweiss
Copy link
Contributor

What would work I think would be to add a new token to rel="allow-navigation-timing" but this way, website A exposures the timing to all websites, not only to B

Do you mean that if we A adds a link to B with rel=allow-navigation-timing, it's exposing the timings to B as well as any redirects B would trigger?

@noamr
Copy link
Contributor Author

noamr commented Oct 26, 2021

What would work I think would be to add a new token to rel="allow-navigation-timing" but this way, website A exposures the timing to all websites, not only to B

Do you mean that if we A adds a link to B with rel=allow-navigation-timing, it's exposing the timings to B as well as any redirects B would trigger?

I think that would work, with maybe some meta to limit exposing this to certain origins/sites, also to avoid this as a side-channel for fingerprinting.

@terjanq
Copy link

terjanq commented Oct 26, 2021

What would work I think would be to add a new token to rel="allow-navigation-timing" but this way, website A exposures the timing to all websites, not only to B

Do you mean that if we A adds a link to B with rel=allow-navigation-timing, it's exposing the timings to B as well as any redirects B would trigger?

@yoavweiss this would work basically the same as "opener" (or however it is done nowadays) to preserve the window.opener reference that is now lost because of "noopener" by default. Meaning, that the opened document would be able to access this timing API and get the true value, so that doesn't matter where the link points to and whether there are any redirects.

And I think we could do that because similarly to window.opener the potential information leak is only about website A, and as mentioned, if website A is willing to provide such timing it already can send the request time in window.name or simply embedded into the URL.

@sgomes
Copy link
Contributor

sgomes commented Oct 26, 2021

@sgomes I am curious how could this be applied? Does "within the context of the same organisation" change the difficulty on making such measurement (e.g. in contrast to two non-related websites)? Without having some backend information, it's hard to imagine that this is indeed that simple in the current state. With backend information at the other hand, it's easier and without calling the client side API - you just compare two timings on your side (well, you have to somehow fingerprint the initial request).

@terjanq My concern is mostly around discoverability.

In the current scenario, we can discover problematic pages at the RUM level by simply looking for high values of domainLookupStart, which statistically will catch both problematic in-origin and cross-origin redirects. We can then analyse each situation and try to understand what's happening through either HTTP-level request logs or manual experimentation.

In a scenario where cross-site information is not available to RUM libraries and there exists no mechanism to retrieve it, we would need to rely exclusively on HTTP-level server logs for the discovery phase as well. Not only that, we would have to ensure that the logs for all systems involved are present in the same location, that requests can be correlated, and that an understanding of flow can be established so that we could calculate for each flow what the timing of the first request and the timing of the final one were. It's theoretically doable, yes, but non-trivial in the context of logging systems that are designed to handle each request as a separate entry. Not to mention much more difficult to scale, given the complexity involved.

Hope this provides some extra context!

@terjanq
Copy link

terjanq commented Oct 26, 2021

Makes sense. I am not an expert, but isn't this actually problematic for measurements as well? Suppose that you indeed rely on these measurements and now user visits your website from another website that use redirectors, and these redirectors tend to be really slow. Doesn't it provide false signal to your website? Normally links clicked within the same organisation would be faster than from another in the example.

For me, it looks like both parties in this discussion would benefit from fixing this. For your case it would always provide the wanted signal via opt-in, and from the security & privacy it would mask the potential leaks.

@sgomes
Copy link
Contributor

sgomes commented Oct 26, 2021

For me, it looks like both parties in this discussion would benefit from fixing this. For your case it would always provide the wanted signal via opt-in, and from the security & privacy it would mask the potential leaks.

Yes, I agree. The information is ambiguous in the status quo, and we're only able to distinguish between problematic external redirectors and internal ones by manually looking at things case-by-case. That is sufficient for some needs, but not others.

If an opt-in mechanism were to exist for unambiguously determining that a user spent too much time being redirected across an organisation's various hosted origins, then that would be an improvement over the status quo, as long as the mechanism is practical to deploy.

@noamr
Copy link
Contributor Author

noamr commented Oct 26, 2021

I see such opt-in to be similar in spirit to referrer policy, e.g. <meta name="referrer-timing" content="same-site" /> with some more detailed semantics and a per-element override like the referrerpolicy attribute

@noamr
Copy link
Contributor Author

noamr commented Oct 26, 2021

I see such opt-in to be similar in spirit to referrer policy, e.g. <meta name="referrer-timing" content="same-site" /> with some more detailed semantics

@annevk
Copy link
Member

annevk commented Oct 26, 2021

I don't think Firefox would implement such a mechanism as it enables precisely the thing we want to avoid. (See also statements upthread.) Having sites move things into the URL would be vastly preferable and would ultimately allow for tackling this as part of https://github.com/privacycg/nav-tracking-mitigations (if sites indeed decide to go to those lengths).

@noamr
Copy link
Contributor Author

noamr commented Nov 15, 2021

In the meantime, added a PR to move time origin computation to HTML, this would hopefully make it easier to see how it works and make changes in this in the future.

@andydavies
Copy link

Metrics such as LCP are trying to represent the user's experience and if navgiationStart is changed to be before the first redirect for the current origin then it will no-longer represent the user's experience for many cases

Visitors clicking from search engines / social media sites are typically routed through redirect, in the worst case clicking on a Ad in Google results leads to three redirects that consume nearly a second for example

The time before the first redirect on the current origin is important as it reflects the visitors actual experience

@noamr
Copy link
Contributor Author

noamr commented Nov 23, 2021

Metrics such as LCP are trying to represent the user's experience and if navgiationStart is changed to be before the first redirect for the current origin then it will no-longer represent the user's experience for many cases

Visitors clicking from search engines / social media sites are typically routed through redirect, in the worst case clicking on a Ad in Google results leads to three redirects that consume nearly a second for example

The time before the first redirect on the current origin is important as it reflects the visitors actual experience

Understood, but nonetheless the cross-domain leak is there, and the fact that removing it would hinder this valuable metric doesn't make it less of a leak.

@yoavweiss
Copy link
Contributor

@andydavies - I think the use case for having visibility to these cross-origin redirects is clear. At the same time, this is a cross-origin leak, as it is exposed right now. We'd need to find an alternative, privacy-preserving way to expose this information to developers. (e.g. aggregated reporting)

@noamr
Copy link
Contributor Author

noamr commented Apr 11, 2022

Suggesting to start tackling this by adding an opt-in.
Something similar to TAO but specific to Redirect to avoid loading new meanings on old headers.

How about: Redirect-Timing-Allow-Origin: same-origin | same-site | [url list] | * (default same-origin)
Not sure if we want it closer to TAO or to only allow same-origin/same-site.

At first, it would allow exposing redirectStart/redirectEnd when there are cross-origin redirects in navigation, and later on we can make this as the only way to expose cross-origin redirects at start-of-navigation.

@noamr
Copy link
Contributor Author

noamr commented Apr 11, 2022

Suggesting to solve this in the context of w3c/resource-timing#220

@annevk
Copy link
Member

annevk commented Apr 19, 2022

I don't see how an opt-in header helps with the attacks? See also #160 (comment).

@noamr
Copy link
Contributor Author

noamr commented Apr 19, 2022

I don't see how an opt-in header helps with the attacks? See also #160 (comment).

You're right, it doesn't help with that aspect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Triage
Waiting on dependencies
Development

No branches or pull requests