Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cergyk - BBCommon::_accrue wrong value is used to prevent overflow #41

Open
sherlock-admin2 opened this issue Mar 15, 2024 · 2 comments
Labels
Has Duplicates A valid issue with 1+ other issues describing the same vulnerability Medium A valid Medium severity issue Reward A payout will be made for this issue Sponsor Confirmed The sponsor acknowledged this issue is valid Will Fix The sponsor confirmed this issue will be fixed

Comments

@sherlock-admin2
Copy link
Contributor

sherlock-admin2 commented Mar 15, 2024

cergyk

medium

BBCommon::_accrue wrong value is used to prevent overflow

Summary

A mechanism is used in _accrue, to prevent overflow in order to avoid Dos on multiple entrypoints of a BigBang market (many external functions call on _accrue before executing their logic). However the wrong value is used to prevent an overflow, and even though it could be prevented the first time, it should overflow the second one it is called

Vulnerability Detail

We can see that the value to be accrued is clamped to type(uint128).max - totalBorrowCap

Which works the first time to avoid an overflow since totalBorrow.elastic should be less than totalBorrowCap. However if totalBorrow.elastic is already bigger than totalBorrowCap (due to a previous accrual), this clamping does not prevent overflow.

Impact

_accrue can still revert due to an overflow blocking most of the functions of a BigBang market.

Code Snippet

Tool used

Manual Review

Recommendation

Clamp accrued value to type(uint128).max - totalBorrow.elastic instead

@sherlock-admin2 sherlock-admin2 added Sponsor Confirmed The sponsor acknowledged this issue is valid Will Fix The sponsor confirmed this issue will be fixed labels Mar 16, 2024
@github-actions github-actions bot added Medium A valid Medium severity issue Has Duplicates A valid issue with 1+ other issues describing the same vulnerability labels Mar 20, 2024
@cryptotechmaker
Copy link

Fixed by Tapioca-DAO/Tapioca-bar#351

@sherlock-admin4
Copy link
Contributor

The protocol team fixed this issue in PR/commit Tapioca-DAO/Tapioca-bar#351.

@sherlock-admin3 sherlock-admin3 changed the title Modern Mandarin Wasp - BBCommon::_accrue wrong value is used to prevent overflow cergyk - BBCommon::_accrue wrong value is used to prevent overflow Mar 31, 2024
@sherlock-admin3 sherlock-admin3 added the Reward A payout will be made for this issue label Mar 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Has Duplicates A valid issue with 1+ other issues describing the same vulnerability Medium A valid Medium severity issue Reward A payout will be made for this issue Sponsor Confirmed The sponsor acknowledged this issue is valid Will Fix The sponsor confirmed this issue will be fixed
Projects
None yet
Development

No branches or pull requests

4 participants