Bug 1770468 - Report-only wasm-unsafe-eval in MV2 r=mixedpuppy,freddyb,ckerschb

For backcompat, do not enforce wasm-unsafe-eval even if the extension
has specified a custom CSP. Do report the errors though, to allow
extension authors to discover the issue and fix it.

Differential Revision: https://phabricator.services.mozilla.com/D147105
This commit is contained in:
Rob Wu
2022-05-24 13:56:22 +00:00
parent 195280f165
commit ab4eaf5309
2 changed files with 43 additions and 3 deletions

View File

@@ -515,6 +515,17 @@ bool nsScriptSecurityManager::ContentSecurityPolicyPermitsJSAction(
if (NS_FAILED(csp->GetAllowsWasmEval(&reportViolation, &evalOK))) {
return false;
}
if (!evalOK) {
// Historically, CSP did not block WebAssembly in Firefox, and some
// add-ons use wasm and a stricter CSP. To avoid breaking them, ignore
// 'wasm-unsafe-eval' violations for MV2 extensions.
// TODO bug 1770909: remove this exception.
auto* addonPolicy = BasePrincipal::Cast(subjectPrincipal)->AddonPolicy();
if (addonPolicy && addonPolicy->ManifestVersion() == 2) {
reportViolation = true;
evalOK = true;
}
}
}
if (reportViolation) {