WIP: Cache partitioning#191
Draft
jupenur wants to merge 9 commits into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There's a lot of stuff crammed into this PR, so bear with me. The basics:
originscache as well asnonOriginsandtabsglobals are now partitioned by first party origin and incognito status. That's done by using composite cache keys implemented using the newCacheKeyfunction. This part is largely trivial.getFirstPartyto help determine the correct cache partition for a webRequest details object. This is where things get a bit hairy, but there are comments in the function to help navigate it.SharedWorker; in this case we patch theSharedWorkerconstructor to include the first party origin in the worker script's URL fragment.ServiceWorker; piggy-backing on URL fragments doesn't work because the URL fragment is explicitly cleared by the browser; instead we completely block service worker registration in frames and assume the first party origin for any service worker is the origin of the service worker.Worker; this case should be easy, but due to BMO#2048884 we need to do similar patching as with shared workers.Some hairy details:
firstPartyMarker, that can be reliably detected on the other end. This marker must not leak outside the extension, because knowing the marker would allow an attacker to spoof the first party origin and force the use of an arbitrary cache partition.WorkerLocation.getFirstPartyfail securely by emitting a unique origin in that case, effectively disabling the cache. If that happens, the function also logs a warning.Some additional stuff in this PR:
AudioWorkletbug in NoScript.updatableHookfunction that handles delivering async data to a hook in a reusable manner.