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

transferSize might reveal HttpOnly cookies #238

Closed
annevk opened this issue Nov 20, 2020 · 12 comments · Fixed by #266
Closed

transferSize might reveal HttpOnly cookies #238

annevk opened this issue Nov 20, 2020 · 12 comments · Fixed by #266

Comments

@annevk
Copy link
Member

annevk commented Nov 20, 2020

Which does not seem ideal. The web platform networking APIs purposefully filter out cookie headers everywhere. (Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1679737.)

@rniwa
Copy link

rniwa commented Nov 22, 2020

This is one of many reasons Safari / WebKit doesn't expose transferSize.

@marcelduran
Copy link

marcelduran commented Nov 22, 2020 via email

@rniwa
Copy link

rniwa commented Nov 22, 2020

Hence TAO (timing-allow-origin) header, right? Or am I missing something?

TAO wouldn't help here. This isn't a cross origin issue.

@marcelduran
Copy link

marcelduran commented Nov 24, 2020 via email

@yoavweiss
Copy link
Contributor

httpOnly cookies should not be exposed to web content, even for the same origin. transferSize can enable sites to estimate those cookie sizes, which can reveal variations in those cookies which should not be observable.

@bdekoz
Copy link

bdekoz commented Dec 3, 2020

hey @rniwa can you expand a bit on what keeps Safari / WebKit from exposing transferSize or encoded transfer size? Is there a common x-kind of transfer size that is acceptable to all the vendors here?

@nicjansma
Copy link
Contributor

@annevk Could you provide a brief summary of how you could use transferSize to detect HttpOnly cookies? When I first saw this I was thinking you could compare document.cookie.length to transferSize-encodedBodySize (to get "headers size"), but the later would also obviously include the other HTTP headers as well. I don't think the client would be able to know the exact size of the "other" headers unless they changed very little by time/useragent.

@annevk
Copy link
Member Author

annevk commented Dec 4, 2020

@nicjansma you could just do a fetch(), no?

@rniwa
Copy link

rniwa commented Dec 4, 2020

@nicjansma you could just do a fetch(), no?

Also, we don't want to make it a requirement for web servers to insert varying lengths of HTTP(S) headers to obscure the presence of HttpOnly cookies.

@nicjansma
Copy link
Contributor

@annevk Ah yep, thanks, forgot XHR/fetch have access to all headers in some cases.

@yoavweiss
Copy link
Contributor

This was discussed on the WG call the other week.

Seems like a good path forward would be to remove the header sizes from transferSize, and replace it with a fixed value (e.g. 300 bytes) that would enable the current cache state related use cases ("is the resource fetched from cache?" and "was the resource successfully revalidated?") to remain viable without breaking existing code that relies on current values.

@Krinkle
Copy link
Member

Krinkle commented Jan 19, 2021

I've analysed usage in Wikimedia codebases, and the libraries we distribute currently. Indeed the only use case currently found was to "guess" whether a resource was a local cache hit, 304 Not Modified response, or fresh download.

Follows this pattern generally:

// Resource Timing API
if (nt.transferSize === 0) {
	browserCache = 'local hit';
} else if (nt.transferSize > 0 && nt.encodedBodySize > 0 && nt.transferSize < nt.encodedBodySize ) {
	browserCache = 'local hit (after HTTP 304)';
} else {
	browserCache = 'miss (HTTP 200 OK)';
}

I support the mitigation reducing transferSize to just a fixed amount for headers plus encodedBodySize, if transferred.

Now that we've learned that we don't want to expose the actual transfer size, I wonder it would make sense to remove this in a future interation of the spec. From what I can tell, it seems likely safe for web compat for it to become undefined, as the original spec didn't have it (afaik), and Safari still doesn't implement it.

In that case, we may want to first decide how to provide the cache status in a more intiutive manner for future generations, since this definitely doesn't seem like a good API for it long-term. It would be confusing both because it doesn't provide what it appears to, and the thing it actually provides (cache status) is hard to learn/discover this way. It seems appealing to jump for a shiny new field like cacheStatus holding three possible values, but that might be rather inflexible over the long-term and presents the same problem we've since faced in other APIs when we try to capture complex information in a single string, which means we can't then add new values to it that are related without breaking existing code. In this case something more split up might make sense e.g. boolean wasBodyTransferred. Depending on whether we want to long-term expose http status codes and/or to differenteiate between 304 vs fully local hit, we might want to add another bool or integer field.

