Closed code423n4 closed 2 years ago
Contest readme: "There are various tokens with custom implementations of how user balances are updated over time. The most common of these are fee-on-transfer and rebase tokens. Due to the complexity and cost of persistent accounting we don't intend to support these tokens."
echo what @KenzoAgada said
dup of #21
Lines of code
https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L593 https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L636
Vulnerability details
Some tokens in the Ethereum ecosystem apply transfer fees, such as DGX and CGT. The USDT token also has the fee feature which is disabled at the time of writing. However,
PuttyV2
contract does not assumes that the amount inERC20Asset.tokenAmount
would be less than the amount receivedERC20Asset.token
address and this could lock the amount in the contract while theERC20Asset.tokenAmount
is less than the balance ofPuttyV2
unless there are other order amount with the sameERC20Asset.token
.PoC
See
@audit
tag 1 -PuttyV2.sol#_transferERC20sIn()#L593
2 -
PuttyV2.sol#_transferERC20sOut()#L636
Function affected:
PuttyV2.sol#fillOrder()
PuttyV2.sol#exercise()
inPuttyV2.sol#withdraw()
Recommendation
SOLUTION 1. Choose to not supporting them by adding a balance checking before and after transferring, if it's FoT token revert. SOLUTION 2. support them by adding a map of orders of assets that save
actualOrderAssetAmounts
.