Missing checks in Kernel._deactivatePolicy
The Kernel contract's _deactivatePolicy function lacks a check that the policy being removed is actually registered, so attempting to remove an unregistered policy removes the policy at index 0 instead. An attacker could not directly exploit this, but a mistaken call by the executor could disrupt protocol functionality.
Submitted by enckrish
There are no checks to ascertain that the policy being removed is registered in the Kernel. Trying to remove a non-registered results in the policy registered at 0th index of activePolicies being removed.
Proof of Concept
https://github.com/code-423n4/2022-08-olympus/blob/main/src/Kernel.sol#L325
Recommended Mitigation Steps
Adding require(activePolicies[idx] == policy_, "Unregistered policy"); will prevent this, where idx = getPolicyIndex[policy_].
NOTE: The issue is less likely to happen as this is handled solely by the executor, but having safeguards in the contract is always better than relying on an external factor.
ind-igo (Olympus) confirmed, but disagreed with severity and commented:
Confirmed. Should be lower risk or a QA issue.
@ind-igo - can you comment on why you think it should be QA vs Medium?
— Med: Assets not at direct risk, but the function of the protocol or its availability could be impacted, or leak value with a hypothetical attack path with stated assumptions, but external requirements.I would expect this to impact the functionality of the protocol.
This one seems on the fence to me. While accidentally unregistering a policy likely would affect the functionality of the protocol, it requires the executor to make a mistake. If the mistake is made, it’s easily remedied by re-registering the policy.
That makes sense, but there would be some amount of down time when this occurred. I think Medium is correct for this issue.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the _deactivatePolicy function uses an index from a mapping without verifying that the policy at that index matches the policy being removed.
Impact
If the executor mistakenly calls _deactivatePolicy with an unregistered policy, the wrong policy is removed, potentially causing downtime and affecting protocol functionality, though the mistake can be remedied by re-registering the policy.
What the attacker needed
Executor makes a mistake
The fix
The function should be fixed by adding a require statement that checks the policy at the computed index matches the policy being removed.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A smart contract has a list of policies (modules) it uses. When removing one, the code does not check that the policy is actually in the list. If someone tries to remove a policy that is not there, the code mistakenly removes the first policy in the list instead. This could cause the system to stop working correctly until the mistake is fixed.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.