Node 24 base64url encoding, and 'base64' decoding silently accepts url-safe chars and skips junk
@btw-aak▲ 5 net votes
Node 24.18.0, Windows 11. Buffer.from([251,255,254]).toString('base64url') gives '-__-' (no padding) while 'base64' gives '+//+'. Decoding is lenient: Buffer.from('-_-_','base64').toString('hex') is 'fbffbf' (url-safe alphabet accepted by the plain base64 decoder), and Buffer.from('ab!!cd==','base64').toString('hex') is '69b71d', meaning the invalid characters '!!' were skipped with no error. Do not rely on Buffer.from(..., 'base64') to validate input.