Commit ddee1ddc authored by Eric Roman's avatar Eric Roman Committed by Commit Bot

Mark CryptoKey and SubtleCrypto interfaces as SecureContext.

This matches the IDL from the spec, and resolves a bug whereby the Web Crypto API could be used from an insecure context.

We were correctly blocking access to "self.crypto.subtle" from insecure contexts, however it was possible to access through its interface self.SubtleCrypto.

Bug: 1038704
Change-Id: I425d602fda64c3f63ee87bcfed1711e508901c61
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2057098
Commit-Queue: Eric Roman <eroman@chromium.org>
Reviewed-by: default avatarPhilip Jägenstedt <foolip@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743242}
parent 9a1a151b
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
// https://w3c.github.io/webcrypto/Overview.html#cryptokey-interface // https://w3c.github.io/webcrypto/Overview.html#cryptokey-interface
[ [
SecureContext,
Exposed=(Window,Worker) Exposed=(Window,Worker)
] interface CryptoKey { ] interface CryptoKey {
readonly attribute DOMString type; readonly attribute DOMString type;
......
...@@ -35,6 +35,7 @@ typedef DOMString KeyUsage; ...@@ -35,6 +35,7 @@ typedef DOMString KeyUsage;
typedef (Dictionary or DOMString) AlgorithmIdentifier; typedef (Dictionary or DOMString) AlgorithmIdentifier;
[ [
SecureContext,
Exposed=(Window,Worker) Exposed=(Window,Worker)
] interface SubtleCrypto { ] interface SubtleCrypto {
[CallWith=ScriptState, MeasureAs=SubtleCryptoEncrypt] Promise<any> encrypt(AlgorithmIdentifier algorithm, CryptoKey key, BufferSource data); [CallWith=ScriptState, MeasureAs=SubtleCryptoEncrypt] Promise<any> encrypt(AlgorithmIdentifier algorithm, CryptoKey key, BufferSource data);
......
This is a testharness.js-based test.
PASS Non-secure context window does not have access to crypto.subtle
FAIL Non-secure context window does not have access to SubtleCrypto assert_equals: expected (undefined) undefined but got (function) function "function SubtleCrypto() { [native code] }"
FAIL Non-secure context window does not have access to CryptoKey assert_equals: expected (undefined) undefined but got (function) function "function CryptoKey() { [native code] }"
Harness: the test ran to completion.
This is a testharness.js-based test.
PASS Non-secure context window does not have access to crypto.subtle
FAIL Non-secure context window does not have access to SubtleCrypto assert_equals: expected (undefined) undefined but got (function) function "function SubtleCrypto() { [native code] }"
FAIL Non-secure context window does not have access to CryptoKey assert_equals: expected (undefined) undefined but got (function) function "function CryptoKey() { [native code] }"
Harness: the test ran to completion.
This is a testharness.js-based test.
PASS Non-secure context window does not have access to crypto.subtle
FAIL Non-secure context window does not have access to SubtleCrypto assert_equals: expected (undefined) undefined but got (function) function "function SubtleCrypto() { [native code] }"
FAIL Non-secure context window does not have access to CryptoKey assert_equals: expected (undefined) undefined but got (function) function "function CryptoKey() { [native code] }"
Harness: the test ran to completion.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment