Skip to content

Commit

Permalink
[CSP] Regression WPT for nonce hiding on dangling html/body
Browse files Browse the repository at this point in the history
See bug or https://crrev.com/c/5149755

Bug: 1513216
Change-Id: Ie04e0d900e8d49ffd99fc60579f50cbd460cad2a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5148217
Commit-Queue: Jonathan Hao <phao@chromium.org>
Commit-Queue: Yifan Luo <lyf@chromium.org>
Reviewed-by: Yifan Luo <lyf@chromium.org>
Auto-Submit: Jonathan Hao <phao@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1241168}
  • Loading branch information
johnathan79717 authored and chromium-wpt-export-bot committed Dec 27, 2023
1 parent cf158fc commit 4ec8cb8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
29 changes: 29 additions & 0 deletions content-security-policy/nonce-hiding/dangling-html-or-body.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<script src="/resources/testharness.js" nonce="secret"></script>
<script src="/resources/testharnessreport.js" nonce="secret"></script>

<!-- `Content-Security-Policy: script-src 'nonce-secret'` delivered via headers -->

<body>
<style>body[nonce*=secret]{background:url(/security/resources/abe.png);}</style>
<body
<script nonce="secret" src="https://example.com/good.js"></script>
<script nonce="secret">
test(t => {
const body = document.querySelector('body');
var style = getComputedStyle(body);
assert_equals(style['background-image'], 'none');
}, "Nonces don't leak via CSS side-channels when a dangling body is injected.");
</script>

<style>html[nonce*=secret]{background:url(/security/resources/abe.png);}</style>
<html
<script nonce="secret" src="https://example.com/good.js"></script>
<script nonce="secret">
test(t => {
const html = document.querySelector('html');
var style = getComputedStyle(html);
assert_equals(style['background-image'], 'none');
}, "Nonces don't leak via CSS side-channels when a dangling html is injected.");
</script>
</body>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Content-Security-Policy: script-src 'nonce-secret'

0 comments on commit 4ec8cb8

Please sign in to comment.