Loss Of Flash Governance Tokens If They Are Not Withdrawn Before The Next Request
The contract overwrites a user's pending flash governance decision when assertGovernanceApproved is called again for the same target and sender, causing previously locked tokens to become unaccounted for and locked in the contract. An attacker can call this public function to make any arbitrary sender's tokens inaccessible.
Originally disclosed on Code4rena
Submitted by kirk-baird
Users who have not called withdrawGovernanceAsset() after they have locked their tokens from a previous proposal (i.e. assertGovernanceApproved), will lose their tokens if assertGovernanceApproved() is called again with the same target and sender.
The sender will lose pendingFlashDecision[target][sender].amount tokens and the tokens will become unaccounted for and locked in the contract. Since the new amount is not added to the previous amount, instead the previous amount is overwritten with the new amount.
The impact of this is worsened by another vulnerability, that is assertGovernanceApproved() is a public function and may be called by any arbitrary user so long as the sender field has called approve() for FlashGovernanceArbiter on the ERC20 token. This would allow an attacker to make these tokens inaccessible for any arbitrary sender.
Proof of Concept
In assertGovernanceApproved() as seen below, the linependingFlashDecision[target][sender] = flashGovernanceConfig will overwrite the previous contents. Thereby, making any previous rewards unaccounted for and inaccessible to anyone.
Note that we must wait pendingFlashDecision[target][sender].unlockTime between calls.
function assertGovernanceApproved(
address sender,
address target,
bool emergency
) public {
if (
IERC20(flashGovernanceConfig.asset).transferFrom(sender, address(this), flashGovernanceConfig.amount) &&
pendingFlashDecision[target][sender].unlockTime < block.timestamp
) {
require(
emergency || (block.timestamp - security.lastFlashGovernanceAct > security.epochSize),
"Limbo: flash governance disabled for rest of epoch"
);
pendingFlashDecision[target][sender] = flashGovernanceConfig;
pendingFlashDecision[target][sender].unlockTime += block.timestamp;
security.lastFlashGovernanceAct = block.timestamp;
emit flashDecision(sender, flashGovernanceConfig.asset, flashGovernanceConfig.amount, target);
} else {
revert("LIMBO: governance decision rejected.");
}
}
Recommended Mitigation Steps
Consider updating the initial if statement to ensure the pendingFlashDecision for that target and sender is empty, that is:
function assertGovernanceApproved(
address sender,
address target,
bool emergency
) public {
if (
IERC20(flashGovernanceConfig.asset).transferFrom(sender, address(this), flashGovernanceConfig.amount) &&
pendingFlashDecision[target][sender].unlockTime == 0
) {
...
Note we cannot simply add the new amount to the previous amount incase the underlying asset has been changed.
gititGoro (Behodler) confirmed and commented:
Excellent find! Thank you.
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
The function overwrites the pendingFlashDecision mapping entry instead of checking for or adding to an existing entry, so previously locked tokens are lost.
Impact
The sender loses the previously locked tokens, which become locked in the contract; an attacker can cause this for any arbitrary sender who has approved the contract.
What the attacker needed
Sender has approved the contract to spend tokens; attacker can call the public function; wait until unlockTime has passed
The fix
The function should check that the pendingFlashDecision for that target and sender is empty (unlockTime == 0) before accepting a new decision.
How it was found
- A sender calls approve() for FlashGovernanceArbiter on the ERC20 token.
- The sender calls assertGovernanceApproved() to lock tokens for a target.
- Wait until the unlockTime of the pending decision has passed.
- Call assertGovernanceApproved() again with the same target and sender.
- The previous pending decision is overwritten, and the earlier tokens become locked and unaccounted for.
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 lets users lock tokens to vote on proposals. If a user locks tokens again for the same proposal without first withdrawing the old ones, the contract forgets about the old tokens, so they are stuck forever. Because anyone can trigger this, an attacker can cause this loss for any user who has approved the contract to spend their tokens.
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.