Vulnerability library
Security checkNovember 04, 2025

Predictable results in nanoid generation when given non-integer values

Understand the exposure, see the recommended fix, and check whether your own website has related weaknesses.

Medium severitynpmnanoid

Check your website

Find this and other vulnerabilities with a free scan.

Your scan runs on your computer. No account required.

Description

When nanoid is called with a fractional value, there were a number of undesirable effects:

  1. in browser and non-secure, the code infinite loops on while (size–)
  2. in node, the value of poolOffset becomes fractional, causing calls to nanoid to return zeroes until the pool is next filled 3.

Recommendation

Update the nanoid package to the latest compatible version. Followings are version details:

  • Affected version(s): **< 3.3.8 >= 4.0.0, < 5.0.9**
  • Patched version(s): **3.3.8 5.0.9**

References

Could your website be exposed too?

SmartScanner can check your website for Predictable results in nanoid generation when given non-integer values and gives you actionable findings to investigate.

Start a free scan

Related Issues

See something that needs correcting? Let us knowUpdated November 04, 2025