Tadle

Tadle
DeFiFoundry
27,750 USDC
View results
Submission Details
Severity: high
Invalid

TokenManager::withdraw function implements the line `IWrappedNativeToken(wrappedNativeToken).withdraw(claimAbleAmount)` that introduces a reentrancy risk.

Summary

TokenManager::withdraw function implements the line IWrappedNativeToken(wrappedNativeToken).withdraw(claimAbleAmount) that makes an external call to the deposit function of a wrapped native token contract. This external call introduces a reentrancy risk.

Vulnerability Details

function withdraw( //@audit : reentrancy
address _tokenAddress,
TokenBalanceType _tokenBalanceType
) external whenNotPaused {
uint256 claimAbleAmount = userTokenBalanceMap[_msgSender()][
_tokenAddress
][_tokenBalanceType];
if (claimAbleAmount == 0) {
return;
}
address capitalPoolAddr = tadleFactory.relatedContracts(
RelatedContractLibraries.CAPITAL_POOL
);
if (_tokenAddress == wrappedNativeToken) {
/**
* @dev token is native token
* @dev transfer from capital pool to msg sender
* @dev withdraw native token to token manager contract
* @dev transfer native token to msg sender
*/
_transfer(
wrappedNativeToken,
capitalPoolAddr,
address(this),
claimAbleAmount,
capitalPoolAddr
);
@> IWrappedNativeToken(wrappedNativeToken).withdraw(claimAbleAmount); //@audit external call
@> payable(msg.sender).transfer(claimAbleAmount); //@audit
} else {
/**
* @dev token is ERC20 token
* @dev transfer from capital pool to msg sender
*/
_safe_transfer_from(
_tokenAddress,
capitalPoolAddr,
_msgSender(),
claimAbleAmount
);
}
emit Withdraw(
_msgSender(),
_tokenAddress,
_tokenBalanceType,
claimAbleAmount
);
}

Impact

exposes the protocol to reentrancy attack

Tools Used

manual review

Recommendations

To prevent this, you can implement a reentrancy guard:

Updates

Lead Judging Commences

0xnevi Lead Judge
over 1 year ago
0xnevi Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Known issue

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!