code-423n4 / 2022-06-putty-findings

5 stars 0 forks source link

`ISWHITELISTED` CAN BE USED TO GRIEF OTHERS GAS #35

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Lines of code

https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L670 https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L284

Vulnerability details

Impact

The PuttyV2.isWhitelisted is used while filling orders in the scenario where the maker whitelists a specific sender to execute fillOrder. A malicious actor can use the whitelisting feature to waste senders gas by creating a pointless big array and putting the sender address in the end of that array.

Proof of Concept

For example:

The whitelist array size can be easily manipulated by the order maker (Alice) and the griefing is essentially costless for her. Even if the size is considerably high, the isWhitelisted call may revert because of exceeding the max. block size.

Recommended Mitigation Steps

Three ways to mitigate this were found:

outdoteth commented 2 years ago

The transaction cost is shown up front to Bob in whatever wallet he uses. He will immediately be able to see how much he has to pay if there is an excessively large whitelist. So there is no real attack vector here unless Bob is not looking at his transaction before he sends it.

From a game theoretical standpoint, any money that Bob wastes on gas, is money that could have gone towards Alice as a premium instead. So the real one losing out here is Alice (the attacker) not Bob (the supposed victim).

HickupHH3 commented 2 years ago

Agree with sponsor's explanation.