Context: Assertions.sol#L129-L144
So far, the impact seems low and we are not able to craft an exploit.
The above code checks for the following, let len represent the length of the additionalRecipients array, then it checks that len * 64 + 0x260 == calldataload(0x244). Where all the arithmetic is in EVM. This however does not check for overflow of len * 64. Its possible to craft malicious calldata that would satisfy this condition by overflowing on the multiplication.
We need to find x such that mul(x, 64) = mul(len, 64) in EVM arithmetic. The values of x can be len + y where y is in the set {2**250, 2**251, ..., 2**255}. These are also the only such values.
This would create problems whenever the value BasicOrder_additionalRecipients_length_cdPtr is used to do read from calldata.
Note: the solidity compiler would add the check len < 2**64 for high level data.
Note: the issues is similar to some known bugs in past versions of solc. Look for bug descriptions with overflow in bugs.json.
The following addition to the test would revert, but the reverts happen later in the codebase, likely due to OOG as the value gets used in a for-loop in BasicOrderFulfiller.sol#L611-L13.
The test changes the length of an empty array to 2**255, everything else in the calldata remaining the same. The invariant 0 * 64 + 0x260 == 0x260 == 2**255 * 64 + 0x60 is true in EVM arithmetic.
Consider adding a check for calldataload(BasicOrder_additionalRecipients_length_cdPtr) < 2**64, similar to what solc generates. Alternatively, the number 2**64 can be decreased further, depending on a realistic upper bound for additionalRecipients.