(Wording of "was" vs "did" still TBD in w3ctag/design-reviews#547)

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue May 11, 2021
Aligning transferSize to the spec means that response header sizes will
no longer be directly exposed, even for same origin resources or
resources with Timing-Allow-Origin headers.
This is because it seems unsafe[1] to expose header sizes directly.

It also means that redirect chains won't count towards the size exposed
in `transferSize`. While we could specify and accumulate redirect body
sizes, it seems like we'd be better off reporting redirects directly[2]
in the future, in case it becomes a priority.

PSA: https://groups.google.com/a/chromium.org/g/blink-dev/c/Sny4FO5_y5E

[1] w3c/resource-timing#238
[2] https://w3c.github.io/web-performance/meetings/2021/2021-03-18/index.html

Bug: 1185801
Change-Id: Iba071c6bb74c5522e3f1ed2586f082f11a7a68a0
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue May 11, 2021
Aligning transferSize to the spec means that response header sizes will
no longer be directly exposed, even for same origin resources or
resources with Timing-Allow-Origin headers.
This is because it seems unsafe[1] to expose header sizes directly.

It also means that redirect chains won't count towards the size exposed
in `transferSize`. While we could specify and accumulate redirect body
sizes, it seems like we'd be better off reporting redirects directly[2]
in the future, in case it becomes a priority.

PSA: https://groups.google.com/a/chromium.org/g/blink-dev/c/Sny4FO5_y5E

[1] w3c/resource-timing#238
[2] https://w3c.github.io/web-performance/meetings/2021/2021-03-18/index.html

Bug: 1185801
Change-Id: Iba071c6bb74c5522e3f1ed2586f082f11a7a68a0
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue May 12, 2021
Aligning transferSize to the spec means that response header sizes will
no longer be directly exposed, even for same origin resources or
resources with Timing-Allow-Origin headers.
This is because it seems unsafe[1] to expose header sizes directly.

It also means that redirect chains won't count towards the size exposed
in `transferSize`. While we could specify and accumulate redirect body
sizes, it seems like we'd be better off reporting redirects directly[2]
in the future, in case it becomes a priority.

PSA: https://groups.google.com/a/chromium.org/g/blink-dev/c/Sny4FO5_y5E

[1] w3c/resource-timing#238
[2] https://w3c.github.io/web-performance/meetings/2021/2021-03-18/index.html

Bug: 1185801
Change-Id: Iba071c6bb74c5522e3f1ed2586f082f11a7a68a0
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue May 14, 2021
Aligning transferSize to the spec means that response header sizes will
no longer be directly exposed, even for same origin resources or
resources with Timing-Allow-Origin headers.
This is because it seems unsafe[1] to expose header sizes directly.

It also means that redirect chains won't count towards the size exposed
in `transferSize`. While we could specify and accumulate redirect body
sizes, it seems like we'd be better off reporting redirects directly[2]
in the future, in case it becomes a priority.

PSA: https://groups.google.com/a/chromium.org/g/blink-dev/c/Sny4FO5_y5E

[1] w3c/resource-timing#238
[2] https://w3c.github.io/web-performance/meetings/2021/2021-03-18/index.html

Bug: 1185801
Change-Id: Iba071c6bb74c5522e3f1ed2586f082f11a7a68a0
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue May 16, 2021
Aligning transferSize to the spec means that response header sizes will
no longer be directly exposed, even for same origin resources or
resources with Timing-Allow-Origin headers.
This is because it seems unsafe[1] to expose header sizes directly.

It also means that redirect chains won't count towards the size exposed
in `transferSize`. While we could specify and accumulate redirect body
sizes, it seems like we'd be better off reporting redirects directly[2]
in the future, in case it becomes a priority.

PSA: https://groups.google.com/a/chromium.org/g/blink-dev/c/Sny4FO5_y5E

[1] w3c/resource-timing#238
[2] https://w3c.github.io/web-performance/meetings/2021/2021-03-18/index.html

Bug: 1185801
Change-Id: Iba071c6bb74c5522e3f1ed2586f082f11a7a68a0
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue May 17, 2021
Aligning transferSize to the spec means that response header sizes will
no longer be directly exposed, even for same origin resources or
resources with Timing-Allow-Origin headers.
This is because it seems unsafe[1] to expose header sizes directly.

It also means that redirect chains won't count towards the size exposed
in `transferSize`. While we could specify and accumulate redirect body
sizes, it seems like we'd be better off reporting redirects directly[2]
in the future, in case it becomes a priority.

PSA: https://groups.google.com/a/chromium.org/g/blink-dev/c/Sny4FO5_y5E

[1] w3c/resource-timing#238
[2] https://w3c.github.io/web-performance/meetings/2021/2021-03-18/index.html

Bug: 1185801
Change-Id: Iba071c6bb74c5522e3f1ed2586f082f11a7a68a0
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue May 18, 2021
Aligning transferSize to the spec means that response header sizes will
no longer be directly exposed, even for same origin resources or
resources with Timing-Allow-Origin headers.
This is because it seems unsafe[1] to expose header sizes directly.

It also means that redirect chains won't count towards the size exposed
in `transferSize`. While we could specify and accumulate redirect body
sizes, it seems like we'd be better off reporting redirects directly[2]
in the future, in case it becomes a priority.

PSA: https://groups.google.com/a/chromium.org/g/blink-dev/c/Sny4FO5_y5E

[1] w3c/resource-timing#238
[2] https://w3c.github.io/web-performance/meetings/2021/2021-03-18/index.html

Bug: 1185801
Change-Id: Iba071c6bb74c5522e3f1ed2586f082f11a7a68a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2878693
Commit-Queue: Yoav Weiss <yoavweiss@chromium.org>
Reviewed-by: Nicolás Peña Moreno <npm@chromium.org>
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Charlie Harrison <csharrison@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#883803}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue May 18, 2021
Aligning transferSize to the spec means that response header sizes will
no longer be directly exposed, even for same origin resources or
resources with Timing-Allow-Origin headers.
This is because it seems unsafe[1] to expose header sizes directly.

It also means that redirect chains won't count towards the size exposed
in `transferSize`. While we could specify and accumulate redirect body
sizes, it seems like we'd be better off reporting redirects directly[2]
in the future, in case it becomes a priority.

PSA: https://groups.google.com/a/chromium.org/g/blink-dev/c/Sny4FO5_y5E

[1] w3c/resource-timing#238
[2] https://w3c.github.io/web-performance/meetings/2021/2021-03-18/index.html

Bug: 1185801
Change-Id: Iba071c6bb74c5522e3f1ed2586f082f11a7a68a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2878693
Commit-Queue: Yoav Weiss <yoavweiss@chromium.org>
Reviewed-by: Nicolás Peña Moreno <npm@chromium.org>
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Charlie Harrison <csharrison@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#883803}
pull bot pushed a commit to Yannic/chromium that referenced this issue May 18, 2021
Aligning transferSize to the spec means that response header sizes will
no longer be directly exposed, even for same origin resources or
resources with Timing-Allow-Origin headers.
This is because it seems unsafe[1] to expose header sizes directly.

It also means that redirect chains won't count towards the size exposed
in `transferSize`. While we could specify and accumulate redirect body
sizes, it seems like we'd be better off reporting redirects directly[2]
in the future, in case it becomes a priority.

PSA: https://groups.google.com/a/chromium.org/g/blink-dev/c/Sny4FO5_y5E

[1] w3c/resource-timing#238
[2] https://w3c.github.io/web-performance/meetings/2021/2021-03-18/index.html

Bug: 1185801
Change-Id: Iba071c6bb74c5522e3f1ed2586f082f11a7a68a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2878693
Commit-Queue: Yoav Weiss <yoavweiss@chromium.org>
Reviewed-by: Nicolás Peña Moreno <npm@chromium.org>
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Charlie Harrison <csharrison@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#883803}
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue May 20, 2021
…spec, a=testonly

Automatic update from web-platform-tests
[Resource Timing] Align transferSize to spec

Aligning transferSize to the spec means that response header sizes will
no longer be directly exposed, even for same origin resources or
resources with Timing-Allow-Origin headers.
This is because it seems unsafe[1] to expose header sizes directly.

It also means that redirect chains won't count towards the size exposed
in `transferSize`. While we could specify and accumulate redirect body
sizes, it seems like we'd be better off reporting redirects directly[2]
in the future, in case it becomes a priority.

PSA: https://groups.google.com/a/chromium.org/g/blink-dev/c/Sny4FO5_y5E

[1] w3c/resource-timing#238
[2] https://w3c.github.io/web-performance/meetings/2021/2021-03-18/index.html

Bug: 1185801
Change-Id: Iba071c6bb74c5522e3f1ed2586f082f11a7a68a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2878693
Commit-Queue: Yoav Weiss <yoavweiss@chromium.org>
Reviewed-by: Nicolás Peña Moreno <npm@chromium.org>
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Charlie Harrison <csharrison@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#883803}

--

wpt-commits: 12a4d39e06d9831ad96af1b70b3b55deb35bb42c
wpt-pr: 28962
qtprojectorg pushed a commit to qt/qtwebengine-chromium that referenced this issue Oct 25, 2021
Cherry-pick of patch originally reviewed on
https://chromium-review.googlesource.com/c/chromium/src/+/3062844:
[M90-LTS] Align transferSize to spec

Aligning transferSize to the spec means that response header sizes will
no longer be directly exposed, even for same origin resources or
resources with Timing-Allow-Origin headers.
This is because it seems unsafe[1] to expose header sizes directly.

It also means that redirect chains won't count towards the size exposed
in `transferSize`. While we could specify and accumulate redirect body
sizes, it seems like we'd be better off reporting redirects directly[2]
in the future, in case it becomes a priority.

PSA: https://groups.google.com/a/chromium.org/g/blink-dev/c/Sny4FO5_y5E

[1] w3c/resource-timing#238
[2] https://w3c.github.io/web-performance/meetings/2021/2021-03-18/index.html

(cherry picked from commit 8d16683fe77e78dc06e87c9cdc9fd7e77f7759ea)

Bug: 1185801
Change-Id: Iba071c6bb74c5522e3f1ed2586f082f11a7a68a0
Commit-Queue: Yoav Weiss <yoavweiss@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#883803}
Reviewed-by: Artem Sumaneev <asumaneev@google.com>
Reviewed-by: Jana Grill <janagrill@google.com>
Owners-Override: Artem Sumaneev <asumaneev@google.com>
Owners-Override: Jana Grill <janagrill@google.com>
Commit-Queue: Jana Grill <janagrill@google.com>
Cr-Commit-Position: refs/branch-heads/4430@{#1597}
Cr-Branched-From: e5ce7dc4f7518237b3d9bb93cccca35d25216cbe-refs/heads/master@{#857950}
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
mjfroman pushed a commit to mjfroman/moz-libwebrtc-third-party that referenced this issue Oct 14, 2022
Aligning transferSize to the spec means that response header sizes will
no longer be directly exposed, even for same origin resources or
resources with Timing-Allow-Origin headers.
This is because it seems unsafe[1] to expose header sizes directly.

It also means that redirect chains won't count towards the size exposed
in `transferSize`. While we could specify and accumulate redirect body
sizes, it seems like we'd be better off reporting redirects directly[2]
in the future, in case it becomes a priority.

PSA: https://groups.google.com/a/chromium.org/g/blink-dev/c/Sny4FO5_y5E

[1] w3c/resource-timing#238
[2] https://w3c.github.io/web-performance/meetings/2021/2021-03-18/index.html

Bug: 1185801
Change-Id: Iba071c6bb74c5522e3f1ed2586f082f11a7a68a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2878693
Commit-Queue: Yoav Weiss <yoavweiss@chromium.org>
Reviewed-by: Nicolás Peña Moreno <npm@chromium.org>
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Charlie Harrison <csharrison@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#883803}
NOKEYCHECK=True
GitOrigin-RevId: 8d16683fe77e78dc06e87c9cdc9fd7e77f7759ea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment