15-Year-Old JavaScript Color Library Harbored Hidden Heap-Crash Bug in Two Functions
A developer discovered a heap-exhaustion vulnerability in TinyColor2, a widely used JavaScript color library with over 5,200 GitHub stars, while porting it to Rust. The bug exists in the analogous() and monochromatic() functions, which loop indefinitely and crash the process when passed negative or fractional count arguments such as -1, 0.5, or 1.5. The flaw went undetected for roughly 15 years because a default assignment — results = results || 6 — silently catches all falsy inputs like null, NaN, and undefined, making the functions appear safe during casual testing. Only specific truthy invalid values bypass this default and trigger infinite loops that exhaust available memory with exit code 134. The reporter proposed input validation guards similar to those already present in the library's polyad() function, which correctly rejects non-integer or out-of-range arguments.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in