IWNat(address(token)).governanceVotePower().undelegate() is redundant after undelegateGovernance()
The destroy() function calls undelegate() on a token's governance vote power even when the delegation was already removed by an earlier undelegateGovernance() call. This causes a redundant second undelegation and wasted gas, and leaves internal state flags out of sync with the real delegation state.
- Disclosed after under an hour
#45310 [SC-Insight] `IWNat(address(token)).governanceVotePower().undelegate()` is redundant after `undelegateGovernance()`
Submitted on May 12th 2025 at 13:21:52 UTC by @magtentic for Audit Comp | Flare | FAssets
- Report ID: #45310
- Report Type: Smart Contract
- Report severity: Insight
- Target: https://github.com/flare-labs-ltd/fassets/blob/main/docs/ImmunefiScope.md
- Impacts:
Description
Brief/Intro
The destroy() function unnecessarily calls IWNat(address(token)).governanceVotePower().undelegate() even when the delegation has already been removed via a prior call to undelegateGovernance(). This leads to redundant operations and suboptimal gas usage.
Vulnerability Details
The flag TOKEN_DELEGATE_GOVERNANCE is set to tokenUseFlags[token] via _tokenUsed() during a call to delegateGovernance(), but it is not cleared when undelegateGovernance() is invoked. This causes destroy() to interpret the token as still being actively delegated, resulting in a second, redundant call to undelegate().
Example:
Flag is set:
function delegateGovernance(IVPToken _token, address _to) external override onlyOwner {
_token.governanceVotePower().delegate(_to);
_tokenUsed(_token, TOKEN_DELEGATE_GOVERNANCE);
}
Flag is not cleared:
function undelegateGovernance(IVPToken _token) external override onlyOwner {
_token.governanceVotePower().undelegate();
}
Redundant check in destroy():
if ((useFlags & TOKEN_DELEGATE_GOVERNANCE) != 0) {
IWNat(address(token)).governanceVotePower().undelegate();
}
Impact Details
- Redundant logic:
undelegate()is called twice for the same token, increasing unnecessary gas costs. - Potential confusion: It creates a mismatch between internal state (tokenUseFlags) and actual delegation state.
- Maintainability issue: Future contributors may misinterpret this logic or fail to reason correctly about token state.
References
Add any relevant links to documentation or code
Proof of Concept
Proof of Concept
Refer to Vulnerability Details for guidance on why the code is redundant. Runnable PoCs are not required for Smart Contract & Blockchain/DLT bug reports
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 TOKEN_DELEGATE_GOVERNANCE flag is set in delegateGovernance() but never cleared in undelegateGovernance(), so destroy() still believes the token is delegated.
Impact
The redundant call wastes gas and creates a mismatch between the stored flags and the real delegation state, which could confuse future maintainers; no direct security impact is claimed.
What the attacker needed
Owner-only functions; token previously delegated
The fix
The flag should be cleared when undelegateGovernance() is called, or the redundant undelegate() call in destroy() should be 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 keeps a small note (a flag) saying whether a token's voting power has been handed to someone else. When the owner cancels that handover, the code forgets to update the note, so later cleanup code thinks the handover is still active and cancels it a second time. That second cancellation does nothing useful and costs extra gas, the fee paid to run code on the blockchain.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.