Submitted by RadiantLabs, also found by gumgumzum
The RIPEMD-160 digest integrates the input data with one additional block including the message length.
If we look at the Cairo code that achieves this:
 we see that the if (next_block == false) executes one block of code in case len >= 55, and the other otherwise.
If we compare this check with the equivalent implementation in Go (used by Geth), for example:
We see that this time, the selection is made with len < 56 as discriminator; if we imagine swapping the if and the else blocks of the Go implementation, the condition becomes len >= 56.
So for the edge case of len == 55, Kakarot and Geth will take different actions, which, as shown in the PoC, results in differing hashes. len here represents the length of the input modulo 64, hence the RIPEMD-160 precompile will yield wrong outputs for inputs of length 55 + k*64.
Because this precompile is a cryptographic hash function, it can be used in many ways by EVM applications, including access control on funds.
To prove the point, the following test can be added to the test_ripemd160.py unit test suite:
 which yields the following output:
Change the check at L455 to is_nn_le(56, len).
ClementWalter (Kakarot) confirmed and commented:
Kakarot mitigated:
Status: Mitigation confirmed.
