From 3202f6376fc87cb5273c088e5ccdea05f7c656ac Mon Sep 17 00:00:00 2001 From: Philipp Dunkel Date: Sun, 6 Sep 2026 16:32:10 +0200 Subject: [PATCH] vfs: give ZipProvider option bags a null prototype The options passed to `createFileStats()` and to the archive's `add()` and `addSync()` are plain literals, so a property added to `Object.prototype` would reach those callees as if it had been passed on purpose. Create them with a null prototype so only the fields set here are visible. Refs: https://github.com/nodejs/node/pull/65853 Signed-off-by: Philipp Dunkel PR-URL: https://github.com/nodejs/node/pull/65853 Reviewed-By: James M Snell Reviewed-By: Matteo Collina --- lib/internal/vfs/providers/ziparchive.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/internal/vfs/providers/ziparchive.js b/lib/internal/vfs/providers/ziparchive.js index e5ecfc7afd7..9f4ecceee46 100644 --- a/lib/internal/vfs/providers/ziparchive.js +++ b/lib/internal/vfs/providers/ziparchive.js @@ -219,6 +219,7 @@ class ZipFileHandle extends VirtualFileHandle { // its own modification time; once dirty the file is as new as its close. #doStat() { return createFileStats(this.#size, { + __proto__: null, mode: this.#entryMode, mtimeMs: this.#dirty || this.#modified === null ? undefined : this.#modified.getTime(), }); @@ -249,13 +250,15 @@ class ZipFileHandle extends VirtualFileHandle { async close() { if (this.#dirty && isWritableFlag(this.flags)) { - await this.#source.add(this.#name, this.#buffer.subarray(0, this.#size), { mode: this.#entryMode }); + await this.#source.add(this.#name, this.#buffer.subarray(0, this.#size), + { __proto__: null, mode: this.#entryMode }); } await super.close(); } closeSync() { if (this.#dirty && isWritableFlag(this.flags)) { - this.#source.addSync(this.#name, this.#buffer.subarray(0, this.#size), { mode: this.#entryMode }); + this.#source.addSync(this.#name, this.#buffer.subarray(0, this.#size), + { __proto__: null, mode: this.#entryMode }); } super.closeSync(); }