Permission checks in UpdateWeightRunner are split between two different sources without proper synchronization or hierarchy. Having different functions check different permission sources can lead to potential permission bypass or permanently disabled permissions.
The contract alternates between two different sources for permission checks:
Pool's immutable poolRegistry:
Own mutable storage map approvedPoolActions:
There is no obvious reason why 2 different sources for pool registry would be used. Same action masks are sometimes checked in approvedPoolActions and sometimes in poolRegistry.
Here's the list of functions that check action masks using pool's poolRegistry:
setWeightsManually() -> MASK_POOL_OWNER_UPDATES and MASK_POOL_QUANTAMM_ADMIN_UPDATES
calculateMultiplierAndSetWeightsFromRule() -> MASK_POOL_RULE_DIRECT_SET_WEIGHT
QuantAMMWeightedPool's poolRegistry is immutable and is set by deployer at the deployment time, cannot be modified.
And here's the list of functions checking action masks using approvedPoolActions mapping:
performUpdate() -> MASK_POOL_PERFORM_UPDATE
getData() -> MASK_POOL_GET_DATA
setIntermediateValuesManually() -> MASK_POOL_OWNER_UPDATES and MASK_POOL_QUANTAMM_ADMIN_UPDATES
InitialisePoolLastRunTime() -> MASK_POOL_OWNER_UPDATES and MASK_POOL_QUANTAMM_ADMIN_UPDATES
UpdateWeightRunner's approvedPoolActions can be set and modified at any time by admin doing the setApprovedActionsForPool call.
This design inconsistency can lead to a quite some permission issues. Some examples:
Deployer deploys pool with no MASK_POOL_OWNER_UPDATES action enabled, thinking this will be the permenant immutable config. However admin enables MASK_POOL_OWNER_UPDATES using setApprovedActionsForPool call and in that way enables pool manager to set intermediate values and last run time manually (but can't set weight manually)
Admin enables MASK_POOL_QUANTAMM_ADMIN_UPDATES action in order to be able to set weights manually in the emergency situation. However, even though MASK_POOL_QUANTAMM_ADMIN_UPDATES is successfully set, admin's calls to setWeightsManually fail because that function looks only into immutable registry set by deployer where this action is not enabled
In latter case there is no way to ever set weights manually, making breakglass function unusable. I consider this to be medium risk vulnerability.
Manual code review
Use a single source of truth for permissions, which is mutable by admin.
Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelyhood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.
Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelyhood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.