Conversation
Navigation responses guarded by Cache-Control: no-store, private or no-cache may contain authenticated or user-specific data and must never be written to the offline cache. handleNavigation now checks these directives before calling cache.put(), tightens the cacheable status to 200, and keeps the network-first strategy and offline fallback intact. Adds serviceWorkerHandlersSecuritySpec.js covering the security behavior and the offline fallback to prevent regressions. Resolves the concern raised by @sylvesterkaczmarek on nasa#8425.
14 tasks
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.
Summary
Resolves the security concern raised by @sylvesterkaczmarek during review of nasa#8425:
handleNavigation()wrote every successful navigation response to the offline cache without consulting the response'sCache-Controlheader. On deployments that serve authenticated or personalized pages, those responses persist in Cache Storage and remain readable offline — including by later, unauthenticated sessions on the same browser profile.Changes
src/plugins/pwa/serviceWorkerHandlers.jshandleNavigationnow checksisCacheableNavigationResponse()beforecache.put():Cache-Control: no-store,privateorno-cacheare never stored, even when they are200 OK;200responses that were not the result of a redirect are stored;cacheControlForbidsCaching) is case-insensitive and tolerates whitespace and directive arguments (e.g.no-cache="Set-Cookie"), per RFC 9111.index.html) are unchanged. Pages withheld from the cache can, by design, never be served by the fallback.activate(), so deploying this build also evicts anything the earlier, permissive version may have cached.src/plugins/pwa/serviceWorkerHandlersSecuritySpec.js(new)Cache-Control: public) are still cached for offline use;no-store,private,no-cache, combined, mixed-case and argument-carrying header variants are never written to Cache Storage, even on200 OKresponses;Notes for reviewers
max-age=0(a revalidation hint) intentionally remains cacheable; only directives that forbid storage or shared caching are enforced.must-revalidate/Vary: Authorizationhandling can be discussed as a follow-up.*Spec.jsnaming so Karma'sindex-test.cjsdiscovery picks it up in CI.Fixes the review feedback on nasa#8425.