Skip to content
Business logic Audit finding Intermediate

Wfcash deposit might give incorrect amount of shares (wfcash) in some cases

The preview function for wfcash deposits does not handle the case when no fcash is available on the markets, leading to incorrect share calculation. Users may receive fewer or incorrect shares when depositing.

tvdung94 Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-12-notional-update-5-judging/issues/14

Found by

tvdung94

Summary

Wfcash deposit might not give correct amount of wfcash when there is no fcash available on the markets.

Vulnerability Detail

The preview function, which calculates the amount of share for minting, does not take the edge case, when there is not available fcash on the markets, into account. In this case, amount of shares should be equivalent to the amount of asset (ratio 1:1). However, the code will get amount of share on notionalv2 instead, which is incorrect.

Impact

Users will get less/ incorrect amount of shares when using this deposit function.

Code Snippet

https://github.com/sherlock-audit/2023-12-notional-update-5/blob/main/wrapped-fcash/contracts/wfCashERC4626.sol#L89-L106

Tool used

Manual Review

Recommendation

Consider adding code to handle the case when there is not enough available fcash on the markets.

Discussion

sherlock-admin2

1 comment(s) were left on this issue during the judging contest.

takarez commented:

invalid because { invalid as using NotionalV2 is the right and intended behavior}

T-Woodward

_previewDeposit logic is not consistent with _mintInternal logic

sherlock-admin

The protocol team fixed this issue in PR/commit https://github.com/notional-finance/wrapped-fcash/pull/18.

sherlock-admin

The Lead Senior Watson signed-off on the fix.

The original report as published on Sherlock, by tvdung94. 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

Likely the preview function does not account for the edge case of zero available fcash, incorrectly using NotionalV2's share calculation instead of a 1:1 ratio.

Impact

Users could receive less or incorrect shares when depositing under the no-fcash condition.

What the attacker needed

No fcash available on the markets

The fix

The issue was fixed by adding code to handle the case when there is not enough available fcash on the markets.

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.

When you deposit into a vault, the system calculates how many shares you get. If the market has no fcash available, the calculation should be one share per asset, but the code uses a different method that gives wrong shares. This means you might get fewer shares than you should.

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 Notional Update #5

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.