Skip to content
Business logic Audit finding Intermediate

Update to `managerFeeBPS` applied to pending tokens yet to be claimed

The manager could change the manager fee percentage at any time, and this new rate would be applied retroactively to pending fees that had not yet been claimed. A malicious or careless manager could therefore take up to 100% of the pending fees owed to stakers.

0xDjango Follow with Jeiwan, ast3ros and 4 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-06-arrakis-judging/issues/198

Found by

0xDjango, Jeiwan, ast3ros, dipp, immeas, rugpull_detector, rvierdiiev

Summary

A manager (malicious or not) can update the managerFeeBPS by calling ArrakisV2.setManagerFeeBPS(). The newly-updated managerFeeBPS will be retroactively applied to the pending fees yet to be claimed by the ArrakisV2 contract.

Vulnerability Detail

Whenever UniV3 fees are collected (via burn() or rebalance()), the manager fees are applied to the received pending tokens.

Solidity
function _applyFees(uint256 fee0_, uint256 fee1_) internal {
    uint16 mManagerFeeBPS = managerFeeBPS;
    managerBalance0 += (fee0_ * mManagerFeeBPS) / hundredPercent;
    managerBalance1 += (fee1_ * mManagerFeeBPS) / hundredPercent;
}

Since the manager can update the managerFeeBPS whenever, this calculation can be altered to take up to 100% of the pending fees in favor of the manager.

Solidity
function setManagerFeeBPS(uint16 managerFeeBPS_) external onlyManager {
    require(managerFeeBPS_ <= 10000, "MFO");
    managerFeeBPS = managerFeeBPS_;
    emit LogSetManagerFeeBPS(managerFeeBPS_);
}

Impact

  • Manager's ability to intentionally or accidently steal pending fees owed to stakers

Code Snippet

https://github.com/sherlock-audit/2023-06-arrakis/blob/main/v2-core/contracts/abstract/ArrakisV2Storage.sol#L218-L222

Tool used

Manual Review

Recommendation

Fees should be collected at the start of execution within the setManagerFeeBPS() function. This effectively checkpoints the fees properly, prior to updating the managerFeeBPS variable.

Discussion

Gevarist

We provide a fix on the v2-core repository, we add an internal function _collectFeesOnPools that will be called when the manager will set managerFeeBPS

IAm0x52

Fix looks good. Fees are now updated and collected for manager anytime there is an update to manager or fee BPS

The original report as published on Sherlock, by 0xDjango. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The contract applies the current manager fee rate to pending fees without first checkpointing or collecting those fees at the old rate.

Impact

A manager could intentionally or accidentally steal pending fees owed to stakers by raising the fee rate before those fees are collected.

What the attacker needed

Manager role

The fix

The project added a function to collect fees on pools before updating the manager fee, and the fix was confirmed to look good.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A manager can change the fee percentage that they take from rewards. Because the new percentage is applied to rewards that were earned before the change, the manager can suddenly increase their cut and take most or all of the rewards that should go to the people who staked their money.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by 0xDjango

View all

23 more disclosed reports, best first.

More from Arrakis Valantis SOT Audit

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.