Submitted by Emmanuel, also found by 20centclub
In decode_legacy_tx, data_len for chain_id is not constrained to be <31, which allows validation of signatures with chain_id that are larger than felt, and overflows.
chain_id is pulled from items\[6].data via the bytes_to_felt helper function.
Looking at bytes_to_felt function, we will observe that the return value will overflow if len>31, because current would have been shifted 2^(8\*32) times, which overflows the max felt value of 2^252:
Since items\[6].data_len is not constrained to be <=31, absurd values of chain_id(containing >31 data_len) can be passed, which would overflow, and pass the signature validation.
Assert that items\[6].data_len <= 31:
Under/Overflow
ClementWalter (Kakarot) confirmed and commented:
Kakarot mitigated:
Status: Mitigation confirmed.
