Summary
BaseGauge::_getBaseWeight has wrong implementation.
If we call it to get the base weight for an account
, rather than getting the base weight for the account
we will get the base weight for address(this)
Vulnerability Details
BaseGauge::_getBaseWeight
* @notice Gets base weight for an account
* @dev Virtual function to be implemented by child contracts
* @param account Address to get weight for
* @return Base weight value
*/
function _getBaseWeight(address account) internal view virtual returns (uint256) {
return IGaugeController(controller).getGaugeWeight(address(this)); 👈👈
}
On BaseGauge::getUserWeight we can see it is passing an account
address and then call _applyBoost
.
But it will return the baseWeight
for address(this)
not for the passed account
's address.
* @notice Gets user's current weight including boost
* @param account Address to get weight for
* @return User's current weight
*/
function getUserWeight(address account) public view virtual returns (uint256) {
uint256 baseWeight = _getBaseWeight(account); 👈👈
return _applyBoost(account, baseWeight);
}
Impact
The function does not return the correct value as expected, as a result, it will break the protocol's functionality.
Tools Used
Manual review
Recommendations
/**
* @notice Gets base weight for an account
* @dev Virtual function to be implemented by child contracts
* @param account Address to get weight for
* @return Base weight value
*/
function _getBaseWeight(address account) internal view virtual returns (uint256) {
- return IGaugeController(controller).getGaugeWeight(address(this));
+ return IGaugeController(controller).getGaugeWeight(account);
}