diff options
author | Antoine du Hamel <duhamelantoine1995@gmail.com> | 2022-10-27 15:09:07 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-27 20:09:07 +0000 |
commit | 2e2dc99115004e8b4303b9e84a2a652f92fc2b59 (patch) | |
tree | 46fa0c28c4e5c1d4fd9718920dba911055fbd8ff /test/es-module | |
parent | 3faa6e2c11b3260eeabb9615b1c5380db4e3ae79 (diff) | |
download | node-new-2e2dc99115004e8b4303b9e84a2a652f92fc2b59.tar.gz |
esm: protect ESM loader from prototype pollution
In a previous commit, the loader implementation was modified to be
protected against most prototype pollution, but was kept vulnerable to
`Array.prototype` pollution. This commit fixes that, the tradeoff is
that it modifies the `ESMLoader.prototype.import` return type from an
`Array` to an array-like object.
Refs: https://github.com/nodejs/node/pull/45044
PR-URL: https://github.com/nodejs/node/pull/45175
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Diffstat (limited to 'test/es-module')
-rw-r--r-- | test/es-module/test-cjs-prototype-pollution.js | 5 | ||||
-rw-r--r-- | test/es-module/test-esm-prototype-pollution.mjs | 5 |
2 files changed, 0 insertions, 10 deletions
diff --git a/test/es-module/test-cjs-prototype-pollution.js b/test/es-module/test-cjs-prototype-pollution.js index ea24407ee7..9f6291eff1 100644 --- a/test/es-module/test-cjs-prototype-pollution.js +++ b/test/es-module/test-cjs-prototype-pollution.js @@ -2,11 +2,6 @@ const { mustNotCall, mustCall } = require('../common'); -Object.defineProperties(Array.prototype, { - // %Promise.all% and %Promise.allSettled% are depending on the value of - // `%Array.prototype%.then`. - then: {}, -}); Object.defineProperties(Object.prototype, { then: { set: mustNotCall('set %Object.prototype%.then'), diff --git a/test/es-module/test-esm-prototype-pollution.mjs b/test/es-module/test-esm-prototype-pollution.mjs index 3a311394ad..6ba1fd8d64 100644 --- a/test/es-module/test-esm-prototype-pollution.mjs +++ b/test/es-module/test-esm-prototype-pollution.mjs @@ -1,10 +1,5 @@ import { mustNotCall, mustCall } from '../common/index.mjs'; -Object.defineProperties(Array.prototype, { - // %Promise.all% and %Promise.allSettled% are depending on the value of - // `%Array.prototype%.then`. - then: {}, -}); Object.defineProperties(Object.prototype, { then: { set: mustNotCall('set %Object.prototype%.then'), |