Bug 1876575, part 2 - Make Workers use ancestor chain for third-partiness check - r=anti-tracking-reviewers,timhuang,asuth

Differential Revision: https://phabricator.services.mozilla.com/D203289
This commit is contained in:
Benjamin VanderSloot
2024-04-02 18:53:26 +00:00
parent f9b6578ac7
commit 9379dadba0
8 changed files with 11 additions and 14 deletions

View File

@@ -1063,8 +1063,8 @@ nsresult WorkerScriptLoader::LoadScript(
// This flag reflects the fact that if the worker is created under a
// third-party context.
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
loadInfo->SetIsThirdPartyContextToTopWindow(
mWorkerRef->Private()->IsThirdPartyContextToTopWindow());
loadInfo->SetIsInThirdPartyContext(
mWorkerRef->Private()->IsThirdPartyContext());
Maybe<ClientInfo> clientInfo;
clientInfo.emplace(loadContext->mClientInfo.ref());

View File

@@ -101,7 +101,7 @@ WorkerLoadInfoData::WorkerLoadInfoData()
mUsingStorageAccess(false),
mServiceWorkersTestingInWindow(false),
mShouldResistFingerprinting(false),
mIsThirdPartyContextToTopWindow(true),
mIsThirdPartyContext(true),
mSecureContext(eNotSet) {}
nsresult WorkerLoadInfo::SetPrincipalsAndCSPOnMainThread(

View File

@@ -147,7 +147,7 @@ struct WorkerLoadInfoData {
bool mShouldResistFingerprinting;
Maybe<RFPTarget> mOverriddenFingerprintingSettings;
OriginAttributes mOriginAttributes;
bool mIsThirdPartyContextToTopWindow;
bool mIsThirdPartyContext;
enum {
eNotSet,

View File

@@ -2791,8 +2791,7 @@ nsresult WorkerPrivate::GetLoadInfo(
loadInfo.mOriginAttributes = aParent->GetOriginAttributes();
loadInfo.mServiceWorkersTestingInWindow =
aParent->ServiceWorkersTestingInWindow();
loadInfo.mIsThirdPartyContextToTopWindow =
aParent->IsThirdPartyContextToTopWindow();
loadInfo.mIsThirdPartyContext = aParent->IsThirdPartyContext();
loadInfo.mShouldResistFingerprinting = aParent->ShouldResistFingerprinting(
RFPTarget::IsAlwaysEnabledForPrecompute);
loadInfo.mOverriddenFingerprintingSettings =
@@ -2953,7 +2952,7 @@ nsresult WorkerPrivate::GetLoadInfo(
StorageAllowedForDocument(document) != StorageAccess::eAllow) {
loadInfo.mUsingStorageAccess = false;
}
loadInfo.mIsThirdPartyContextToTopWindow =
loadInfo.mIsThirdPartyContext =
AntiTrackingUtils::IsThirdPartyWindow(globalWindow, nullptr);
loadInfo.mCookieJarSettings = document->CookieJarSettings();
if (loadInfo.mCookieJarSettings) {
@@ -3021,7 +3020,7 @@ nsresult WorkerPrivate::GetLoadInfo(
cookieJarSettings->Serialize(loadInfo.mCookieJarSettingsArgs);
loadInfo.mOriginAttributes = OriginAttributes();
loadInfo.mIsThirdPartyContextToTopWindow = false;
loadInfo.mIsThirdPartyContext = false;
}
MOZ_ASSERT(loadInfo.mLoadingPrincipal);

View File

@@ -972,9 +972,7 @@ class WorkerPrivate final
}
// Determine if the worker was created under a third-party context.
bool IsThirdPartyContextToTopWindow() const {
return mLoadInfo.mIsThirdPartyContextToTopWindow;
}
bool IsThirdPartyContext() const { return mLoadInfo.mIsThirdPartyContext; }
bool IsWatchedByDevTools() const { return mLoadInfo.mWatchedByDevTools; }

View File

@@ -286,7 +286,7 @@ nsresult RemoteWorkerChild::ExecWorkerOnMainThread(RemoteWorkerData&& aData) {
info.mStorageAccess = aData.storageAccess();
info.mUseRegularPrincipal = aData.useRegularPrincipal();
info.mUsingStorageAccess = aData.usingStorageAccess();
info.mIsThirdPartyContextToTopWindow = aData.isThirdPartyContextToTopWindow();
info.mIsThirdPartyContext = aData.isThirdPartyContext();
info.mOriginAttributes =
BasePrincipal::Cast(principal)->OriginAttributesRef();
info.mShouldResistFingerprinting = aData.shouldResistFingerprinting();

View File

@@ -76,7 +76,7 @@ struct RemoteWorkerData
StorageAccess storageAccess;
bool isThirdPartyContextToTopWindow;
bool isThirdPartyContext;
bool shouldResistFingerprinting;

View File

@@ -437,7 +437,7 @@ bool StoragePrincipalHelper::ShouldUsePartitionPrincipalForServiceWorker(
return false;
}
return aWorkerPrivate->IsThirdPartyContextToTopWindow();
return aWorkerPrivate->IsThirdPartyContext();
}
// static