Although ERC20Boost.decrementGaugesBoostIndexed
function would require user to remove all of her or his boost from a deprecated gauge at once, such user can instead call ERC20Boost.decrementGaugeBoost
function for multiple times to utilize such deprecated gauge and decrement its userGaugeBoost
for multiple times
#904
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
M-01
primary issue
Highest quality submission among a set of duplicates
satisfactory
satisfies C4 submission criteria; eligible for awards
selected for report
This submission will be included/highlighted in the audit report
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Lines of code
https://github.com/code-423n4/2023-05-maia/blob/62f4f01a522dcbb4b9abfe2f6783bbb67c0da022/src/erc-20/ERC20Boost.sol#L175-L187
https://github.com/code-423n4/2023-05-maia/blob/62f4f01a522dcbb4b9abfe2f6783bbb67c0da022/src/erc-20/ERC20Boost.sol#L198-L200
https://github.com/code-423n4/2023-05-maia/blob/62f4f01a522dcbb4b9abfe2f6783bbb67c0da022/src/erc-20/ERC20Boost.sol#L203-L227
Vulnerability details
Impact
When the
gauge
input corresponds to a deprecated gauge, calling the followingERC20Boost.decrementGaugeBoost
function can still executegaugeState.userGaugeBoost -= boost.toUint128()
ifboost >= gaugeState.userGaugeBoost
is false.https://github.com/code-423n4/2023-05-maia/blob/62f4f01a522dcbb4b9abfe2f6783bbb67c0da022/src/erc-20/ERC20Boost.sol#L175-L187
However, for the same deprecated gauge, calling the following
ERC20Boost.decrementAllGaugesBoost
andERC20Boost.decrementGaugesBoostIndexed
functions below would execute_userGauges[msg.sender].remove(gauge)
anddelete getUserGaugeBoost[msg.sender][gauge]
without executinggaugeState.userGaugeBoost -= boost.toUint128()
because_deprecatedGauges.contains(gauge)
is true. Hence, an inconsistency exists between theERC20Boost.decrementGaugeBoost
andERC20Boost.decrementGaugesBoostIndexed
functions when the corresponding gauge is deprecated. As a result, although theERC20Boost.decrementGaugesBoostIndexed
function would require the user to remove all of her or his boost from a deprecated gauge at once, such user can instead call theERC20Boost.decrementGaugeBoost
function for multiple times to utilize such deprecated gauge and decrement itsuserGaugeBoost
for multiple times ifboost >= gaugeState.userGaugeBoost
is false each time.https://github.com/code-423n4/2023-05-maia/blob/62f4f01a522dcbb4b9abfe2f6783bbb67c0da022/src/erc-20/ERC20Boost.sol#L198-L200
https://github.com/code-423n4/2023-05-maia/blob/62f4f01a522dcbb4b9abfe2f6783bbb67c0da022/src/erc-20/ERC20Boost.sol#L203-L227
Proof of Concept
The following steps can occur for the described scenario.
ERC20Boost.decrementGaugeBoost
function to decrement 0.5e18 boost from such deprecated gauge.ERC20Boost.decrementGaugeBoost
function to decrement 0.2e18 boost from such deprecated gauge.Tools Used
VSCode
Recommended Mitigation Steps
The
ERC20Boost.decrementGaugeBoost
function can be updated to executerequire(_userGauges[msg.sender].remove(gauge))
anddelete getUserGaugeBoost[msg.sender][gauge]
if_deprecatedGauges.contains(gauge) || boost >= gaugeState.userGaugeBoost
is true, which is similar to theERC20Boost.decrementGaugesBoostIndexed
function.Assessed type
Other
The text was updated successfully, but these errors were encountered: