From 971f09abe486185247e1faf4e8d1419ba2506b8d Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Thu, 23 May 2024 00:03:35 +0200 Subject: fix(runtime): use more null proto objects (#23921) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a primordialization effort to improve resistance against users tampering with the global `Object` prototype. --------- Co-authored-by: Bartek IwaƄczuk --- ext/web/06_streams.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'ext/web/06_streams.js') diff --git a/ext/web/06_streams.js b/ext/web/06_streams.js index 9c2a05980..e01ece6c8 100644 --- a/ext/web/06_streams.js +++ b/ext/web/06_streams.js @@ -5274,7 +5274,7 @@ class ReadableStream { "Argument 1", ); } else { - options = {}; + options = { __proto__: null }; } if (options.mode === undefined) { return acquireReadableStreamDefaultReader(this); @@ -5290,7 +5290,7 @@ class ReadableStream { * @param {PipeOptions=} options * @returns {ReadableStream} */ - pipeThrough(transform, options = {}) { + pipeThrough(transform, options = { __proto__: null }) { webidl.assertBranded(this, ReadableStreamPrototype); const prefix = "Failed to execute 'pipeThrough' on 'ReadableStream'"; webidl.requiredArguments(arguments.length, 1, prefix); @@ -5329,7 +5329,7 @@ class ReadableStream { * @param {PipeOptions=} options * @returns {Promise} */ - pipeTo(destination, options = {}) { + pipeTo(destination, options = { __proto__: null }) { try { webidl.assertBranded(this, ReadableStreamPrototype); const prefix = "Failed to execute 'pipeTo' on 'ReadableStream'"; @@ -5567,7 +5567,7 @@ class ReadableStreamBYOBReader { * @param {ReadableStreamBYOBReaderReadOptions} options * @returns {Promise} */ - read(view, options = {}) { + read(view, options = { __proto__: null }) { try { webidl.assertBranded(this, ReadableStreamBYOBReaderPrototype); const prefix = "Failed to execute 'read' on 'ReadableStreamBYOBReader'"; @@ -6151,8 +6151,8 @@ class TransformStream { */ constructor( transformer = undefined, - writableStrategy = {}, - readableStrategy = {}, + writableStrategy = { __proto__: null }, + readableStrategy = { __proto__: null }, ) { const prefix = "Failed to construct 'TransformStream'"; if (transformer !== undefined) { -- cgit v1.2.3