Closed code423n4 closed 2 years ago
@dapp-whisperer wdyt?
Pretty sure the idea was to subtract old weight from total, but perhaps the warden has a point?
Seems to be fine since fundingPoolWeights[_pool]
should always be less than totalFundingPoolWeight
. Calculations are a bit redundant though
This is invalid as when totalFundingPoolWeight == 0
, fundingPoolWeights[_pool]
must be 0
.
_newTotalWeight = _newTotalWeight - fundingPoolWeights[_pool];
Lines of code
https://github.com/code-423n4/2022-04-badger-citadel/blob/18f8c392b6fc303fe95602eba6303725023e53da/src/CitadelMinter.sol#L250-L284
Vulnerability details
Impact
At
CitadelMinter.sol
, Funding Pool Weight can't be set at the beginning sincetotalFundingPoolWeight
value is not assigned and Zero meanwhile being cached to_newTotalWeight
. Hence the substraction will not perform as it will yield to a negative value which the cached variable is an oppositeuint
. Please check the @audit notes below;Proof of Concept
https://github.com/code-423n4/2022-04-badger-citadel/blob/18f8c392b6fc303fe95602eba6303725023e53da/src/CitadelMinter.sol#L276-L277
Tools Used
Manual Review
Recommended Mitigation Steps
Zero check logic can be implemented.