No-Vary-Search crosses cache identity extensions and exposes cross-origin POST responses
Categories
(Core :: Networking: Cache, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox154 | --- | affected |
People
(Reporter: 5up3rh3i, Unassigned)
References
Details
(Keywords: ai-involved, reporter-external, Whiteboard: [client-bounty-form])
Attachments
(3 files)
Summary
Firefox uses aIdExtension as part of the HTTP cache identity. POST requests
receive a unique extension, while cross-origin fetch/XHR, HEAD, TRR, and other
specialized consumers use additional extensions. The cache API explicitly
requires entries with different extensions to remain completely distinct.
Firefox 154 enables No-Vary-Search cache matching for release users. On an
exact-key miss, the new secondary lookup searches every No-Vary-Search entry
with the same URL base path, but does not require the candidate's
mEnhanceID to equal the incoming aIdExtension.
This allows a cross-origin POST response loaded into an unreadable iframe to be
returned later to a classic script GET. The POST response then executes in the
attacker document even though the server receives no GET request.
The attached product PoC uses two origins and requires no Firefox source
modification, privileged page, CORS opt-in, missing Vary header, or
compromised content process.
Tested Builds
Firefox 154 local Windows x64 build:
Version: 154.0a1
BuildID: 20260730050333
Source revision: c0dff85fa67e5ab148ce20d4298c13f13ceec342
Official Windows x64 Nightly:
Version: 155.0a1
BuildID: 20260727131500
SourceStamp: be36ed55e648665f0098388d4b1a07e94da92a18
The vulnerable code is also present at the latest main revision:
079065d33b0b788f93395938d10660927761dceb
2026-07-31
The default network.cache.no_vary_search setting was left untouched in both
positive tests.
Security Boundary
A page on http://localhost:<port> submits a form POST to
http://127.0.0.1:<port>/target.js in a hidden iframe. The iframe may receive
the target response, but the attacker page cannot inspect its cross-origin
body because of the same-origin policy.
The target's POST response contains a random target-origin secret:
window.__nvsPostSecret = "NVS_POST_SECRET_<random>";
It is explicitly cacheable and carries:
Content-Type: application/javascript
Cache-Control: public, max-age=600
No-Vary-Search: key-order
The attacker then inserts a classic script using the same URL. That is a GET,
and the server's real GET response contains only:
window.__nvsNetworkGetExecuted = true;
Without this bug, the POST response and GET request have different cache
identities and the GET must reach the server. With the bug, Firefox returns the
cached POST entry to the script channel. Classic external script code executes
in the embedding document, so the target response writes its secret into the
attacker global.
This is a direct cross-origin response disclosure. The leaked data belongs to
the target origin's POST response and is not available through the target's GET
endpoint.
Root Cause
netwerk/cache2/nsICacheStorage.idl defines aIdExtension as a strict identity
component:
Two entries with the same aURI but different aIdExtension will be completely
different entries.
nsHttpChannel::Connect() assigns each POST/PATCH transaction a unique
mPostID:
if (mRequestHead.IsPost() || mRequestHead.IsPatch()) {
if (mPostID == 0) {
mPostID = gHttpHandler->GenerateUniqueID();
}
}
nsHttpChannel::OpenCacheEntryInternal() places that ID in the extension:
if (mPostID) {
mCacheIdExtension.AppendInt(mPostID);
}
The exact cache lookup correctly includes the incoming extension:
rv = CacheEntry::HashingKey(""_ns, aIdExtension, aURI, entryKey);
bool entryExists = entries->Get(entryKey, getter_AddRefs(entry));
On an exact miss, the No-Vary-Search path retrieves all candidates sharing the
URL base path:
auto candidates = entries->mNoVarySearchIndex.Lookup(basePath);
for (const auto& fullKey : *candidates) {
RefPtr<CacheEntry> candidate;
if (!entries->Get(fullKey, getter_AddRefs(candidate))) {
continue;
}
if (URLsAreEquivalentModuloVariationConfig(incomingURI,
candidateURI, data)) {
entry = candidate;
entryExists = true;
break;
}
}
fullKey includes the candidate's extension, and CacheEntry exposes the value
through GetEnhanceID(), but the loop never compares it with
aIdExtension.
The later nsHttpChannel::OnCacheEntryCheck() method check only rejects a
cached HEAD response when the current request is not HEAD:
if (methodWasHead && !mRequestHead.IsHead()) {
*aResult = ENTRY_NOT_WANTED;
return NS_OK;
}
It does not reject POST-to-GET reuse because the cache key extension was
supposed to make that combination unreachable.
The missing extension check was introduced by:
958a45100d624554a6a9e04e6480367478cafbe6
Bug 2038008 - nsHttpChannel: store No-Vary-Search metadata and notify cache index on response
The feature was enabled for release users by:
897e718ea64b21a1e29e16e4636b249c343ca246
Bug 2038013 - Enable no-vary-search http caching extension for release users
Reproduction
Install Selenium and run:
python poc/run_probe.py `
--firefox C:\path\to\firefox.exe `
--geckodriver C:\path\to\geckodriver.exe `
--output result.json
The script starts both local origins, creates a fresh Firefox profile, runs the
page, and records both the browser result and every target request.
Attachments:
poc/run_probe.py
poc/result-nightly-155.json
poc/control-nightly-155.json
Firefox 154 with the default pref:
{
"page": {
"attackerOrigin": "http://localhost:52394",
"targetOrigin": "http://127.0.0.1:52394",
"scriptStatus": "loaded",
"postSecret": "NVS_POST_SECRET_cf1b684249af51c3",
"networkGetBodyExecuted": false
},
"server": {
"postCount": 1,
"getCount": 0
},
"vulnerable": true
}
Nightly 155 with the default pref:
{
"page": {
"postSecret": "NVS_POST_SECRET_ae58b498f44c264c",
"networkGetBodyExecuted": false
},
"server": {
"postCount": 1,
"getCount": 0
},
"vulnerable": true
}
For the differential control:
python poc/run_probe.py `
--firefox C:\path\to\firefox.exe `
--geckodriver C:\path\to\geckodriver.exe `
--nvs disabled `
--output control.json
Firefox 154 then performs the real GET and does not expose the POST response:
{
"page": {
"postSecret": null,
"networkGetBodyExecuted": true
},
"server": {
"postCount": 1,
"getCount": 1
},
"vulnerable": false
}
Related Cache-Partition Bypass
The same missing check also crosses the FETCH extension added by Bug 1816390
to fix CVE-2024-1554. A cross-origin fetch entry can therefore be returned to a
normal resource request. This is the same root cause and fix boundary, so it is
included here rather than reported separately.
The POST-to-script PoC is the primary security proof because it does not depend
on CORS, a response-varying request header, or a missing Vary declaration.
Suggested Fix
No-Vary-Search may alter only URL query equivalence. It must preserve all cache
identity fields outside the URL.
Before considering a candidate, require its extension to equal the incoming
extension:
if (!candidate->GetEnhanceID().Equals(aIdExtension)) {
continue;
}
Alternatively, key mNoVarySearchIndex by both base path and
aIdExtension.
Regression coverage should verify that No-Vary-Search never matches across
POST IDs, FETCH, HEAD, TRR, dictionary, or future extensions.
Comment 3•4 months ago
|
||
Is this a 154 and upwards only issue? And does that mean we can fix before this goes to release or can disable/postpone rollout?
Updated•4 months ago
|
Comment 4•4 months ago
|
||
The bug has a release status flag that shows some version of Firefox is affected, thus it will be considered confirmed.
Comment 5•3 months ago
|
||
Hi, sorry for missing this last week. The no-vary-search cache stuff isn't actually related to Speculation Rules, and it was implemented by Sunil (who's on PTO until September) - I wasn't involved.
Could this be redirected to someone on the Necko team?
Comment 6•3 months ago
|
||
Fixed in bug 2059207
Updated•3 months ago
|
Updated•24 days ago
|
Description
•