Skip to content
DoS Audit finding Intermediate

Activating same Policy multiple times in Kernel possible

The Kernel contract trusted a policy contract's own isActive() return value to decide whether it was already registered, so a malicious policy returning false could be activated repeatedly. This broke uniqueness invariants, made deactivation fail, and could cause out-of-gas denial of service when iterating over the duplicated policy list.

Lambda Follow

Originally disclosed on Code4rena

Submitted by Lambda, also found by enckrish

https://github.com/code-423n4/2022-08-olympus/blob/549b96bcf8b97807738572605f6b1e26b33ef411/src/Kernel.sol#L296

To check that an already active policy is not added a second time, isActive() is called on the policy. However, policy could be a malicious contract that always returns false for isActive(). In such a scenario, it would be possible to activate the policy multiple times for the same Kernel. This would break uniqueness invariants such that _deactivatePolicy() no longer works. However, it could also be used for a DoS attack: As _reconfigurePolicies and _migrateKernel iterate over those lists that now contain duplicates, they could run out of gas if a policy is activated enough times.

Recommended Mitigation Steps

Check getPolicyIndex[policy_] != 0 instead of relying on a value of an untrusted contract.

0xLienid (Olympus) commented:

@ind-igo a few other submissions also mention problems with over-reliance on policy.isActive (i.e. #368). Might be worth mitigating with the suggested step here or the check on activePolicies[index] like 368 mentions.

ind-igo (Olympus) commented:

Dupe of #368

0xean (judge) commented:

I think this is separate from #368 which is about a policy deactivating that isn’t already active.

I am a bit skeptical at the impact statement currently, but it does seem like protocol functionality does end up in a bad state with the typical policy lifecycle here. Will award as Medium unless Sponsor wants to provide some additional reasoning as to a downgrade.

ind-igo (Olympus) commented:

While the issue is slightly different from #368, the solution is the exact same. The remediation has the new checks to prevent both of these issues.


The original report as published on Code4rena, by Lambda. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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 contract relied on an untrusted external contract's isActive() return value instead of checking its own internal registry mapping.

Impact

A malicious policy could be activated many times, breaking uniqueness and deactivation, and potentially causing a denial of service through out-of-gas errors in loops over the duplicated list.

What the attacker needed

Attacker controls a policy contract; policy is activated via Kernel

The fix

The check should use the Kernel's own internal policy index mapping rather than the untrusted contract's isActive() return value; the sponsor confirmed the remediation adds new checks.

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 here (the Kernel) keeps a list of helper contracts called policies. Before adding one, it asks the policy itself whether it is already active, which is like trusting a stranger to tell you if they are already on the guest list. A malicious policy can lie and say no every time, so it gets added over and over, filling the list until later loops run out of gas.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by Lambda

View all

64 more disclosed reports, best first.

More from Olympus DAO contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.