forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CSP] Added new policy violation source: wasm-eval
This extends the suite of policy violation sources to include a WebAssembly specific source: wasm-eval. This has also been reflected in the PR (w3c/webappsec-csp#293 (review)) against the CSP spec. Added test for proper security violation event of the right form. Bug: 948834 Change-Id: I0b76fd725136b7ddda92e629f147f5ba77c50ffb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3197842 Commit-Queue: Francis McCabe <[email protected]> Reviewed-by: Arthur Sonzogni <[email protected]> Reviewed-by: Mike West <[email protected]> Reviewed-by: Antonio Sartori <[email protected]> Reviewed-by: Andrey Kosyakov <[email protected]> Reviewed-by: David Tseng <[email protected]> Cr-Commit-Position: refs/heads/main@{#931206}
- Loading branch information
Showing
12 changed files
with
113 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
..._tests/external/wpt/content-security-policy/wasm-unsafe-eval/script-src-spv-asynch.any.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// META: global=window,worker | ||
let code = new Uint8Array([0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0]); | ||
async_test(t => { | ||
self.addEventListener('securitypolicyviolation', t.step_func_done(e => { | ||
assert_equals(e.violatedDirective, "script-src"); | ||
assert_equals(e.originalPolicy, "default-src 'self' 'unsafe-inline'") | ||
assert_equals(e.blockedURI, "wasm-eval") | ||
})); | ||
}, "Securitypolicyviolation event looks like it should"); | ||
|
||
promise_test(t => { | ||
return promise_rejects_js( | ||
t, WebAssembly.CompileError, | ||
WebAssembly.instantiate(code)); | ||
}); | ||
|
||
|
||
|
1 change: 1 addition & 0 deletions
1
...xternal/wpt/content-security-policy/wasm-unsafe-eval/script-src-spv-asynch.any.js.headers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Content-Security-Policy: default-src 'self' 'unsafe-inline' |
21 changes: 21 additions & 0 deletions
21
...s/inspector-protocol/issues/content-security-policy-issue-creation-wasm-eval-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Verifies that CSP issue is created from a page with eval() usage. | ||
|
||
Inspector issue: { | ||
issue : { | ||
code : ContentSecurityPolicyIssue | ||
details : { | ||
contentSecurityPolicyIssueDetails : { | ||
contentSecurityPolicyViolationType : kWasmEvalViolation | ||
isReportOnly : false | ||
sourceCodeLocation : { | ||
columnNumber : 19 | ||
lineNumber : 7 | ||
scriptId : <string> | ||
url : https://devtools.test:8443/inspector-protocol/resources/content-security-policy-issue-wasm-eval.php | ||
} | ||
violatedDirective : script-src | ||
} | ||
} | ||
} | ||
} | ||
|
12 changes: 12 additions & 0 deletions
12
.../http/tests/inspector-protocol/issues/content-security-policy-issue-creation-wasm-eval.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
(async function(testRunner) { | ||
const {page, session, dp} = await testRunner.startBlank( | ||
`Verifies that CSP issue is created from a page with eval() usage.\n`); | ||
|
||
await dp.Network.enable(); | ||
await dp.Audits.enable(); | ||
page.navigate('https://devtools.test:8443/inspector-protocol/resources/content-security-policy-issue-wasm-eval.php'); | ||
const issue = await dp.Audits.onceIssueAdded(); | ||
|
||
testRunner.log(issue.params, "Inspector issue: "); | ||
testRunner.completeTest(); | ||
}) |
14 changes: 14 additions & 0 deletions
14
...tests/http/tests/inspector-protocol/resources/content-security-policy-issue-wasm-eval.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
header("Content-Security-Policy: script-src 'self' 'unsafe-inline';"); | ||
?> | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<h2>Webpage with not allowed WebAssembly</h2> | ||
|
||
<script> | ||
const wasm_script = new Uint8Array([0, 0x61, 0x73, 0x6d, 0x1, 0, 0, 0]); | ||
WebAssembly.instantiate(wasm_script); | ||
</script> | ||
</body> | ||
</html> |