node/test/fixtures/array-hash-collision.js
Joyee Cheung 6fae244080 build,test: test array index hash collision
This enables v8_enable_seeded_array_index_hash and add a test for it.

Fixes: https://hackerone.com/reports/3511792
PR-URL: https://github.com/nodejs-private/node-private/pull/828
CVE-ID: CVE-2026-21717
2026-03-23 13:16:48 -05:00

27 lines
531 B
JavaScript

'use strict';
// See https://hackerone.com/reports/3511792
const payload = [];
const val = 1234;
const MOD = 2 ** 19;
const CHN = 2 ** 17;
const REP = 2 ** 17;
if (process.argv[2] === 'benign') {
for (let i = 0; i < CHN + REP; i++) {
payload.push(`${val + i}`);
}
} else {
let j = val + MOD;
for (let i = 1; i < CHN; i++) {
payload.push(`${j}`);
j = (j + i) % MOD;
}
for (let k = 0; k < REP; k++) {
payload.push(`${val}`);
}
}
const string = JSON.stringify({ data: payload });
JSON.parse(string);