Closed code423n4 closed 2 years ago
https://github.com/code-423n4/2022-06-infinity/blob/main/contracts/core/InfinityExchange.sol#L793 https://github.com/code-423n4/2022-06-infinity/blob/main/contracts/core/InfinityExchange.sol#L899 https://github.com/code-423n4/2022-06-infinity/blob/main/contracts/core/InfinityExchange.sol#L1146
Some ERC20 tokens will fail when transferring 0 amount. Transactions sent by users may be reverted if protocolFee is set to 0.
protocolFee
If protocolFeeBps is set to 0, protocolFee will be 0:
protocolFeeBps
https://github.com/code-423n4/2022-06-infinity/blob/main/contracts/core/InfinityExchange.sol#L873
uint256 protocolFee = (protocolFeeBps * execPrice) / 10000;
These lines will transfer 0 amount:
https://github.com/code-423n4/2022-06-infinity/blob/main/contracts/core/InfinityExchange.sol#L793
IERC20(buy.execParams[1]).safeTransferFrom(buy.signer, address(this), protocolFee);
https://github.com/code-423n4/2022-06-infinity/blob/main/contracts/core/InfinityExchange.sol#L899
https://github.com/code-423n4/2022-06-infinity/blob/main/contracts/core/InfinityExchange.sol#L1146
IERC20(currency).safeTransferFrom(buyer, address(this), protocolFee);
None
Consider setting a lower bound in setProtocolFee, and also PROTOCOL_FEE_BPS should have a cap (max: 10,000).
setProtocolFee
PROTOCOL_FEE_BPS
Thanks
Since the admin could correct the fee it set in error, lowering risk and merging with the warden's QA report #232
Lines of code
https://github.com/code-423n4/2022-06-infinity/blob/main/contracts/core/InfinityExchange.sol#L793 https://github.com/code-423n4/2022-06-infinity/blob/main/contracts/core/InfinityExchange.sol#L899 https://github.com/code-423n4/2022-06-infinity/blob/main/contracts/core/InfinityExchange.sol#L1146
Vulnerability details
Impact
Some ERC20 tokens will fail when transferring 0 amount. Transactions sent by users may be reverted if
protocolFee
is set to 0.Proof of Concept
If
protocolFeeBps
is set to 0,protocolFee
will be 0:https://github.com/code-423n4/2022-06-infinity/blob/main/contracts/core/InfinityExchange.sol#L873
These lines will transfer 0 amount:
https://github.com/code-423n4/2022-06-infinity/blob/main/contracts/core/InfinityExchange.sol#L793
https://github.com/code-423n4/2022-06-infinity/blob/main/contracts/core/InfinityExchange.sol#L899
https://github.com/code-423n4/2022-06-infinity/blob/main/contracts/core/InfinityExchange.sol#L1146
Tools Used
None
Recommended Mitigation Steps
Consider setting a lower bound in
setProtocolFee
, and alsoPROTOCOL_FEE_BPS
should have a cap (max: 10,000).