Skip to content
Business logic Audit finding Intermediate

ConvexMasterChef : safeRewardTransfer can cause loss of funds

The safeRewardTransfer function in ConvexMasterChef can silently send less reward tokens than owed if the contract lacks sufficient cvx tokens, causing depositors to lose funds. The report claims this is unsafe because the shortfall is not reflected in accounting.

cccz Follow

Originally disclosed on Code4rena

Submitted by cccz

Same as https://github.com/code-423n4/2022-02-concur-findings/issues/244

All calculations are rounded down, since a lack of tokens in the contracts cannot be rounding errors’ fault. So the function is redundant. On the other hand, if the contract is undersupplied with cvx tokens, this will cause depositors to be sent less tokens than needed (or none). This is especially unsafe because the tokens that were lacking are not resembled in accountings at all. Thus a depositor may invoke the safeRewardTransfer and not receive tokens they were supposed to.

Proof of Concept

ConvexMasterChef.sol#L299-L306

Recommended Mitigation Steps

Use usual safeTransfer instead of safeRewardTransfer.

0xMaharishi (Aura Finance) acknowledged, but disagreed with severity and commented:

Reward tokens are transferred here before rewards start.

LSDan (judge) commented:

I agree with this report. The fallback situation in this function specifically prioritizes loss of funds over bricking the contract, which while laudable, results in what is effectively a silent failure case.

0xMaharishi (Aura Finance) resolved:

code-423n4/2022-05-aura#6


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

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

Likely the safeRewardTransfer function uses a safe transfer that does not revert on insufficient balance, allowing a silent shortfall that is not recorded in accounting.

Impact

A depositor could receive fewer reward tokens than they are owed, or none, with no record of the shortfall, leading to loss of funds.

What the attacker needed

Contract undersupplied with cvx tokens

The fix

The report recommends using a standard safeTransfer instead of safeRewardTransfer, which was addressed in a pull request.

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 smart contract holds reward tokens to pay out to people who deposit funds. If the contract does not have enough reward tokens, the payout function can send less than promised without any error. The person expecting the reward simply gets less, and the contract's records do not show that anything is missing.

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 cccz

View all

104 more disclosed reports, best first.

More from Aura Finance contest

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.