Owner can not set the ve address via RewardDistributor.addVoteEscrow
The addVoteEscrow function assigned the ve address from an uninitialised storage variable instead of the function parameter, so the ve address stayed at zero. This prevented veNFT holders from claiming reward tokens and Ether rewards through multiStakerClaim.
Originally disclosed on Code4rena
Submitted by berndartmueller, also found by 0x1f8b, 0x52, 0xA5DF, 0xsanson, auditor0517, CRYP70, GimelSec, hansfriese, hyh, Krow10, panprog, rajatbeladiya, rbserver, teddav, and TrungOre
On the initial RewardDistributor.addVoteEscrow call, the owner of the contract can set the ve address without a timelock (which is as intended according to the function documentation). However, as the function parameter _voteEscrow is not used for the assignment, instead the storage variable pendingVoteEscrow (which is not initialized, hence address(0)) is used, the ve storage variable can not be set to the provided _voteEscrow address.
This prevents setting the ve address (ve is set to address(0)) and therefore prevents veNFT holders to claim reward tokens and Ether rewards via RewardDistributor.multiStakerClaim.
Proof of Concept
function addVoteEscrow(address _voteEscrow) external onlyOwner {
if (address(ve) == address(0)) {
ve = VE(pendingVoteEscrow); // @audit-info The wrong variable is used. It should be `_voteEscrow`
} else {
voteEscrowEnableDate = block.timestamp + 1 days;
pendingVoteEscrow = _voteEscrow;
}
}
function multiStakerClaim(uint256[] memory tokenids, uint256[] memory epochs) public {
require(address(ve) != address(0), ' VE not added yet'); // @audit-info reverts if `ve` is not initialized
...
}
Recommended Mitigation Steps
Use the correct function parameter _voteEscrow:
function addVoteEscrow(address _voteEscrow) external onlyOwner {
if (address(ve) == address(0)) {
ve = VE(_voteEscrow);
} else {
voteEscrowEnableDate = block.timestamp + 1 days;
pendingVoteEscrow = _voteEscrow;
}
}
0xsaruman (Golom) resolved and commented:
Resolved by removing the manually added timelocks and setting the Vote escrow in constructor and a function to change voteescrow by owner
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 assignment used the uninitialised storage variable pendingVoteEscrow instead of the _voteEscrow function parameter.
Impact
The ve address remains zero, so veNFT holders cannot claim reward tokens or Ether rewards via multiStakerClaim.
What the attacker needed
Contract owner calls addVoteEscrow; ve address still zero
The fix
The issue was resolved by removing the manual timelocks and setting the vote escrow in the constructor, with an owner function to change it.
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 setting that tells it which other contract holds the voting-power tokens. The owner tried to set it, but the code copied the value from an empty slot instead of the address they supplied, so the setting stayed blank. Because of that, people holding those voting tokens could not collect their rewards.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.