mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
console: fix prototype pollution via console.table
CVE-ID: CVE-2022-21824 Backport-PR-URL: https://github.com/nodejs-private/node-private/pull/308 PR-URL: https://github.com/nodejs-private/node-private/pull/307 Refs: https://hackerone.com/reports/1431042 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
1 parent
ff9ac7d757
commit
be69403528
2 files changed
+17
-1
No files matched your search
@@ -9,6 +9,7 @@ const {
|
||||
Boolean,
|
||||
Error,
|
||||
Map,
|
||||
ObjectCreate,
|
||||
ObjectDefineProperties,
|
||||
ObjectDefineProperty,
|
||||
ObjectKeys,
|
||||
@@ -532,7 +533,7 @@ const consoleMethods = {
|
||||
return final([iterKey, valuesKey], [getIndexArray(length), values]);
|
||||
}
|
||||
|
||||
const map = {};
|
||||
const map = ObjectCreate(null);
|
||||
let hasPrimitives = false;
|
||||
const valuesKeyArray = [];
|
||||
const indexKeyArray = ObjectKeys(tabularData);
|
||||
|
||||
@@ -276,3 +276,18 @@ test({ foo: '你好', bar: 'hello' }, `
|
||||
│ bar │ 'hello' │
|
||||
└─────────┴─────────┘
|
||||
`);
|
||||
|
||||
// Regression test for prototype pollution via console.table. Earlier versions
|
||||
// of Node.js created an object with a non-null prototype within console.table
|
||||
// and then wrote to object[column][index], which lead to an error as well as
|
||||
// modifications to Object.prototype.
|
||||
test([{ foo: 10 }, { foo: 20 }], ['__proto__'], `
|
||||
┌─────────┬───────────┐
|
||||
│ (index) │ __proto__ │
|
||||
├─────────┼───────────┤
|
||||
│ 0 │ │
|
||||
│ 1 │ │
|
||||
└─────────┴───────────┘
|
||||
`);
|
||||
assert.strictEqual('0' in Object.prototype, false);
|
||||
assert.strictEqual('1' in Object.prototype, false);
|
||||
Reference in new issue
Block a user