Firefox: a compromised content process can read any origin's blob: contents
Categories
(Core :: DOM: Content Processes, defect)
Tracking
()
People
(Reporter: manhluat93.php, Unassigned)
Details
(Keywords: reporter-external, Whiteboard: [client-bounty-form])
Attachments
(4 files)
This is a Site Isolation bypass. A compromised attacker.com content process could read the blob: contents of any other origin - e.g. victim.com - across the process boundary Site Isolation exists to enforce. Blob contents are arbitrary same-origin-confined application data (generated/decrypted files, documents, tokens), so this is a cross-origin data disclosure.
The cause is two parent-side IPC handlers on the blob-URL path that trust a renderer-supplied URL/principal without calling ContentParent::ValidatePrincipal: the first hands the caller a victim origin's blob: URLs, the second hands it their bytes.
1. WindowGlobalParent::RecvLoadURI transmits a victim origin's blob URLs to the caller
mozilla::ipc::IPCResult WindowGlobalParent::RecvLoadURI(
const MaybeDiscarded<dom::BrowsingContext>& aTargetBC,
nsDocShellLoadState* aLoadState, bool aSetNavigating) {
...
if (!nsContentUtils::CanNavigate(BrowsingContext(), targetBC.get(),
DocumentPrincipal(), true)) // <<---(1)
return IPC_FAIL(this, "... (!CanNavigate())");
targetBC->LoadURI(aLoadState, aSetNavigating); // <<---(2)
}
// nsContentUtils::CanNavigate(aSource, aTarget, aDocumentPrincipal, aConsiderOpener)
if (aTarget == aSource || aTarget == aSource->Top())
return true; // <<---(3)
// BrowsingContext::LoadURI, parent branch:
} else if (XRE_IsParentProcess()) {
if (ContentParent* cp = Canonical()->GetContentParent()) { // cp = the caller's process
cp->TransmitBlobDataIfBlobURL(aLoadState->URI(), mOriginAttributes); // <<---(4)
void ContentParent::TransmitBlobURLsForPrincipal(nsIPrincipal* aPrincipal) {
...
BlobURLProtocolHandler::ForEachBlobURL([&](..., const nsACString& aURI, bool aRevoked) {
if (originHash != ComputeLoadedOriginHash(aBlobPrincipal)) return true;
registrations.AppendElement(BlobURLRegistrationData(nsCString(aURI), ...)); // <<---(5)
});
(void)SendInitBlobURLs(registrations); // <<---(6)
}
CanNavigate (1) is a frame-navigation check with no URL argument and returns true for the caller's own frame (3), so a webIsolated=attacker.com process navigating its own frame to blob:https://victim.com/<any-uuid> passes it. In the parent, TransmitBlobDataIfBlobURL (4) derives the principal from the renderer-supplied URL string and sends every blob URL registered for that origin (6) to the caller's process. The registrations carry the URL and principal, not bytes. DocumentLoadListener calls ValidatePrincipal before its copy of this transmit; this path does not.
2. ContentParent::RecvBlobURLDataRequest returns a cross-origin blob's bytes
mozilla::ipc::IPCResult ContentParent::RecvBlobURLDataRequest(
const nsACString& aBlobURL, nsIPrincipal* aTriggeringPrincipal,
nsIPrincipal* aLoadingPrincipal, ...) {
if (!BlobURLProtocolHandler::GetDataEntry(
aBlobURL, getter_AddRefs(blobImpl), aLoadingPrincipal,
aTriggeringPrincipal, ...)) // <<---(7) no ValidatePrincipal
return aResolver(NS_ERROR_DOM_BAD_URI), IPC_OK();
aResolver(ipcBlob); // serves the bytes
}
// BlobURLProtocolHandler::GetDataEntry
if ((!aLoadingPrincipal || !aLoadingPrincipal->IsSystemPrincipal()) && // <<---(8) System skips the OA check
!IsOriginAttributesEqualIgnoringFPD(aOriginAttributes, info->mPrincipal->...))
return false;
if (!aTriggeringPrincipal->Subsumes(info->mPrincipal)) // <<---(9) System subsumes every origin
return false;
RecvBlobURLDataRequest passes the renderer-supplied principals straight to GetDataEntry (7) without ValidatePrincipal. The system principal skips the origin-attributes gate (8) and subsumes every origin (9), so a content process that claims the system principal reads any origin's blob. ParamTraits<nsIPrincipal*>::Read reconstructs whatever PrincipalInfo the child sends - including SystemPrincipalInfo - with no check on the sender, and ValidatePrincipal (the only thing that would reject it) is not called on this handler.
Chained, a compromised attacker.com process reads the contents of every blob: URL victim.com holds, knowing only https://victim.com.
Steps to reproduce:
git apply poc/instrument.patch, then./mach build.- Set the Firefox binary path in
poc/poc.sh, then runpoc/poc.sh. - Click RUN EXPLOIT in the attacker tab.
- The terminal prints STEP 1..4 - STEP 2 is the victim's real blob URL, STEP 4 is its bytes. Captured run:
poc/EVIDENCE_full_chain_secret.log.
Tested on: mozilla-central 24cab6a0399d, self-built ASan, Fission on.
Fix: call ContentParent::ValidatePrincipal (without AllowSystem) on the URL's derived principal before the BrowsingContext::LoadURI parent-branch transmit, and on the principals in RecvBlobURLDataRequest, as DocumentLoadListener already does.
On the PoC patch: it only simulates a compromised renderer, a state achieved by RCE in a renderer process. It sends the two IPCs such a renderer would (LoadURI, then BlobURLDataRequest with a system principal) and prints the trace; no security logic is changed.
| Reporter | ||
Comment 1•4 months ago
|
||
| Reporter | ||
Comment 2•4 months ago
|
||
| Reporter | ||
Comment 3•4 months ago
|
||
Updated•4 months ago
|
Updated•4 months ago
|
Description
•