Summary
In the UpdateWeightRunner.sol:setWeightsManually() function poolRegistryEntry immutable variable is being fetched from pool. Unlike other functions, such as setIntermediateValuesManually() or InitialisePoolLastRunTime() which rely on the poolRegistry maintained in the UpdateWeightRunner.sol contract and can be modified by admin.
Vulnerability Details
This design flaw can restrict the flexibility and accessibility of updating weights manually in emergency situations.
UpdateWeightRunner.sol:setWeightsManually():
function setWeightsManually(
int256[] calldata _weights,
address _poolAddress,
uint40 _lastInterpolationTimePossible,
uint _numberOfAssets
) external {
uint256 poolRegistryEntry = QuantAMMWeightedPool(_poolAddress).poolRegistry();
if (poolRegistryEntry & MASK_POOL_OWNER_UPDATES > 0) {
require(msg.sender == poolRuleSettings[_poolAddress].poolManager, "ONLYMANAGER");
} else if (poolRegistryEntry & MASK_POOL_QUANTAMM_ADMIN_UPDATES > 0) {
require(msg.sender == quantammAdmin, "ONLYADMIN");
} else {
revert("No permission to set weight values");
}
for (uint i; i < _weights.length; i++) {
if (i < _numberOfAssets) {
require(_weights[i] > 0, "Negative weight not allowed");
require(_weights[i] < 1e18, "greater than 1 weight not allowed");
}
}
IQuantAMMWeightedPool(_poolAddress).setWeights(_weights, _poolAddress, _lastInterpolationTimePossible);
emit SetWeightManual(msg.sender, _poolAddress, _weights, _lastInterpolationTimePossible);
}
QuantAMMWeightedPool.sol:
uint256 public immutable poolRegistry;
...
constructor(
NewPoolParams memory params,
IVault vault
) BalancerPoolToken(vault, params.name, params.symbol) PoolInfo(vault) Version(params.version) {
_totalTokens = params.numTokens;
updateWeightRunner = UpdateWeightRunner(params.updateWeightRunner);
quantammAdmin = updateWeightRunner.quantammAdmin();
poolRegistry = params.poolRegistry;
require(params.poolDetails.length <= 50, "Limit exceeds array length");
for(uint i; i < params.poolDetails.length; i++){
require(params.poolDetails[i].length == 4, "detail needs all 4 [category, name, type, detail]");
}
poolDetails = params.poolDetails;
}
Impact
Inability to respond quickly in emergencies and potential lockout of quantAMM admin
Tools Used
Manual Review
Recommendations
Use poolRegistryEntry from the same UpdateWeightRunner.sol contract:
uint256 poolRegistryEntry = approvedPoolActions[_poolAddress];