Submitted by serial-coder, also found by 0x11singh99, josephdara, Jorgect, unix515, Mrxstrange, nonseodion, and Rhaydden
Currently, the WiseLending protocol supports several ERC-20 tokens and will also support more tokens in the future:
On some ERC-20 tokens, the transferFrom() will return false on failure instead of reverting a transaction. I noticed that the TransferHelper::_safeTransferFrom(), which is used throughout the protocol, is vulnerable to detecting the token transfer failure if the transferFrom() returns false due to the unchecked return value bug.
The following lists the functions directly invoking the vulnerable _safeTransferFrom():
Due to the unchecked return value bug, users or attackers can exploit these protocols functions without supplying a token (please refer to the Proof of Concept section for more details).
The WiseLending protocol implements the TransferHub::_callOptionalReturn() as a helper function for executing low-level calls. In case the transferFrom() returns false on failure, the _callOptionalReturn() will receive the returned parameters: success == true and returndata != bytes(0).
Then, the _callOptionalReturn() will decode the received returndata for the success status. If the transferFrom() returns false, the results will become false.
With the results == false, finally, the _callOptionalReturn() will return false to its function caller.
On the TransferHelper::_safeTransferFrom(), I noticed that the function does not evaluate the return value (i.e., unchecked return value bug) of the _callOptionalReturn(). Subsequently, the _safeTransferFrom() cannot detect the token transfer failure if the transferFrom() returns false.
@1 -- On some tokens, the transferFrom() will return false instead of reverting a transaction: see here.
@2 -- If the transferFrom() returns false, the results == false: see here.
@3 -- If the results == false, the _callOptionalReturn() will return false: see here.
@4 -- The _safeTransferFrom() cannot detect the token transfer failure if the transferFrom() returns false instead of reverting a transaction due to the unchecked return value bug: see here.
Note: Please refer to the Impact section for a complete list of the functions directly invoking the vulnerable _safeTransferFrom().
The following briefly analyzes 2 of the 17 functions that would affect the exploitation as examples:
@5 -- Liquidator can steal collateral (_receiveToken) from the target liquidable position: see here.
@6 -- Depositor can increase their collateral without supplying any token: see here.
Improve the _safeTransferFrom() by checking the return value from the _callOptionalReturn() and reverting a transaction if it is false.
Invalid Validation
vm06007 (Wise Lending) commented:
vm06007 (Wise Lending) commented:
