Skip to content
Business logic Audit finding Intermediate

Copy-paste bug leading to incorrect harvest rewards in Vault.sol

The calcReward function contains a copy-paste error where the else branch incorrectly uses USDV-related variables and functions instead of VADER ones, leading to an incorrect adjusted reserve calculation. This causes incorrect harvest rewards for all users, with some receiving more and some less than they should.

Vader Protocol contest

Originally disclosed on Code4rena

The conditional in calcReward() function uses the same code in both if/else parts with repeated use of reserveUSDV, reserveVADER and getUSDVAmount leading to incorrect computed value of _adjustedReserve in the else part.

This will affect harvest rewards for all users of the protocol and lead to incorrect accounting. Protocol will break and lead to fund loss.

Recommend changing variables and function calls from using USDV to VADER in the else part of the conditional which has to return the adjusted reserves when synth is not an asset i.e. an anchor and therefore base is VADER. L144 should be changed to: uint _adjustedReserve = iROUTER(ROUTER).getVADERAmount(reserveUSDV()) + reserveVADER();

strictly-scarce (vader) confirmed:

Funds are not at-risk, just that some users will get less rewards, some will get more.

Recommend: 2

Mervyn853 commented:

Our decision matrix for severity:

0: No-risk: Code style, clarity, off-chain monitoring (events etc), exclude gas-optimisations 1: Low Risk: UX, state handling, function incorrect as to spec 2: Funds-Not-At-Risk, but can impact the functioning of the protocol, or leak value with a hypothetical attack path with stated assumptions, but external requirements 3: Funds can be stolen/lost directly, or indirectly if a valid attack path shown that does not have handwavey hypotheticals.

Recommended: 2

The original report as published on Code4rena. 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 a copy-paste error where the else branch of a conditional was not updated to use the correct variables and function calls for the VADER asset.

Impact

Funds are not at risk, but some users will receive less rewards and some more, impacting the protocol's functioning.

What the attacker needed

None

The fix

The else branch should be changed to use getVADERAmount and reserveVADER instead of getUSDVAmount and reserveUSDV.

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 function that calculates rewards for users has a mistake: in one branch, it uses the wrong variables, so the reward amount is calculated incorrectly. This means some users get too many rewards and others too few, which can break the protocol's accounting.

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 from Vader Protocol 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.