Platform: Code4rena
Start Date: 13/01/2023
Pot Size: $100,500 USDC
Total HM: 1
Participants: 23
Period: 10 days
Judge: hickuphh3
Total Solo HM: 1
Id: 201
League: ETH
Rank: 6/23
Findings: 1
Award: $1,551.45
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: horsefacts
Also found by: 0xSmartContract, ABA, Chom, IllIllI, Josiah, RaymondFam, Rickard, Rolezn, brgltd, btk, chaduke, charlesjhongc, csanuragjain, delfin454000, nadin, oyc_109
1551.4544 USDC - $1,551.45
_encodeBytes
attempts to round up the provided size of src memory pointer to the nearest word but instead it rounds up to the second nearest word by using AlmostTwoWords
instead of AlmostOneWord
// Mask the length of the bytes array to protect against overflow // and round up to the nearest word. size = (src.readUint256() + AlmostTwoWords) & OnlyFullWordMask;
_encodeBytes
is used in 3 places:
_encodeGenerateOrder
-> over extens the size of the bytes memory context
in the calldata_encodeRatifyOrder
-> over extens the size of the bytes memory context
in the calldata_encodeValidateOrder
-> over extens the size of bytes memory extraData
in the calldataIn all cases, the over increase in size dose not pose an issue internally as the values are only passed through a call
to the calling ContractOffererInterface
implementation functions. Here, depending on the logic used by the implementer the size may cause an issue/hidden bug, althought of a low severity.
pragma solidity ^0.8.13.0; contract Testing { function _encodeBytes(uint256 src) external pure returns (uint256 size) { uint256 AlmostTwoWords = 0x3f; uint256 OnlyFullWordMask = 0xff_ff_ff_e0; unchecked { size = (src + AlmostTwoWords) & OnlyFullWordMask; } } }
Input: 0x12345678
Expectation: 0x12345680
Output: 0x123456A0
change AlmostTwoWords
to AlmostOneWord
Natspec typos of wrongly named arguments
For function _encodeBytes
second param is named dst
but the natspec has it as src
. Simply rename it to fix.
#0 - HickupHH3
2023-01-25T09:13:06Z
Nice find for the 1st issue! Possibly grade A because of it.
#1 - c4-judge
2023-01-26T03:02:05Z
HickupHH3 marked the issue as grade-a
#2 - HickupHH3
2023-01-26T18:15:39Z
Regarding the 1st issue, impl is working as expected, whereby word storing the length needs to be copied over as well. See https://github.com/ProjectOpenSea/seaport/pull/906/files
Keeping the grade because the issue helped to clarify the return argument of the function => finding is of value.