Tadle

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

Incorrect refund to contract owner in `DeliveryPlace::settleAskMaker()` function

Summary

In the DeliveryPlace::settleAskMaker() function, if the offerInfo.usedPoints is zero, the function calculates a refund amount for the maker’s collateral tokens. However, when the function is called by the contract owner, the refund is mistakenly sent to the contract owner’s address instead of the maker's authority.

Vulnerability Details

The settleAskMaker() function allows the contract owner to settle an ask maker’s offer if provided _settledPoints is zero:

File: DeliveryPlace.sol
249: if (status == MarketPlaceStatus.AskSettling) {
250: if (_msgSender() != offerInfo.authority) {
251: revert Errors.Unauthorized();
252: }
253: } else {
254:> if (_msgSender() != owner()) {
255: revert Errors.Unauthorized();
256: }
257:> if (_settledPoints > 0) {
258: revert InvalidPoints();
259: }
260: }

In this case, if the offerInfo.usedPoints is zero, no points are used, and the function calculates a makerRefundAmount to refund the maker’s collateral tokens.

However, the refund is incorrectly allocated to the _msgSender(), which is the contract owner when he calls the function:

File: DeliveryPlace.sol
276: if (_settledPoints == offerInfo.usedPoints) {
...
301: tokenManager.addTokenBalance(
302: TokenBalanceType.SalesRevenue,
303:> _msgSender(), // <= add balance for contract owner if it is settled by owner
304: makerInfo.tokenAddress,
305: makerRefundAmount
306: );
307: }

This results in the collateral tokens being sent to the contract owner instead of the offerInfo.authority.

Impact

This vulnerability allows the contract owner to improperly receive collateral refunds that belong to the authority of offer.

Tools Used

vscode

Recommendations

tokenManager.addTokenBalance(
TokenBalanceType.SalesRevenue,
- _msgSender(),
+ offerInfo.authority,
makerInfo.tokenAddress,
makerRefundAmount
);
Updates

Lead Judging Commences

0xnevi Lead Judge
about 1 year ago
0xnevi Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

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