fix(runtime): use more null proto objects (#23921)

This is a primordialization effort to improve resistance against users
tampering with the global `Object` prototype.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit is contained in:
Luca Casonato 2024-05-23 00:03:35 +02:00 committed by GitHub
parent 6c167c64d6
commit 971f09abe4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
32 changed files with 141 additions and 92 deletions

View file

@ -91,7 +91,7 @@ class Worker extends EventTarget {
// still be messages left to receive.
#status = "RUNNING";
constructor(specifier, options = {}) {
constructor(specifier, options = { __proto__: null }) {
super();
specifier = String(specifier);
const {
@ -254,7 +254,7 @@ class Worker extends EventTarget {
}
};
postMessage(message, transferOrOptions = {}) {
postMessage(message, transferOrOptions = { __proto__: null }) {
const prefix = "Failed to execute 'postMessage' on 'MessagePort'";
webidl.requiredArguments(arguments.length, 1, prefix);
message = webidl.converters.any(message);