Backed out changeset b3538b7016aa (bug 1599438) for bustages on TestHttpFuzzing.cpp . CLOSED TREE

This commit is contained in:
Narcis Beleuzu 2020-01-15 06:03:55 +02:00
parent 6724b78bd2
commit c59ca04e7b
23 changed files with 106 additions and 132 deletions

View File

@ -7732,8 +7732,7 @@ nsresult nsDocShell::CreateContentViewer(const nsACString& aContentType,
// Mark the channel as being a document URI...
aOpenedChannel->GetLoadFlags(&loadFlags);
loadFlags |= nsIChannel::LOAD_DOCUMENT_URI;
nsCOMPtr<nsILoadInfo> loadInfo = aOpenedChannel->LoadInfo();
if (SandboxFlagsImplyCookies(loadInfo->GetSandboxFlags())) {
if (SandboxFlagsImplyCookies(mBrowsingContext->GetSandboxFlags())) {
loadFlags |= nsIRequest::LOAD_DOCUMENT_NEEDS_COOKIE;
}
@ -8279,7 +8278,7 @@ nsresult nsDocShell::PerformRetargeting(nsDocShellLoadState* aLoadState,
// should match this one when both are applicable.
nsCOMPtr<nsILoadInfo> secCheckLoadInfo = new LoadInfo(
mScriptGlobal, aLoadState->TriggeringPrincipal(), requestingContext,
nsILoadInfo::SEC_ONLY_FOR_EXPLICIT_CONTENTSEC_CHECK, 0);
nsILoadInfo::SEC_ONLY_FOR_EXPLICIT_CONTENTSEC_CHECK);
// Since Content Policy checks are performed within docShell as well as
// the ContentSecurityManager we need a reliable way to let certain
@ -9827,6 +9826,8 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState,
return NS_ERROR_FAILURE;
}
bool isSandBoxed = mBrowsingContext->GetSandboxFlags() & SANDBOXED_ORIGIN;
// We want to inherit aLoadState->PrincipalToInherit() when:
// 1. ChannelShouldInheritPrincipal returns true.
// 2. aLoadState->URI() is not data: URI, or data: URI is not
@ -9848,7 +9849,6 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState,
nsLoadFlags loadFlags = mDefaultLoadFlags;
nsSecurityFlags securityFlags =
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL;
uint32_t sandboxFlags = mBrowsingContext->GetSandboxFlags();
if (aLoadState->FirstParty()) {
// tag first party URL loads
@ -9864,16 +9864,16 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState,
if (inheritPrincipal) {
securityFlags |= nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL;
}
if (isSandBoxed) {
securityFlags |= nsILoadInfo::SEC_SANDBOXED;
}
RefPtr<LoadInfo> loadInfo =
(contentPolicyType == nsIContentPolicy::TYPE_DOCUMENT)
? new LoadInfo(loadingWindow, aLoadState->TriggeringPrincipal(),
topLevelLoadingContext, securityFlags, sandboxFlags)
topLevelLoadingContext, securityFlags)
: new LoadInfo(loadingPrincipal, aLoadState->TriggeringPrincipal(),
loadingNode, securityFlags, contentPolicyType,
Maybe<mozilla::dom::ClientInfo>(),
Maybe<mozilla::dom::ServiceWorkerDescriptor>(),
sandboxFlags);
loadingNode, securityFlags, contentPolicyType);
if (aLoadState->PrincipalToInherit()) {
loadInfo->SetPrincipalToInherit(aLoadState->PrincipalToInherit());
@ -9953,14 +9953,14 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState,
// same process), which breaks if we serialize to the parent process.
bool canUseDocumentChannel =
aLoadState->HasLoadFlags(INTERNAL_LOAD_FLAGS_IS_SRCDOC)
? (sandboxFlags & SANDBOXED_ORIGIN)
? isSandBoxed
: SchemeUsesDocChannel(aLoadState->URI());
if (StaticPrefs::browser_tabs_documentchannel() && XRE_IsContentProcess() &&
canUseDocumentChannel) {
channel = new DocumentChannelChild(aLoadState, loadInfo, initiatorType,
loadFlags, mLoadType, cacheKey, isActive,
isTopLevelDoc, sandboxFlags);
channel = new DocumentChannelChild(
aLoadState, loadInfo, initiatorType, loadFlags, mLoadType, cacheKey,
isActive, isTopLevelDoc, mBrowsingContext->GetSandboxFlags());
channel->SetNotificationCallbacks(this);
} else if (!CreateAndConfigureRealChannelForLoadState(
aLoadState, loadInfo, this, this, initiatorType, loadFlags,

View File

@ -2105,15 +2105,9 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(Document)
uint32_t nsid = tmp->GetDefaultNamespaceID();
nsAutoCString uri;
if (tmp->mDocumentURI) uri = tmp->mDocumentURI->GetSpecOrDefault();
static const char* kNSURIs[] = {"([none])", "(xmlns)", "(xml)",
"(xhtml)", "(XLink)", "(XSLT)",
"(MathML)", "(RDF)", "(XUL)"};
if (nsid < ArrayLength(kNSURIs)) {
SprintfLiteral(name, "Document %s %s %s", loadedAsData.get(),
kNSURIs[nsid], uri.get());
} else {
SprintfLiteral(name, "Document %s %s", loadedAsData.get(), uri.get());
}
const char* nsuri = nsNameSpaceManager::GetNameSpaceDisplayName(nsid);
SprintfLiteral(name, "Document %s %s %s", loadedAsData.get(), nsuri,
uri.get());
cb.DescribeRefCountedNode(tmp->mRefCnt.get(), name);
} else {
NS_IMPL_CYCLE_COLLECTION_DESCRIBE(Document, tmp->mRefCnt.get())
@ -3128,10 +3122,10 @@ nsresult Document::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel,
// immutable after being set here.
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(aContainer);
// If this is an error page, don't inherit sandbox flags
// If this is an error page, don't inherit sandbox flags from docshell
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
if (docShell && !loadInfo->GetLoadErrorPage()) {
mSandboxFlags = loadInfo->GetSandboxFlags();
mSandboxFlags = docShell->GetBrowsingContext()->GetSandboxFlags();
WarnIfSandboxIneffective(docShell, mSandboxFlags, GetChannel());
}

View File

@ -2271,6 +2271,7 @@ nsresult nsObjectLoadingContent::OpenChannel() {
RefPtr<ObjectInterfaceRequestorShim> shim =
new ObjectInterfaceRequestorShim(this);
bool isSandBoxed = doc->GetSandboxFlags() & SANDBOXED_ORIGIN;
bool inherit = nsContentUtils::ChannelShouldInheritPrincipal(
thisContent->NodePrincipal(), mURI,
true, // aInheritForAboutBlank
@ -2284,6 +2285,9 @@ nsresult nsObjectLoadingContent::OpenChannel() {
if (inherit && !isURIUniqueOrigin) {
securityFlags |= nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL;
}
if (isSandBoxed) {
securityFlags |= nsILoadInfo::SEC_SANDBOXED;
}
nsContentPolicyType contentPolicyType = GetContentPolicyType();
@ -2294,9 +2298,7 @@ nsresult nsObjectLoadingContent::OpenChannel() {
shim, // aCallbacks
nsIChannel::LOAD_CALL_CONTENT_SNIFFERS |
nsIChannel::LOAD_BYPASS_SERVICE_WORKER |
nsIRequest::LOAD_HTML_OBJECT_DATA,
nullptr, // aIoService
doc->GetSandboxFlags());
nsIRequest::LOAD_HTML_OBJECT_DATA);
NS_ENSURE_SUCCESS(rv, rv);
if (inherit) {
nsCOMPtr<nsILoadInfo> loadinfo = chan->LoadInfo();

View File

@ -666,6 +666,7 @@ static void LogSecurityFlags(nsSecurityFlags securityFlags) {
{nsILoadInfo::SEC_COOKIES_SAME_ORIGIN, "SEC_COOKIES_SAME_ORIGIN"},
{nsILoadInfo::SEC_COOKIES_OMIT, "SEC_COOKIES_OMIT"},
{nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL, "SEC_FORCE_INHERIT_PRINCIPAL"},
{nsILoadInfo::SEC_SANDBOXED, "SEC_SANDBOXED"},
{nsILoadInfo::SEC_ABOUT_BLANK_INHERITS, "SEC_ABOUT_BLANK_INHERITS"},
{nsILoadInfo::SEC_ALLOW_CHROME, "SEC_ALLOW_CHROME"},
{nsILoadInfo::SEC_DISALLOW_SCRIPT, "SEC_DISALLOW_SCRIPT"},

View File

@ -1742,7 +1742,7 @@ nsresult WebSocketImpl::InitializeConnection(
rv = wsChannel->InitLoadInfoNative(
doc, doc ? doc->NodePrincipal() : aPrincipal, aPrincipal, aCookieSettings,
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
nsIContentPolicy::TYPE_WEBSOCKET, 0);
nsIContentPolicy::TYPE_WEBSOCKET);
MOZ_ASSERT(NS_SUCCEEDED(rv));
if (!mRequestedProtocolList.IsEmpty()) {

View File

@ -43,7 +43,6 @@
#include "nsIJARURI.h"
#include "nsLayoutCID.h"
#include "nsReadableUtils.h"
#include "nsSandboxFlags.h"
#include "nsIURI.h"
#include "nsIURIMutator.h"
@ -2377,12 +2376,11 @@ nsresult XMLHttpRequestMainThread::CreateChannel() {
nsSecurityFlags secFlags;
nsLoadFlags loadFlags = nsIRequest::LOAD_BACKGROUND;
uint32_t sandboxFlags = 0;
if (mPrincipal->IsSystemPrincipal()) {
// When chrome is loading we want to make sure to sandbox any potential
// result document. We also want to allow cross-origin loads.
secFlags = nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL;
sandboxFlags = SANDBOXED_ORIGIN;
secFlags = nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL |
nsILoadInfo::SEC_SANDBOXED;
} else if (IsSystemXHR()) {
// For pages that have appropriate permissions, we want to still allow
// cross-origin loads, but make sure that the any potential result
@ -2413,7 +2411,7 @@ nsresult XMLHttpRequestMainThread::CreateChannel() {
nullptr, // aPerformanceStorage
loadGroup,
nullptr, // aCallbacks
loadFlags, nullptr, sandboxFlags);
loadFlags);
} else if (mClientInfo.isSome()) {
rv = NS_NewChannel(getter_AddRefs(mChannel), mRequestURL, mPrincipal,
mClientInfo.ref(), mController, secFlags,
@ -2422,7 +2420,7 @@ nsresult XMLHttpRequestMainThread::CreateChannel() {
mPerformanceStorage, // aPerformanceStorage
loadGroup,
nullptr, // aCallbacks
loadFlags, nullptr, sandboxFlags);
loadFlags);
} else {
// Otherwise use the principal.
rv = NS_NewChannel(getter_AddRefs(mChannel), mRequestURL, mPrincipal,
@ -2431,7 +2429,7 @@ nsresult XMLHttpRequestMainThread::CreateChannel() {
mPerformanceStorage, // aPerformanceStorage
loadGroup,
nullptr, // aCallbacks
loadFlags, nullptr, sandboxFlags);
loadFlags);
}
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -571,8 +571,7 @@ nsresult LoadInfoToLoadInfoArgs(nsILoadInfo* aLoadInfo,
loadingPrincipalInfo, triggeringPrincipalInfo, principalToInheritInfo,
sandboxedLoadingPrincipalInfo, topLevelPrincipalInfo,
topLevelStorageAreaPrincipalInfo, optionalResultPrincipalURI,
aLoadInfo->GetSecurityFlags(), aLoadInfo->GetSandboxFlags(),
aLoadInfo->InternalContentPolicyType(),
aLoadInfo->GetSecurityFlags(), aLoadInfo->InternalContentPolicyType(),
static_cast<uint32_t>(aLoadInfo->GetTainting()),
aLoadInfo->GetBlockAllMixedContent(),
aLoadInfo->GetUpgradeInsecureRequests(),
@ -761,7 +760,7 @@ nsresult LoadInfoArgsToLoadInfo(
sandboxedLoadingPrincipal, topLevelPrincipal,
topLevelStorageAreaPrincipal, resultPrincipalURI, cookieSettings,
cspToInherit, clientInfo, reservedClientInfo, initialClientInfo,
controller, loadInfoArgs.securityFlags(), loadInfoArgs.sandboxFlags(),
controller, loadInfoArgs.securityFlags(),
loadInfoArgs.contentPolicyType(),
static_cast<LoadTainting>(loadInfoArgs.tainting()),
loadInfoArgs.blockAllMixedContent(),

View File

@ -56,8 +56,7 @@ LoadInfo::LoadInfo(
nsINode* aLoadingContext, nsSecurityFlags aSecurityFlags,
nsContentPolicyType aContentPolicyType,
const Maybe<mozilla::dom::ClientInfo>& aLoadingClientInfo,
const Maybe<mozilla::dom::ServiceWorkerDescriptor>& aController,
uint32_t aSandboxFlags)
const Maybe<mozilla::dom::ServiceWorkerDescriptor>& aController)
: mLoadingPrincipal(aLoadingContext ? aLoadingContext->NodePrincipal()
: aLoadingPrincipal),
mTriggeringPrincipal(aTriggeringPrincipal ? aTriggeringPrincipal
@ -68,7 +67,6 @@ LoadInfo::LoadInfo(
mLoadingContext(do_GetWeakReference(aLoadingContext)),
mContextForTopLevelLoad(nullptr),
mSecurityFlags(aSecurityFlags),
mSandboxFlags(aSandboxFlags),
mInternalContentPolicyType(aContentPolicyType),
mTainting(LoadTainting::Basic),
mBlockAllMixedContent(false),
@ -136,7 +134,7 @@ LoadInfo::LoadInfo(
aLoadingContext->NodePrincipal() == aLoadingPrincipal);
// if the load is sandboxed, we can not also inherit the principal
if (mSandboxFlags & SANDBOXED_ORIGIN) {
if (mSecurityFlags & nsILoadInfo::SEC_SANDBOXED) {
mForceInheritPrincipalDropped =
(mSecurityFlags & nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL);
mSecurityFlags &= ~nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL;
@ -324,13 +322,12 @@ LoadInfo::LoadInfo(
LoadInfo::LoadInfo(nsPIDOMWindowOuter* aOuterWindow,
nsIPrincipal* aTriggeringPrincipal,
nsISupports* aContextForTopLevelLoad,
nsSecurityFlags aSecurityFlags, uint32_t aSandboxFlags)
nsSecurityFlags aSecurityFlags)
: mLoadingPrincipal(nullptr),
mTriggeringPrincipal(aTriggeringPrincipal),
mPrincipalToInherit(nullptr),
mContextForTopLevelLoad(do_GetWeakReference(aContextForTopLevelLoad)),
mSecurityFlags(aSecurityFlags),
mSandboxFlags(aSandboxFlags),
mInternalContentPolicyType(nsIContentPolicy::TYPE_DOCUMENT),
mTainting(LoadTainting::Basic),
mBlockAllMixedContent(false),
@ -370,7 +367,7 @@ LoadInfo::LoadInfo(nsPIDOMWindowOuter* aOuterWindow,
MOZ_ASSERT(mTriggeringPrincipal);
// if the load is sandboxed, we can not also inherit the principal
if (mSandboxFlags & SANDBOXED_ORIGIN) {
if (mSecurityFlags & nsILoadInfo::SEC_SANDBOXED) {
mForceInheritPrincipalDropped =
(mSecurityFlags & nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL);
mSecurityFlags &= ~nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL;
@ -438,7 +435,6 @@ LoadInfo::LoadInfo(const LoadInfo& rhs)
mLoadingContext(rhs.mLoadingContext),
mContextForTopLevelLoad(rhs.mContextForTopLevelLoad),
mSecurityFlags(rhs.mSecurityFlags),
mSandboxFlags(rhs.mSandboxFlags),
mInternalContentPolicyType(rhs.mInternalContentPolicyType),
mTainting(rhs.mTainting),
mBlockAllMixedContent(rhs.mBlockAllMixedContent),
@ -495,10 +491,9 @@ LoadInfo::LoadInfo(
const Maybe<ClientInfo>& aReservedClientInfo,
const Maybe<ClientInfo>& aInitialClientInfo,
const Maybe<ServiceWorkerDescriptor>& aController,
nsSecurityFlags aSecurityFlags, uint32_t aSandboxFlags,
nsContentPolicyType aContentPolicyType, LoadTainting aTainting,
bool aBlockAllMixedContent, bool aUpgradeInsecureRequests,
bool aBrowserUpgradeInsecureRequests,
nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType,
LoadTainting aTainting, bool aBlockAllMixedContent,
bool aUpgradeInsecureRequests, bool aBrowserUpgradeInsecureRequests,
bool aBrowserWouldUpgradeInsecureRequests, bool aForceAllowDataURI,
bool aAllowInsecureRedirectToDataURI, bool aBypassCORSChecks,
bool aSkipContentPolicyCheckForWebRequest,
@ -533,7 +528,6 @@ LoadInfo::LoadInfo(
mController(aController),
mLoadingContext(do_GetWeakReference(aLoadingContext)),
mSecurityFlags(aSecurityFlags),
mSandboxFlags(aSandboxFlags),
mInternalContentPolicyType(aContentPolicyType),
mTainting(aTainting),
mBlockAllMixedContent(aBlockAllMixedContent),
@ -672,7 +666,7 @@ nsIPrincipal* LoadInfo::FindPrincipalToInherit(nsIChannel* aChannel) {
}
nsIPrincipal* LoadInfo::GetSandboxedLoadingPrincipal() {
if (!(mSandboxFlags & SANDBOXED_ORIGIN)) {
if (!(mSecurityFlags & nsILoadInfo::SEC_SANDBOXED)) {
return nullptr;
}
@ -742,12 +736,6 @@ LoadInfo::GetSecurityFlags(nsSecurityFlags* aResult) {
return NS_OK;
}
NS_IMETHODIMP
LoadInfo::GetSandboxFlags(uint32_t* aResult) {
*aResult = mSandboxFlags;
return NS_OK;
}
NS_IMETHODIMP
LoadInfo::GetSecurityMode(uint32_t* aFlags) {
*aFlags =
@ -846,7 +834,7 @@ LoadInfo::GetForceInheritPrincipalOverruleOwner(bool* aInheritPrincipal) {
NS_IMETHODIMP
LoadInfo::GetLoadingSandboxed(bool* aLoadingSandboxed) {
*aLoadingSandboxed = (mSandboxFlags & SANDBOXED_ORIGIN);
*aLoadingSandboxed = (mSecurityFlags & nsILoadInfo::SEC_SANDBOXED);
return NS_OK;
}

View File

@ -63,15 +63,14 @@ class LoadInfo final : public nsILoadInfo {
const Maybe<mozilla::dom::ClientInfo>& aLoadingClientInfo =
Maybe<mozilla::dom::ClientInfo>(),
const Maybe<mozilla::dom::ServiceWorkerDescriptor>& aController =
Maybe<mozilla::dom::ServiceWorkerDescriptor>(),
uint32_t aSandboxFlags = 0);
Maybe<mozilla::dom::ServiceWorkerDescriptor>());
// Constructor used for TYPE_DOCUMENT loads which have a different
// loadingContext than other loads. This ContextForTopLevelLoad is
// only used for content policy checks.
LoadInfo(nsPIDOMWindowOuter* aOuterWindow, nsIPrincipal* aTriggeringPrincipal,
nsISupports* aContextForTopLevelLoad, nsSecurityFlags aSecurityFlags,
uint32_t aSandboxFlags);
nsISupports* aContextForTopLevelLoad,
nsSecurityFlags aSecurityFlags);
// create an exact copy of the loadinfo
already_AddRefed<nsILoadInfo> Clone() const;
@ -134,7 +133,7 @@ class LoadInfo final : public nsILoadInfo {
const Maybe<mozilla::dom::ClientInfo>& aReservedClientInfo,
const Maybe<mozilla::dom::ClientInfo>& aInitialClientInfo,
const Maybe<mozilla::dom::ServiceWorkerDescriptor>& aController,
nsSecurityFlags aSecurityFlags, uint32_t aSandboxFlags,
nsSecurityFlags aSecurityFlags,
nsContentPolicyType aContentPolicyType, LoadTainting aTainting,
bool aBlockAllMixedContent, bool aUpgradeInsecureRequests,
bool aBrowserUpgradeInsecureRequests,
@ -214,7 +213,6 @@ class LoadInfo final : public nsILoadInfo {
nsWeakPtr mLoadingContext;
nsWeakPtr mContextForTopLevelLoad;
nsSecurityFlags mSecurityFlags;
uint32_t mSandboxFlags;
nsContentPolicyType mInternalContentPolicyType;
LoadTainting mTainting;
bool mBlockAllMixedContent;

View File

@ -117,7 +117,6 @@ interface nsIIOService : nsISupports
in const_MaybeServiceWorkerDescriptorRef aController,
in unsigned long aSecurityFlags,
in unsigned long aContentPolicyType,
in unsigned long aSandboxFlags,
out nsIChannel aResult);
/**

View File

@ -164,13 +164,25 @@ interface nsILoadInfo : nsISupports
* is loading the URI "http://b.com/whatever", GetChannelResultPrincipal
* will return a principal from "http://a.com/".
*
* This flag can not be used together with SANDBOXED_ORIGIN sandbox flag. If
* both are passed to the LoadInfo constructor then this flag will be dropped.
* If you need to know whether this flag would have been present but was dropped
* due to sandboxing, check for the forceInheritPrincipalDropped flag.
* This flag can not be used together with SEC_SANDBOXED. If both are passed
* to the LoadInfo constructor then this flag will be dropped. If you need
* to know whether this flag would have been present but was dropped due to
* sandboxing, check for the forceInheritPrincipalDropped flag.
*/
const unsigned long SEC_FORCE_INHERIT_PRINCIPAL = (1<<7);
/**
* Sandbox the load. The resulting resource will use a freshly created
* null principal. So GetChannelResultPrincipal will always return a
* null principal whenever this flag is set.
*
* This will happen independently of the scheme of the URI that the
* channel is loading.
*
* This flag can not be used together with SEC_FORCE_INHERIT_PRINCIPAL.
*/
const unsigned long SEC_SANDBOXED = (1<<8);
/**
* Inherit the Principal for about:blank.
*/
@ -397,11 +409,6 @@ interface nsILoadInfo : nsISupports
}
%}
/**
* The sandboxFlags of that channel.
*/
[infallible] readonly attribute unsigned long sandboxFlags;
/**
* Allows to query only the security mode bits from above.
*/
@ -627,9 +634,9 @@ interface nsILoadInfo : nsISupports
/**
* The SEC_FORCE_INHERIT_PRINCIPAL flag may be dropped when a load info
* object is created. Specifically, it will be dropped if the SANDBOXED_ORIGIN
* sandbox flag is also present. This flag is set if SEC_FORCE_INHERIT_PRINCIPAL
* was dropped.
* object is created. Specifically, it will be dropped if the SEC_SANDBOXED
* flag is also present. This flag is set if SEC_FORCE_INHERIT_PRINCIPAL was
* dropped.
*/
[infallible] readonly attribute boolean forceInheritPrincipalDropped;
@ -909,7 +916,7 @@ interface nsILoadInfo : nsISupports
attribute nsIURI resultPrincipalURI;
/**
* Returns the null principal of the resulting resource if the SANDBOXED_ORIGIN
* Returns the null principal of the resulting resource if the SEC_SANDBOXED
* flag is set. Otherwise returns null. This is used by
* GetChannelResultPrincipal() to ensure that the same null principal object
* is returned every time.

View File

@ -904,13 +904,13 @@ nsresult nsIOService::NewChannelFromURIWithClientAndController(
nsIPrincipal* aTriggeringPrincipal,
const Maybe<ClientInfo>& aLoadingClientInfo,
const Maybe<ServiceWorkerDescriptor>& aController, uint32_t aSecurityFlags,
uint32_t aContentPolicyType, uint32_t aSandboxFlags, nsIChannel** aResult) {
uint32_t aContentPolicyType, nsIChannel** aResult) {
return NewChannelFromURIWithProxyFlagsInternal(
aURI,
nullptr, // aProxyURI
0, // aProxyFlags
aLoadingNode, aLoadingPrincipal, aTriggeringPrincipal, aLoadingClientInfo,
aController, aSecurityFlags, aContentPolicyType, aSandboxFlags, aResult);
aController, aSecurityFlags, aContentPolicyType, aResult);
}
NS_IMETHODIMP
@ -928,7 +928,7 @@ nsresult nsIOService::NewChannelFromURIWithProxyFlagsInternal(
nsIPrincipal* aTriggeringPrincipal,
const Maybe<ClientInfo>& aLoadingClientInfo,
const Maybe<ServiceWorkerDescriptor>& aController, uint32_t aSecurityFlags,
uint32_t aContentPolicyType, uint32_t aSandboxFlags, nsIChannel** result) {
uint32_t aContentPolicyType, nsIChannel** result) {
// Ideally all callers of NewChannelFromURIWithProxyFlagsInternal provide
// the necessary arguments to create a loadinfo.
//
@ -946,7 +946,7 @@ nsresult nsIOService::NewChannelFromURIWithProxyFlagsInternal(
aContentPolicyType == nsIContentPolicy::TYPE_DOCUMENT) {
loadInfo = new LoadInfo(aLoadingPrincipal, aTriggeringPrincipal,
aLoadingNode, aSecurityFlags, aContentPolicyType,
aLoadingClientInfo, aController, aSandboxFlags);
aLoadingClientInfo, aController);
}
if (!loadInfo) {
JSContext* cx = nsContentUtils::GetCurrentJSContext();
@ -1050,7 +1050,7 @@ nsIOService::NewChannelFromURIWithProxyFlags(
return NewChannelFromURIWithProxyFlagsInternal(
aURI, aProxyURI, aProxyFlags, aLoadingNode, aLoadingPrincipal,
aTriggeringPrincipal, Maybe<ClientInfo>(),
Maybe<ServiceWorkerDescriptor>(), aSecurityFlags, aContentPolicyType, 0,
Maybe<ServiceWorkerDescriptor>(), aSecurityFlags, aContentPolicyType,
result);
}

View File

@ -172,7 +172,7 @@ class nsIOService final : public nsIIOService,
const mozilla::Maybe<mozilla::dom::ClientInfo>& aLoadingClientInfo,
const mozilla::Maybe<mozilla::dom::ServiceWorkerDescriptor>& aController,
uint32_t aSecurityFlags, uint32_t aContentPolicyType,
uint32_t aSandboxFlags, nsIChannel** result);
nsIChannel** result);
nsresult NewChannelFromURIWithProxyFlagsInternal(nsIURI* aURI,
nsIURI* aProxyURI,

View File

@ -313,8 +313,7 @@ nsresult NS_NewChannel(nsIChannel** outChannel, nsIURI* aUri,
nsILoadGroup* aLoadGroup /* = nullptr */,
nsIInterfaceRequestor* aCallbacks /* = nullptr */,
nsLoadFlags aLoadFlags /* = nsIRequest::LOAD_NORMAL */,
nsIIOService* aIoService /* = nullptr */,
uint32_t aSandboxFlags /* = 0 */) {
nsIIOService* aIoService /* = nullptr */) {
return NS_NewChannelInternal(
outChannel, aUri,
nullptr, // aLoadingNode,
@ -322,7 +321,7 @@ nsresult NS_NewChannel(nsIChannel** outChannel, nsIURI* aUri,
nullptr, // aTriggeringPrincipal
Maybe<ClientInfo>(), Maybe<ServiceWorkerDescriptor>(), aSecurityFlags,
aContentPolicyType, aCookieSettings, aPerformanceStorage, aLoadGroup,
aCallbacks, aLoadFlags, aIoService, aSandboxFlags);
aCallbacks, aLoadFlags, aIoService);
}
nsresult NS_NewChannel(nsIChannel** outChannel, nsIURI* aUri,
@ -336,8 +335,7 @@ nsresult NS_NewChannel(nsIChannel** outChannel, nsIURI* aUri,
nsILoadGroup* aLoadGroup /* = nullptr */,
nsIInterfaceRequestor* aCallbacks /* = nullptr */,
nsLoadFlags aLoadFlags /* = nsIRequest::LOAD_NORMAL */,
nsIIOService* aIoService /* = nullptr */,
uint32_t aSandboxFlags /* = 0 */) {
nsIIOService* aIoService /* = nullptr */) {
AssertLoadingPrincipalAndClientInfoMatch(
aLoadingPrincipal, aLoadingClientInfo, aContentPolicyType);
@ -351,7 +349,7 @@ nsresult NS_NewChannel(nsIChannel** outChannel, nsIURI* aUri,
loadingClientInfo, aController, aSecurityFlags,
aContentPolicyType, aCookieSettings,
aPerformanceStorage, aLoadGroup, aCallbacks,
aLoadFlags, aIoService, aSandboxFlags);
aLoadFlags, aIoService);
}
nsresult NS_NewChannelInternal(
@ -365,8 +363,7 @@ nsresult NS_NewChannelInternal(
nsILoadGroup* aLoadGroup /* = nullptr */,
nsIInterfaceRequestor* aCallbacks /* = nullptr */,
nsLoadFlags aLoadFlags /* = nsIRequest::LOAD_NORMAL */,
nsIIOService* aIoService /* = nullptr */,
uint32_t aSandboxFlags /* = 0 */) {
nsIIOService* aIoService /* = nullptr */) {
NS_ENSURE_ARG_POINTER(outChannel);
nsCOMPtr<nsIIOService> grip;
@ -377,7 +374,7 @@ nsresult NS_NewChannelInternal(
rv = aIoService->NewChannelFromURIWithClientAndController(
aUri, aLoadingNode, aLoadingPrincipal, aTriggeringPrincipal,
aLoadingClientInfo, aController, aSecurityFlags, aContentPolicyType,
aSandboxFlags, getter_AddRefs(channel));
getter_AddRefs(channel));
if (NS_FAILED(rv)) {
return rv;
}
@ -498,16 +495,14 @@ nsresult NS_NewChannel(nsIChannel** outChannel, nsIURI* aUri,
nsILoadGroup* aLoadGroup /* = nullptr */,
nsIInterfaceRequestor* aCallbacks /* = nullptr */,
nsLoadFlags aLoadFlags /* = nsIRequest::LOAD_NORMAL */,
nsIIOService* aIoService /* = nullptr */,
uint32_t aSandboxFlags /* = 0 */) {
nsIIOService* aIoService /* = nullptr */) {
NS_ASSERTION(aLoadingNode, "Can not create channel without a loading Node!");
return NS_NewChannelInternal(
outChannel, aUri, aLoadingNode, aLoadingNode->NodePrincipal(),
nullptr, // aTriggeringPrincipal
Maybe<ClientInfo>(), Maybe<ServiceWorkerDescriptor>(), aSecurityFlags,
aContentPolicyType, aLoadingNode->OwnerDoc()->CookieSettings(),
aPerformanceStorage, aLoadGroup, aCallbacks, aLoadFlags, aIoService,
aSandboxFlags);
aPerformanceStorage, aLoadGroup, aCallbacks, aLoadFlags, aIoService);
}
nsresult NS_GetIsDocumentChannel(nsIChannel* aChannel, bool* aIsDocument) {

View File

@ -164,7 +164,7 @@ nsresult NS_NewChannelInternal(
nsILoadGroup* aLoadGroup = nullptr,
nsIInterfaceRequestor* aCallbacks = nullptr,
nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL,
nsIIOService* aIoService = nullptr, uint32_t aSandboxFlags = 0);
nsIIOService* aIoService = nullptr);
// See NS_NewChannelInternal for usage and argument description
nsresult NS_NewChannelInternal(
@ -221,7 +221,7 @@ nsresult NS_NewChannel(
nsILoadGroup* aLoadGroup = nullptr,
nsIInterfaceRequestor* aCallbacks = nullptr,
nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL,
nsIIOService* aIoService = nullptr, uint32_t aSandboxFlags = 0);
nsIIOService* aIoService = nullptr);
// See NS_NewChannelInternal for usage and argument description
nsresult NS_NewChannel(
@ -232,7 +232,7 @@ nsresult NS_NewChannel(
nsILoadGroup* aLoadGroup = nullptr,
nsIInterfaceRequestor* aCallbacks = nullptr,
nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL,
nsIIOService* aIoService = nullptr, uint32_t aSandboxFlags = 0);
nsIIOService* aIoService = nullptr);
// See NS_NewChannelInternal for usage and argument description
nsresult NS_NewChannel(
@ -245,7 +245,7 @@ nsresult NS_NewChannel(
nsILoadGroup* aLoadGroup = nullptr,
nsIInterfaceRequestor* aCallbacks = nullptr,
nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL,
nsIIOService* aIoService = nullptr, uint32_t aSandboxFlags = 0);
nsIIOService* aIoService = nullptr);
nsresult NS_GetIsDocumentChannel(nsIChannel* aChannel, bool* aIsDocument);

View File

@ -77,7 +77,6 @@ struct LoadInfoArgs
PrincipalInfo? topLevelStorageAreaPrincipalInfo;
URIParams? resultPrincipalURI;
uint32_t securityFlags;
uint32_t sandboxFlags;
uint32_t contentPolicyType;
uint32_t tainting;
bool blockAllMixedContent;

View File

@ -206,12 +206,9 @@ BaseWebSocketChannel::InitLoadInfoNative(nsINode* aLoadingNode,
nsIPrincipal* aTriggeringPrincipal,
nsICookieSettings* aCookieSettings,
uint32_t aSecurityFlags,
uint32_t aContentPolicyType,
uint32_t aSandboxFlags) {
mLoadInfo = new LoadInfo(
aLoadingPrincipal, aTriggeringPrincipal, aLoadingNode, aSecurityFlags,
aContentPolicyType, Maybe<mozilla::dom::ClientInfo>(),
Maybe<mozilla::dom::ServiceWorkerDescriptor>(), aSandboxFlags);
uint32_t aContentPolicyType) {
mLoadInfo = new LoadInfo(aLoadingPrincipal, aTriggeringPrincipal,
aLoadingNode, aSecurityFlags, aContentPolicyType);
if (aCookieSettings) {
mLoadInfo->SetCookieSettings(aCookieSettings);
}
@ -226,7 +223,7 @@ BaseWebSocketChannel::InitLoadInfo(nsINode* aLoadingNode,
uint32_t aContentPolicyType) {
return InitLoadInfoNative(aLoadingNode, aLoadingPrincipal,
aTriggeringPrincipal, nullptr, aSecurityFlags,
aContentPolicyType, 0);
aContentPolicyType);
}
NS_IMETHODIMP

View File

@ -58,8 +58,7 @@ class BaseWebSocketChannel : public nsIWebSocketChannel,
nsIPrincipal* aTriggeringPrincipal,
nsICookieSettings* aCookieSettings,
uint32_t aSecurityFlags,
uint32_t aContentPolicyType,
uint32_t aSandboxFlags) override;
uint32_t aContentPolicyType) override;
NS_IMETHOD InitLoadInfo(nsINode* aLoadingNode,
nsIPrincipal* aLoadingPrincipal,
nsIPrincipal* aTriggeringPrincipal,

View File

@ -102,8 +102,7 @@ interface nsIWebSocketChannel : nsISupports
in nsIPrincipal aTriggeringPrincipal,
in nsICookieSettings aCookieSettings,
in unsigned long aSecurityFlags,
in unsigned long aContentPolicyType,
in unsigned long aSandboxFlags);
in unsigned long aContentPolicyType);
/**
* Similar to the previous one but without nsICookieSettings.

View File

@ -10,7 +10,6 @@
#include "nsNetUtil.h"
#include "NullPrincipal.h"
#include "nsCycleCollector.h"
#include "nsSandboxFlags.h"
#include "nsFtpProtocolHandler.h"
@ -68,8 +67,8 @@ static int FuzzingRunNetworkFtp(const uint8_t* data, size_t size) {
nsIRequest::LOAD_FRESH_CONNECTION |
nsIChannel::LOAD_INITIAL_DOCUMENT_URI;
nsSecurityFlags secFlags;
secFlags = nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL;
uint32_t sandboxFlags = SANDBOXED_ORIGIN;
secFlags = nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL |
nsILoadInfo::SEC_SANDBOXED;
nsCOMPtr<nsIChannel> channel;
rv = NS_NewChannel(getter_AddRefs(channel), url,
nsContentUtils::GetSystemPrincipal(), secFlags,
@ -79,8 +78,8 @@ static int FuzzingRunNetworkFtp(const uint8_t* data, size_t size) {
nullptr, // loadGroup
nullptr, // aCallbacks
loadFlags, // aLoadFlags
nullptr, // aIoService
sandboxFlags);
nullptr // aIoService
);
if (rv != NS_OK) {
MOZ_CRASH("Call to NS_NewChannel failed.");

View File

@ -16,7 +16,6 @@
#include "NullPrincipal.h"
#include "nsCycleCollector.h"
#include "RequestContextService.h"
#include "nsSandboxFlags.h"
#include "FuzzingInterface.h"
#include "FuzzingStreamListener.h"
@ -100,8 +99,8 @@ static int FuzzingRunNetworkHttp(const uint8_t* data, size_t size) {
nsIRequest::LOAD_FRESH_CONNECTION |
nsIChannel::LOAD_INITIAL_DOCUMENT_URI;
nsSecurityFlags secFlags;
secFlags = nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL;
uint32_t sandboxFlags = SANDBOXED_ORIGIN;
secFlags = nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL |
nsILoadInfo::SEC_SANDBOXED;
nsCOMPtr<nsIChannel> channel;
nsCOMPtr<nsILoadInfo> loadInfo;
@ -151,8 +150,7 @@ static int FuzzingRunNetworkHttp(const uint8_t* data, size_t size) {
nsContentUtils::GetSystemPrincipal(), // loading principal
nsContentUtils::GetSystemPrincipal(), // triggering principal
nullptr, // Context
secFlags, nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST,
sandboxFlags);
secFlags, nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST);
rv = pph->NewProxiedChannel(url, proxyInfo,
0, // aProxyResolveFlags
@ -171,8 +169,8 @@ static int FuzzingRunNetworkHttp(const uint8_t* data, size_t size) {
nullptr, // loadGroup
nullptr, // aCallbacks
loadFlags, // aLoadFlags
nullptr, // aIoService
sandboxFlags);
nullptr // aIoService
);
if (NS_FAILED(rv)) {
MOZ_CRASH("Call to NS_NewChannel failed.");

View File

@ -15,7 +15,6 @@
#include "nsScriptSecurityManager.h"
#include "nsServiceManagerUtils.h"
#include "NullPrincipal.h"
#include "nsSandboxFlags.h"
namespace mozilla {
namespace net {
@ -118,8 +117,8 @@ static int FuzzingRunNetworkWebsocket(const uint8_t* data, size_t size) {
nsresult rv;
nsSecurityFlags secFlags;
secFlags = nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL;
uint32_t sandboxFlags = SANDBOXED_ORIGIN;
secFlags = nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL |
nsILoadInfo::SEC_SANDBOXED;
nsCOMPtr<nsIURI> url;
nsAutoCString spec;
@ -147,9 +146,9 @@ static int FuzzingRunNetworkWebsocket(const uint8_t* data, size_t size) {
nsCOMPtr<nsIPrincipal> nullPrincipal =
NullPrincipal::CreateWithoutOriginAttributes();
rv = gWebSocketChannel->InitLoadInfoNative(
nullptr, nullPrincipal, nsContentUtils::GetSystemPrincipal(), nullptr,
secFlags, nsIContentPolicy::TYPE_WEBSOCKET, sandboxFlags);
rv = gWebSocketChannel->InitLoadInfo(
nullptr, nullPrincipal, nsContentUtils::GetSystemPrincipal(), secFlags,
nsIContentPolicy::TYPE_WEBSOCKET);
if (rv != NS_OK) {
MOZ_CRASH("Failed to call InitLoadInfo");

View File

@ -2,3 +2,6 @@
[Accessing navigator.serviceWorker in sandboxed iframe should throw.]
expected: FAIL
[Switching iframe sandbox attribute while loading the iframe]
expected: FAIL