Vulnerability library
Security checkAugust 13, 2026

nanoid: custom generators can loop indefinitely when size is zero

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

High severitynpmnanoid

Check your website

Find this and other vulnerabilities with a free scan.

Your scan runs on your computer. No account required.

Description

nanoid (Nano ID) before 5.1.6 contains an infinite loop in the customAlphabet and customRandom functions. When these functions are configured with a size of 0, the internal generation loop never satisfies its exit condition and spins indefinitely, hanging the calling thread.

Recommendation

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

  • Affected version(s): **< 3.3.18 >= 4.0.0, < 5.1.6**
  • Patched version(s): **3.3.18 5.1.6**

References

Could your website be exposed too?

SmartScanner can check your website for nanoid: custom generators can loop indefinitely when size is zero and gives you actionable findings to investigate.

Start a free scan

Related Issues

See something that needs correcting? Let us knowUpdated August 13, 2026