Tadle

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

Incorrect Token Assignment Causes Withdrawal Failures in Point Token Transactions

Summary

wrong token address assignment leads to withdrawing the wrong token

Vulnerability Details

The DeliveryPlace::settleAskTaker function assigns the wrong token address for the bid-maker who wants to receive a point token, not an erc20 token (e.g. usdc). in the settleAskTaker function:

if (settledPointTokenAmount > 0) {
tokenManager.tillIn(
// DONE@Mitsuketa-high: bid-makers who want to buy points must inject points into the contract before getting points.
_msgSender(),
// e this is the point token
marketPlaceInfo.tokenAddress,
settledPointTokenAmount,
true
);
tokenManager.addTokenBalance(
TokenBalanceType.PointToken,
offerInfo.authority,
// @Mitsuketa-high
>>> makerInfo.tokenAddress,
settledPointTokenAmount
);
}

after the bid maker calls the settleAskTaker function, it should assign the desired point token for the bid maker. but the function assigns the makerInfo.tokenAddress for the bid maker which is wrong. this is the token the bid maker paid to get the point token but now he is gonna withdraw the wrong token

function addTokenBalance(
TokenBalanceType _tokenBalanceType,
address _accountAddress,
address _tokenAddress,
uint256 _amount
) external onlyRelatedContracts(tadleFactory, _msgSender()) {
userTokenBalanceMap[_accountAddress][_tokenAddress][
_tokenBalanceType
] += _amount;
emit AddTokenBalance(
_accountAddress,
_tokenAddress,
_tokenBalanceType,
_amount
);
}
function withdraw(
>>> address _tokenAddress,
TokenBalanceType _tokenBalanceType
) external whenNotPaused {
uint256 claimAbleAmount = userTokenBalanceMap[_msgSender()][
_tokenAddress
][_tokenBalanceType];
// ...
}

after the bid maker calls the settleAskTaker function, now he thinks his point token is ready to withdraw so he calls the TokenManager::withdraw function with the point token as the first parameter but it will revert cause the protocol assigns the wrong token address.
the bid maker must call the withdraw with the erc20 token as the first param but in the end, he receives the erc20 token not the point token.

Impact

the main functionality of the protocol is disruption and users can't withdraw their desired point token

Tools Used

manual review

Recommendations

in the DeliveryPlace::settleAskTaker:

tokenManager.addTokenBalance(
TokenBalanceType.PointToken,
offerInfo.authority,
// @Mitsuketa-high
- makerInfo.tokenAddress,
+ marketPlaceInfo.tokenAddress,
settledPointTokenAmount
);
}

Although you must handle the settledPointTokenAmount properly to not point to the wrong number

Updates

Lead Judging Commences

0xnevi Lead Judge 12 months ago
Submission Judgement Published
Validated
Assigned finding tags:

finding-DeliveryPlace-settleAskTaker-closeBidTaker-wrong-makerinfo-token-address-addToken-balance

Valid high severity, In `settleAskTaker/closeBidTaker`, by assigning collateral token to user balance instead of point token, if collateral token is worth more than point, this can cause stealing of other users collateral tokens within the CapitalPool contract, If the opposite occurs, user loses funds based on the points they are supposed to receive

Support

FAQs

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