From 8098b926f8e893a610397238e1b80cb4ef3f4668 Mon Sep 17 00:00:00 2001 From: Fedor Date: Sun, 7 Feb 2021 17:32:58 +0200 Subject: [PATCH] Check for triggering principal URI in FTP subresource check. --- dom/security/nsContentSecurityManager.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dom/security/nsContentSecurityManager.cpp b/dom/security/nsContentSecurityManager.cpp index 298dc810e..d33f962ec 100644 --- a/dom/security/nsContentSecurityManager.cpp +++ b/dom/security/nsContentSecurityManager.cpp @@ -149,8 +149,16 @@ nsContentSecurityManager::CheckFTPSubresourceLoad(nsIChannel* aChannel) nsIPrincipal* triggeringPrincipal = loadInfo->TriggeringPrincipal(); nsCOMPtr tURI; triggeringPrincipal->GetURI(getter_AddRefs(tURI)); + if (!tURI) { + // We don't have a triggering principal URI, meaning this isn't actually + // a subresource, but rather a top-level document, i.e. something we can + // display in-browser and might be saving as-is. Allow the load. + return NS_OK; + } bool isTrigFtpURI = (NS_SUCCEEDED(tURI->SchemeIs("ftp", &isTrigFtpURI)) && isTrigFtpURI); if (isTrigFtpURI) { + // The document loading this resource is also on FTP, satisfying the SOP. + // Allow the load. return NS_OK; }