sherlock-audit / 2024-04-teller-finance-judging

10 stars 9 forks source link

blockchain555 - Some collateral will be locked in the contract #249

Closed sherlock-admin3 closed 4 months ago

sherlock-admin3 commented 4 months ago

blockchain555

high

Some collateral will be locked in the contract

Summary

Some tokens will be locked in the LenderCommitmentGroup_Smart contract forever if used as principal token.

Vulnerability Detail

Some ERC20 tokens, such as BNB, do not revert but return a bool value if the transfer() and transferFrom() function calls fail. Therefore, the transaction may not be reverted and funds may be lost.

    function burnSharesToWithdrawEarnings(
        uint256 _amountPoolSharesTokens,
        address _recipient
    ) external returns (uint256) {

403:    poolSharesToken.burn(msg.sender, _amountPoolSharesTokens);

        uint256 principalTokenValueToWithdraw = _valueOfUnderlying(
            _amountPoolSharesTokens,
            sharesExchangeRateInverse()
        );

        totalPrincipalTokensWithdrawn += principalTokenValueToWithdraw;

412:    principalToken.transfer(_recipient, principalTokenValueToWithdraw);

        return principalTokenValueToWithdraw;
    }

Even if token transmission fails in #L412, the burnSharesToWithdrawEarnings() function is not reverted. Therefore, users may lose their poolSharesToken.

Impact

If the token send fails, it will cause a lot of serious problems. For example, if a token such as BNB is used as the principal token, the user may lose the poolShareToken.

Code Snippet

https://github.com/sherlock-audit/2024-04-teller-finance/blob/main/teller-protocol-v2-audit-2024/packages/contracts/contracts/LenderCommitmentForwarder/extensions/LenderCommitmentGroup/LenderCommitmentGroup_Smart.sol#L412 https://github.com/sherlock-audit/2024-04-teller-finance/blob/main/teller-protocol-v2-audit-2024/packages/contracts/contracts/LenderCommitmentForwarder/extensions/LenderCommitmentGroup/LenderCommitmentGroup_Smart.sol#L313 https://github.com/sherlock-audit/2024-04-teller-finance/blob/main/teller-protocol-v2-audit-2024/packages/contracts/contracts/LenderCommitmentForwarder/extensions/LenderCommitmentGroup/LenderCommitmentGroup_Smart.sol#L446 https://github.com/sherlock-audit/2024-04-teller-finance/blob/main/teller-protocol-v2-audit-2024/packages/contracts/contracts/LenderCommitmentForwarder/extensions/LenderCommitmentGroup/LenderCommitmentGroup_Smart.sol#L459

Tool used

Manual Review

Recommendation

Use OpenZeppelin's safeTransfer(), which is able to handle the missing return value

Duplicate of #50