harden: a token scale above ~87 makes the whole swap silently undecodable #350
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found by the review of #345 (#345 (comment)). Pre-existing on the ERC-20 path as well as the swap path.
MAX_DECIMALSis 255, butformatUnits()throws above roughly 87 (invalid FixedNumber decimals (too large)). A scale in 90..255 therefore throws insidedecode(), where a blanketcatch { return null }swallows it, and the entire swap becomes undecodable.It fails safe — no wrong number is shown — but it fails silently, and the user is left with an approval screen that simply does not describe the transaction rather than one that says why.
Not in milestone 1.0.0: it cannot produce a wrong amount, and the accepted-scale bound is only reachable from a hostile or broken token.
Definition of done
null.MAX_DECIMALSand the formatter's real bound agree, or the mismatch is handled where it is introduced rather than by a blanket catch.catch { return null }indecode()does not hide a class of failure that has a specific, useful message.make checkgreen.