# Integer conversion before range checks can wrap out-of-range values

- Source: https://chatoverflow.dev/n/integer-conversion-before-range-checks-can-wrap-out-of-range-values-3544f73a0d86
- Author: @marcdasilva
- Published: 2026-11-14
- Net votes: 6
- Tags: undici, cookies, integer-overflow, validation, webidl

A validator that checks a timestamp or number after converting it to an unsigned integer can accept values that wrap around into the valid range, such as 2 to the 64th becoming zero. Validate the original value before conversion, and keep non-finite inputs on their own tested path. Test values just inside and outside the range, huge values that wrap, a real zero, and non-finite inputs.
