Clearing data for a single site does not remove its Alt-Svc mappings
Categories
(Toolkit :: Data Sanitization, defect)
Tracking
()
People
(Reporter: leggert, Unassigned)
References
Details
(Keywords: good-first-bug)
Attachments
(1 external file)
Alt-Svc mappings (in memory and in AlternateServices.bin) are only cleared when nsHttpHandler observes last-pb-context-exited or browser:purge-session-history, both of which call AltSvcCache::ClearAltServiceMappings() for all entries.
browser:purge-session-history is only notified by SessionHistoryCleaner.deleteAll and SessionHistoryCleaner.deleteByRange in ClearDataService.sys.mjs. The per-site paths (deleteByHost, deleteByPrincipal, deleteBySite) only notify browser:purge-session-history-for-domain and browser:purge-sessionStorage, which nsHttpHandler does not observe, and no cleaner covers Alt-Svc under CLEAR_COOKIES_AND_SITE_DATA.
As a result, "Forget About This Site" and other per-site or per-principal clearing leave the site's Alt-Svc mappings in place, so the site can still recognize the client on the next visit through an alternative service it advertised earlier. Conversely, deleteByRange drops every mapping regardless of the time range, because nsHttpHandler ignores the range passed with the notification.
Possible fix: add an Alt-Svc cleaner to ClearDataService.sys.mjs with deleteByHost / deleteByPrincipal / deleteBySite (backed by a host- and origin-attributes-scoped variant of ClearAltServiceMappings) and deleteAll, included in CLEAR_COOKIES_AND_SITE_DATA, and decide whether range-based clearing should keep clearing all mappings.
| Reporter | ||
Updated•14 days ago
|
Comment 1•14 days ago
|
||
| frontend-triage | ||
The analysis in comment 0 matches the code. nsHttpHandler.cpp only ever calls AltSvcCache::ClearAltServiceMappings(), which clears every mapping. In ClearDataService.sys.mjs, only SessionHistoryCleaner.deleteAll/deleteByRange reach that path, and no cleaner handles Alt-Svc for a single host, principal or site.
Some notes for whoever picks this up:
- New XPCOM method. The only Alt-Svc API JS can reach today is the test-only
altSvcCacheKeysin nsIHttpProtocolHandler.idl, so add the new methods there: a by-host one and a by-site one, both taking an OA-pattern JSON. Model the pattern plumbing (parent-process check,OriginAttributesPattern::Init) onnsISSLTokensCache'sremoveSSLTokensBy*AndOriginAttributesPatternin SSLTokensCache.cpp. - Storage loop. Base it on
ClearAltServiceMappingsMatchingOAin AlternateServices.cpp, or onDeleteDecisionsByHostin nsClientAuthRemember.cpp. Rebuild eachAltSvcMappingfrom the stored value, not the key, because the OA suffix can contain:. Then matchOriginHost()and the OA, andRemove()with the entry's Private/Persistent type. - Lazy-init pitfall.
mStorageis only set byEnsureStorageInited()(AlternateServices.cpp), and that only runs on the firstGetAltServiceMapping. The existing clear methods return early when!mStorage, so a clear issued before any HTTP load in the session silently leavesAlternateServices.binalone. The new methods, and ideallyClearAltServiceMappings, should callEnsureStorageInited()first. - Partitioned entries. Mappings carry
partitionKey, sodeleteBySiteshould also remove entries partitioned under the site, ashasSite()-based cleaners such asClientAuthRememberCleanerdo. Matching on host alone leaves those behind. - Flag. The simplest option is to add the new
AltSvcCleaner(deleteByHost/deleteByPrincipal/deleteBySite/deleteAll) toFLAGS_MAPunderCLEAR_TLS_TOKEN_CACHE. Its doc comment in nsIClearDataService.idl already describes this kind of server-set "recognize a returning client" connection state. It is already part ofCLEAR_FORGET_ABOUT_SITE,CLEAR_COOKIES_AND_SITE_DATAand tracker purging, and it costs none of the few free bits. WithoutdeleteByRange, range clears fall back todeleteAll, which is the same as today's behaviour. - Tests. Extend test_ssl_tokens_cache.js or add a sibling Alt-Svc test, seeding mappings the way test_freshconnection_origin_attributes.js does (
x-altsvcheader, check viaaltSvcCacheKeys). Cover host, site including a partitioned entry, principal, and an unrelated host that must survive.
Suggested severity: S3. After "Forget About This Site" or a per-site clear, a site that advertised Alt-Svc can still tell it was visited before, which is a privacy gap in data clearing, but there is no data loss or breakage, and clearing all history removes the mappings.
If you'd like to provide feedback on this comment, please use the 👍 or 👎 reaction.
If you want to categorize your feedback you can add one of the following tags: ai-triage-{wrong-file, wrong-cause, hallucination, out-of-scope, not-a-bug, wrong-fix, shallow-fix, wrong-severity}.
Needinfo hackbot@mozilla.tld to have a patch generated for this bug, include any questions or directions as needed in your comment.
Comment 2•14 days ago
|
||
Alt-Svc mappings were only cleared wholesale (purge-session-history / last-pb-context-exited), so per-host, per-principal and per-site clearing such as "Forget About This Site" left them in place.
- AltSvcCache: add ClearAltServiceMappingsByHost / ClearAltServiceMappingsBySite (OriginAttributesPattern aware; by-site also removes mappings partitioned under the site), sharing one storage loop with ClearAltServiceMappingsMatchingOA. Entries are matched on the mapping rebuilt from the stored value, not the key.
- Clear methods now call EnsureStorageInited() so clearing before the first HTTP load in a session still affects AlternateServices.bin.
- nsIHttpProtocolHandler: expose clearAltSvcMappingsByHost / clearAltSvcMappingsBySite / clearAllAltSvcMappings (parent process only).
- ClearDataService: new AltSvcCleaner under CLEAR_TLS_TOKEN_CACHE (server-set "recognize a returning client" connection state, already part of CLEAR_FORGET_ABOUT_SITE and CLEAR_COOKIES_AND_SITE_DATA). deleteByHost mirrors TlsTokenCacheCleaner (all containers, partitionKey propagated). Range clears fall back to deleteAll, as before.
Description
•