Submitted by 0xsanson, also found by cmichel
BasicOrderFulfiller.sol#L346-L349
When fulfilling a basic order we need to assert that the parameter totalOriginalAdditionalRecipients is less or equal than the length of additionalRecipients written in calldata.
However in _prepareBasicFulfillmentFromCalldata this assertion is incorrect (L346):
The way the function is written (L75), it accepts also a length smaller than the original by 1 (basically there shouldnt be a + 1 in the first argument).
Interestingly enough, in the case additionalRecipients.length < totalOriginalAdditionalRecipients, the inline-assembly for-loop at (L506) will read consideration items out-of-bounds.
This can be a vector of exploits, as illustrated below.
Alice makes the following offer: a basic order, with two considerationItems. The second item has the following data:
The only quantities we need to track are the amounts X and recipient Y.
When fulfilling the order normally, the fulfiller will spend X tokens sending them to Y. Its possible however to exploit the previous bug in a way that the fulfiller wont need to make this transfer.
To do this, the fulfiller needs to craft the following calldata:
Basically writing additionalRecipients = [] and making the signature length = X, with Y being the first 32 bytes.
Of course this signature will be invalid; however it doesnt matter since the exploiter can call validate with the correct signature beforehand.
The transaction trace will look like this:
Conclusion:
Every Order that is basic and has two or more consideration items can be fulfilled in a way to not trade the last consideration item in the list. The fulfiller spends less then normally, and a recipient doesnt get his due.
Theres also an extra requirement which is stricter: this last items startAmount (= endAmount) needs to be smallish (< 1e6). This is because this number becomes the signature bytes length, and we need to fill the calldata with extra zeroes to complete it. Realistically then the exploit will work only if the item is a ERC20 will low decimals.
Ive made a hardhat test that exemplifies the exploit. (Link to gist)
Remove the +1 at L347.
0age (OpenSea) confirmed, but disagreed with severity and commented:
HardlyDifficult (judge) decreased severity to Medium
0xleastwood (judge) commented:
0age (OpenSea) resolved:
For this contest, 29 reports were submitted by wardens detailing low risk and non-critical issues. Many of these reports were integrated into Seaport 1.1, often by the warden themselves; see this PR from OpenSea for the full set of changes.
The report highlighted below by team Spearbit received the top score from the judge.
The following wardens also submitted reports: Saw-mon_and_Natalie, cmichel, IllIllI, broccoli, Chom, sces60107, zkhorse, shung, hack3r-0m, peritoflores, OriDabush, hyh, scaraven, hickuphh3, ilan, cccz, 0xsanson, csanuragjain, kebabsec, sorrynotsorry, zzzitron, oyc_109, twojoy, tintin, rfa, foobar, hubble, and mayo.
