Skip to content
DoS Audit finding Intermediate

Incorrect unlockTime can DOS withdrawGovernanceAsset

The unlockTime in the FlashGovernanceArbiter contract is incorrectly incremented by block.timestamp instead of being set to a fixed future time. An attacker could repeatedly call assertGovernanceApproved to push unlockTime far into the future, causing a denial of service for withdrawGovernanceAsset.

Anurag Jain Follow

Originally disclosed on Code4rena

Submitted by csanuragjain

unlockTime is set incorrectly.

Proof of Concept

  1. Navigate to contract at https://github.com/code-423n4/2022-01-behodler/blob/main/contracts/DAO/FlashGovernanceArbiter.sol
  2. Observe the assertGovernanceApproved function
function assertGovernanceApproved(
    address sender,
    address target,
    bool emergency
  ) public {
...
pendingFlashDecision[target][sender].unlockTime += block.timestamp;
...
}
  1. Assume assertGovernanceApproved is called with sender x and target y and pendingFlashDecision[target][sender].unlockTime is 100 and block.timestamp is 10000 then
pendingFlashDecision[target][sender].unlockTime += block.timestamp; // 10000+100=10100
  1. Again assertGovernanceApproved is called with same argument after timestamp 10100. This time unlockTime is set to very high value (assume block.timestamp is 10500). This is incorrect
pendingFlashDecision[target][sender].unlockTime += block.timestamp; // 10100+10500=20600

Recommended Mitigation Steps

Unlock time should be calculated like below:

constant public CONSTANT_UNLOCK_TIME = 1 days; // example
pendingFlashDecision[target][sender].unlockTime = CONSTANT_UNLOCK_TIME +  block.timestamp;

gititGoro (Behodler) confirmed and commented:

Well spotted. This is a variant of a previously reported issue where the recommendation was to not allow flash governing a contract until stake has been withdrawn which is a safer fix.

Jack the Pug (judge) commented:

I’m keeping this as Med instead of marking it as a duplicate of #156 as it did not illustrate the severe impact that it can cause.


The original report as published on Code4rena, by csanuragjain. 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 uses addition assignment (+=) with block.timestamp to set unlockTime, causing it to accumulate instead of being set to a fixed future time.

Impact

An attacker could cause a denial of service by making unlockTime very large, preventing withdrawal of governance assets.

What the attacker needed

Ability to call assertGovernanceApproved

The fix

The unlock time should be set to a constant unlock period plus the current block timestamp, not incremented.

How it was found

  1. Navigate to the FlashGovernanceArbiter contract.
  2. Observe the assertGovernanceApproved function.
  3. Call assertGovernanceApproved with sender x and target y when unlockTime is 100 and block.timestamp is 10000, resulting in unlockTime 10100.
  4. Call assertGovernanceApproved again with the same arguments after timestamp 10100, resulting in unlockTime 20600.

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 function adds the current time to a stored unlock time each time it is called, so calling it repeatedly makes the unlock time grow very large. This can prevent users from withdrawing their governance assets because the unlock time never arrives.

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 Anurag Jain

View all

63 more disclosed reports, best first.

More from Behodler 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.