code-423n4 / 2022-04-badger-citadel-findings

0 stars 1 forks source link

withdrawal amount might be wrong #167

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Lines of code

https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/StakedCitadel.sol#L816

Vulnerability details

r is the user's part of the contract balance, but is supposed to be the user's part of the total funds, including the strategy funds.

therefore the check at line 816 will always return false because the user's part of the contract balance is smaller than the contract balance.

the user doesn't get their part of the strategy funds.

Impact

The user loses funds if they withdraw when there are funds in the strategy.

Recommended Mitigation Steps

chnage r to be (total funds) * _shares / totalSupply();

GalloDaSballo commented 2 years ago

I believe balance in our contract was improperly changed. Wdyt @dapp-whisperer

jack-the-pug commented 2 years ago

Dup #74