Dria

Swan
NFTHardhat
21,000 USDC
View results
Submission Details
Severity: medium
Valid

Owner can steal fee from other actors

Summary

Swan allocates fee to different actors by increasing allowance for the fee token balance of the Swan contracts. These actors then have to separately call transferFrom() to transfer fee from Swan contract to an address they control.

However, there is a privileged function using which the owner of the contract can withdraw all the fee token balance of the contract which platform fee and any other fee not yet withdrawn by other actors. Thus, the owner can steal fee token balance of other actors.

Vulnerability Details

This onlyOwner function lets the owner withdraw all fee token balance withdrawPlatformFees(). Even though the comment says it withdraws the entire fee from the contract, it's still a bug since it's basically denying the right of the actors to get the promised fee.

/// @notice Withdraw the platform fees & along with remaining fees within the contract.
function withdrawPlatformFees() public onlyOwner {
feeToken.transfer(owner(), feeToken.balanceOf(address(this)));
}

Here are the instance where allowance is increased whenever fee is allocated to an actor LLMOracleCoordinator.sol#L369:

_increaseAllowance(responses[taskId][g_i].responder, task.generatorFee);

LLMOracleCoordinator.sol#L234:

_increaseAllowance(msg.sender, task.generatorFee);

LLMOracleCoordinator.sol#L348:

// send validation fee to the validator
_increaseAllowance(validations[taskId][v_i].validator, task.validatorFee);

Impact

High. Fees can be stolen by the owner which disincentivizes the actors to trust the entire system.

Tools Used

Manual

Recommendations

Keep track of the platform fee and withdraw just that amount.

Updates

Lead Judging Commences

inallhonesty Lead Judge 8 months ago
Submission Judgement Published
Validated
Assigned finding tags:

`withdrawPlatformFees` withdraws the entire balance

Support

FAQs

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