mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-01 12:57:31 +09:00
Bug 1182569 - Skip security check for plugins using newstream attribute
This commit is contained in:
parent
846daf6d3b
commit
409656556b
5 changed files with 47 additions and 24 deletions
|
|
@ -13918,7 +13918,8 @@ public:
|
||||||
const nsAString& aFileName,
|
const nsAString& aFileName,
|
||||||
nsIInputStream* aPostDataStream,
|
nsIInputStream* aPostDataStream,
|
||||||
nsIInputStream* aHeadersDataStream,
|
nsIInputStream* aHeadersDataStream,
|
||||||
bool aIsTrusted);
|
bool aIsTrusted,
|
||||||
|
nsIPrincipal* aTriggeringPrincipal);
|
||||||
|
|
||||||
NS_IMETHOD Run() override
|
NS_IMETHOD Run() override
|
||||||
{
|
{
|
||||||
|
|
@ -13934,7 +13935,7 @@ public:
|
||||||
mHandler->OnLinkClickSync(mContent, mURI,
|
mHandler->OnLinkClickSync(mContent, mURI,
|
||||||
mTargetSpec.get(), mFileName,
|
mTargetSpec.get(), mFileName,
|
||||||
mPostDataStream, mHeadersDataStream,
|
mPostDataStream, mHeadersDataStream,
|
||||||
nullptr, nullptr);
|
nullptr, nullptr, mTriggeringPrincipal);
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
@ -13949,6 +13950,7 @@ private:
|
||||||
nsCOMPtr<nsIContent> mContent;
|
nsCOMPtr<nsIContent> mContent;
|
||||||
PopupControlState mPopupState;
|
PopupControlState mPopupState;
|
||||||
bool mIsTrusted;
|
bool mIsTrusted;
|
||||||
|
nsCOMPtr<nsIPrincipal> mTriggeringPrincipal;
|
||||||
};
|
};
|
||||||
|
|
||||||
OnLinkClickEvent::OnLinkClickEvent(nsDocShell* aHandler,
|
OnLinkClickEvent::OnLinkClickEvent(nsDocShell* aHandler,
|
||||||
|
|
@ -13958,7 +13960,8 @@ OnLinkClickEvent::OnLinkClickEvent(nsDocShell* aHandler,
|
||||||
const nsAString& aFileName,
|
const nsAString& aFileName,
|
||||||
nsIInputStream* aPostDataStream,
|
nsIInputStream* aPostDataStream,
|
||||||
nsIInputStream* aHeadersDataStream,
|
nsIInputStream* aHeadersDataStream,
|
||||||
bool aIsTrusted)
|
bool aIsTrusted,
|
||||||
|
nsIPrincipal* aTriggeringPrincipal)
|
||||||
: mHandler(aHandler)
|
: mHandler(aHandler)
|
||||||
, mURI(aURI)
|
, mURI(aURI)
|
||||||
, mTargetSpec(aTargetSpec)
|
, mTargetSpec(aTargetSpec)
|
||||||
|
|
@ -13968,6 +13971,7 @@ OnLinkClickEvent::OnLinkClickEvent(nsDocShell* aHandler,
|
||||||
, mContent(aContent)
|
, mContent(aContent)
|
||||||
, mPopupState(mHandler->mScriptGlobal->GetPopupControlState())
|
, mPopupState(mHandler->mScriptGlobal->GetPopupControlState())
|
||||||
, mIsTrusted(aIsTrusted)
|
, mIsTrusted(aIsTrusted)
|
||||||
|
, mTriggeringPrincipal(aTriggeringPrincipal)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -13978,7 +13982,8 @@ nsDocShell::OnLinkClick(nsIContent* aContent,
|
||||||
const nsAString& aFileName,
|
const nsAString& aFileName,
|
||||||
nsIInputStream* aPostDataStream,
|
nsIInputStream* aPostDataStream,
|
||||||
nsIInputStream* aHeadersDataStream,
|
nsIInputStream* aHeadersDataStream,
|
||||||
bool aIsTrusted)
|
bool aIsTrusted,
|
||||||
|
nsIPrincipal* aTriggeringPrincipal)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(NS_IsMainThread(), "wrong thread");
|
NS_ASSERTION(NS_IsMainThread(), "wrong thread");
|
||||||
|
|
||||||
|
|
@ -14017,7 +14022,8 @@ nsDocShell::OnLinkClick(nsIContent* aContent,
|
||||||
|
|
||||||
nsCOMPtr<nsIRunnable> ev =
|
nsCOMPtr<nsIRunnable> ev =
|
||||||
new OnLinkClickEvent(this, aContent, aURI, target.get(), aFileName,
|
new OnLinkClickEvent(this, aContent, aURI, target.get(), aFileName,
|
||||||
aPostDataStream, aHeadersDataStream, aIsTrusted);
|
aPostDataStream, aHeadersDataStream,
|
||||||
|
aIsTrusted, aTriggeringPrincipal);
|
||||||
return NS_DispatchToCurrentThread(ev);
|
return NS_DispatchToCurrentThread(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -14029,7 +14035,8 @@ nsDocShell::OnLinkClickSync(nsIContent* aContent,
|
||||||
nsIInputStream* aPostDataStream,
|
nsIInputStream* aPostDataStream,
|
||||||
nsIInputStream* aHeadersDataStream,
|
nsIInputStream* aHeadersDataStream,
|
||||||
nsIDocShell** aDocShell,
|
nsIDocShell** aDocShell,
|
||||||
nsIRequest** aRequest)
|
nsIRequest** aRequest,
|
||||||
|
nsIPrincipal* aTriggeringPrincipal)
|
||||||
{
|
{
|
||||||
// Initialize the DocShell / Request
|
// Initialize the DocShell / Request
|
||||||
if (aDocShell) {
|
if (aDocShell) {
|
||||||
|
|
@ -14152,13 +14159,18 @@ nsDocShell::OnLinkClickSync(nsIContent* aContent,
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if the triggeringPrincipal is not passed explicitly, then we
|
||||||
|
// fall back to using doc->NodePrincipal() as the triggeringPrincipal.
|
||||||
|
nsCOMPtr<nsIPrincipal> triggeringPrincipal =
|
||||||
|
aTriggeringPrincipal ? aTriggeringPrincipal
|
||||||
|
: aContent->NodePrincipal();
|
||||||
|
|
||||||
nsresult rv = InternalLoad(clonedURI, // New URI
|
nsresult rv = InternalLoad(clonedURI, // New URI
|
||||||
nullptr, // Original URI
|
nullptr, // Original URI
|
||||||
false, // LoadReplace
|
false, // LoadReplace
|
||||||
referer, // Referer URI
|
referer, // Referer URI
|
||||||
refererPolicy, // Referer policy
|
refererPolicy, // Referer policy
|
||||||
aContent->NodePrincipal(), // Triggering is our node's
|
triggeringPrincipal,
|
||||||
// principal
|
|
||||||
aContent->NodePrincipal(),
|
aContent->NodePrincipal(),
|
||||||
flags,
|
flags,
|
||||||
target, // Window target
|
target, // Window target
|
||||||
|
|
|
||||||
|
|
@ -201,7 +201,8 @@ public:
|
||||||
const nsAString& aFileName,
|
const nsAString& aFileName,
|
||||||
nsIInputStream* aPostDataStream,
|
nsIInputStream* aPostDataStream,
|
||||||
nsIInputStream* aHeadersDataStream,
|
nsIInputStream* aHeadersDataStream,
|
||||||
bool aIsTrusted) override;
|
bool aIsTrusted,
|
||||||
|
nsIPrincipal* aTriggeringPrincipal) override;
|
||||||
NS_IMETHOD OnLinkClickSync(nsIContent* aContent,
|
NS_IMETHOD OnLinkClickSync(nsIContent* aContent,
|
||||||
nsIURI* aURI,
|
nsIURI* aURI,
|
||||||
const char16_t* aTargetSpec,
|
const char16_t* aTargetSpec,
|
||||||
|
|
@ -209,7 +210,8 @@ public:
|
||||||
nsIInputStream* aPostDataStream = 0,
|
nsIInputStream* aPostDataStream = 0,
|
||||||
nsIInputStream* aHeadersDataStream = 0,
|
nsIInputStream* aHeadersDataStream = 0,
|
||||||
nsIDocShell** aDocShell = 0,
|
nsIDocShell** aDocShell = 0,
|
||||||
nsIRequest** aRequest = 0) override;
|
nsIRequest** aRequest = 0,
|
||||||
|
nsIPrincipal* aTriggeringPrincipal = nullptr) override;
|
||||||
NS_IMETHOD OnOverLink(nsIContent* aContent,
|
NS_IMETHOD OnOverLink(nsIContent* aContent,
|
||||||
nsIURI* aURI,
|
nsIURI* aURI,
|
||||||
const char16_t* aTargetSpec) override;
|
const char16_t* aTargetSpec) override;
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,8 @@ public:
|
||||||
* @param aFileName non-null when the link should be downloaded as the given file
|
* @param aFileName non-null when the link should be downloaded as the given file
|
||||||
* @param aHeadersDataStream ???
|
* @param aHeadersDataStream ???
|
||||||
* @param aIsTrusted false if the triggerer is an untrusted DOM event.
|
* @param aIsTrusted false if the triggerer is an untrusted DOM event.
|
||||||
|
* @param aTriggeringPrincipal, if not passed explicitly we fall back to
|
||||||
|
* the document's principal.
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD OnLinkClick(nsIContent* aContent,
|
NS_IMETHOD OnLinkClick(nsIContent* aContent,
|
||||||
nsIURI* aURI,
|
nsIURI* aURI,
|
||||||
|
|
@ -44,7 +46,8 @@ public:
|
||||||
const nsAString& aFileName,
|
const nsAString& aFileName,
|
||||||
nsIInputStream* aPostDataStream,
|
nsIInputStream* aPostDataStream,
|
||||||
nsIInputStream* aHeadersDataStream,
|
nsIInputStream* aHeadersDataStream,
|
||||||
bool aIsTrusted) = 0;
|
bool aIsTrusted,
|
||||||
|
nsIPrincipal* aTriggeringPrincipal) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process a click on a link.
|
* Process a click on a link.
|
||||||
|
|
@ -61,6 +64,8 @@ public:
|
||||||
* @param aHeadersDataStream ???
|
* @param aHeadersDataStream ???
|
||||||
* @param aDocShell (out-param) the DocShell that the request was opened on
|
* @param aDocShell (out-param) the DocShell that the request was opened on
|
||||||
* @param aRequest the request that was opened
|
* @param aRequest the request that was opened
|
||||||
|
* @param aTriggeringPrincipal, if not passed explicitly we fall back to
|
||||||
|
* the document's principal.
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD OnLinkClickSync(nsIContent* aContent,
|
NS_IMETHOD OnLinkClickSync(nsIContent* aContent,
|
||||||
nsIURI* aURI,
|
nsIURI* aURI,
|
||||||
|
|
@ -69,7 +74,8 @@ public:
|
||||||
nsIInputStream* aPostDataStream = 0,
|
nsIInputStream* aPostDataStream = 0,
|
||||||
nsIInputStream* aHeadersDataStream = 0,
|
nsIInputStream* aHeadersDataStream = 0,
|
||||||
nsIDocShell** aDocShell = 0,
|
nsIDocShell** aDocShell = 0,
|
||||||
nsIRequest** aRequest = 0) = 0;
|
nsIRequest** aRequest = 0,
|
||||||
|
nsIPrincipal* aTriggeringPrincipal = nullptr) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process a mouse-over a link.
|
* Process a mouse-over a link.
|
||||||
|
|
|
||||||
|
|
@ -5104,7 +5104,7 @@ nsContentUtils::TriggerLink(nsIContent *aContent, nsPresContext *aPresContext,
|
||||||
|
|
||||||
handler->OnLinkClick(aContent, aLinkURI,
|
handler->OnLinkClick(aContent, aLinkURI,
|
||||||
fileName.IsVoid() ? aTargetSpec.get() : EmptyString().get(),
|
fileName.IsVoid() ? aTargetSpec.get() : EmptyString().get(),
|
||||||
fileName, nullptr, nullptr, aIsTrusted);
|
fileName, nullptr, nullptr, aIsTrusted, aContent->NodePrincipal());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -535,16 +535,6 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL,
|
||||||
nsresult rv = NS_NewURI(getter_AddRefs(uri), aURL, baseURI);
|
nsresult rv = NS_NewURI(getter_AddRefs(uri), aURL, baseURI);
|
||||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
|
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
if (aDoCheckLoadURIChecks) {
|
|
||||||
nsCOMPtr<nsIScriptSecurityManager> secMan(
|
|
||||||
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv));
|
|
||||||
NS_ENSURE_TRUE(secMan, NS_ERROR_FAILURE);
|
|
||||||
|
|
||||||
rv = secMan->CheckLoadURIWithPrincipal(content->NodePrincipal(), uri,
|
|
||||||
nsIScriptSecurityManager::STANDARD);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsCOMPtr<nsIInputStream> headersDataStream;
|
nsCOMPtr<nsIInputStream> headersDataStream;
|
||||||
if (aPostStream && aHeadersData) {
|
if (aPostStream && aHeadersData) {
|
||||||
if (!aHeadersDataLen)
|
if (!aHeadersDataLen)
|
||||||
|
|
@ -563,8 +553,21 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL,
|
||||||
Preferences::GetInt("privacy.popups.disable_from_plugins");
|
Preferences::GetInt("privacy.popups.disable_from_plugins");
|
||||||
nsAutoPopupStatePusher popupStatePusher((PopupControlState)blockPopups);
|
nsAutoPopupStatePusher popupStatePusher((PopupControlState)blockPopups);
|
||||||
|
|
||||||
|
|
||||||
|
// if security checks (in particular CheckLoadURIWithPrincipal) needs
|
||||||
|
// to be skipped we are creating a codebasePrincipal to make sure
|
||||||
|
// that security check succeeds. Please note that we do not want to
|
||||||
|
// fall back to using the systemPrincipal, because that would also
|
||||||
|
// bypass ContentPolicy checks which should still be enforced.
|
||||||
|
nsCOMPtr<nsIPrincipal> triggeringPrincipal;
|
||||||
|
if (!aDoCheckLoadURIChecks) {
|
||||||
|
mozilla::PrincipalOriginAttributes attrs =
|
||||||
|
BasePrincipal::Cast(content->NodePrincipal())->OriginAttributesRef();
|
||||||
|
triggeringPrincipal = BasePrincipal::CreateCodebasePrincipal(uri, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
rv = lh->OnLinkClick(content, uri, unitarget.get(), NullString(),
|
rv = lh->OnLinkClick(content, uri, unitarget.get(), NullString(),
|
||||||
aPostStream, headersDataStream, true);
|
aPostStream, headersDataStream, true, triggeringPrincipal);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue