Logic error in AVM original owner resolution
The claim_many() function in RewardsDistributor fails to check whether a token is managed by the Auto Voting Escrow Manager (AVM), unlike claim(). As a result, rewards for expired locks delegated to AVM are sent to the AVM contract instead of the original owner, causing permanent loss of rewards.
Submitted by maze, also found by maxzuvex
https://github.com/code-423n4/2025-05-blackhole/blob/main/contracts/RewardsDistributor.sol#L196-L247
Finding description
The RewardsDistributor contract contains an inconsistency in how it handles tokens managed by the Auto Voting Escrow Manager (AVM) system. In the claim() function, there’s code to check if a token is managed by AVM and, if so, to retrieve the original owner for sending rewards. However, this critical check is missing in the claim_many() function.
This creates a discrepancy in reward distribution where:
claim()correctly sends rewards to the original owner of an AVM-managed tokenclaim_many()incorrectly sends rewards to the current NFT owner (the AVM contract itself)
Relevant code from claim():
if (_locked.end < block.timestamp && !_locked.isPermanent) {
address _nftOwner = IVotingEscrow(voting_escrow).ownerOf(_tokenId);
if (address(avm) != address(0) && avm.tokenIdToAVMId(_tokenId) != 0) {
_nftOwner = avm.getOriginalOwner(_tokenId);
}
IERC20(token).transfer(_nftOwner, amount);
}
Relevant code from claim_many():
if(_locked.end < block.timestamp && !_locked.isPermanent){
address _nftOwner = IVotingEscrow(_voting_escrow).ownerOf(_tokenId);
IERC20(token).transfer(_nftOwner, amount);
} else {
IVotingEscrow(_voting_escrow).deposit_for(_tokenId, amount);
}
Impact
This inconsistency has significant impact for users who have delegated their tokens to the AVM system:
- Users who have expired locks and whose tokens are managed by AVM will lose their rewards if
claim_many()is called instead ofclaim(). - The rewards will be sent to the AVM contract, which has no mechanism to forward these tokens to their rightful owners.
- This results in permanent loss of rewards for affected users.
- Since
claim_many()is more gas efficient for claiming multiple tokens, it’s likely to be frequently used, increasing the likelihood and impact of this issue.
Recommended mitigation steps
- Add the AVM check to the
claim_many()function to match the behavior inclaim():
if(_locked.end < block.timestamp && !_locked.isPermanent){
address _nftOwner = IVotingEscrow(_voting_escrow).ownerOf(_tokenId);
if (address(avm) != address(0) && avm.tokenIdToAVMId(_tokenId) != 0) {
_nftOwner = avm.getOriginalOwner(_tokenId);
}
IERC20(token).transfer(_nftOwner, amount);
} else {
IVotingEscrow(_voting_escrow).deposit_for(_tokenId, amount);
}
- For better code maintainability, consider refactoring the owner resolution logic to a separate internal function:
function _getRewardRecipient(uint256 _tokenId) internal view returns (address) {
address _nftOwner = IVotingEscrow(voting_escrow).ownerOf(_tokenId);
if (address(avm) != address(0) && avm.tokenIdToAVMId(_tokenId) != 0) {
_nftOwner = avm.getOriginalOwner(_tokenId);
}
return _nftOwner;
}
Then, use this function in both claim() and claim_many() to ensure consistent behavior.
Proof of Concept
Scenario:
-
User A delegates their tokenId #123 to the AVM system.
-
The lock for tokenId #123 expires.
-
Someone calls
claim(123):- AVM check triggers and rewards go to User A (correct behavior)
-
Someone calls
claim_many([123]):- No AVM check happens, rewards go to the AVM contract (incorrect behavior)
-
User A permanently loses their rewards.
Status: Mitigation confirmed. Full details in reports from rayss and maxvzuvex.
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 claim_many() function omits the AVM original owner check that is present in claim(), leading to inconsistent reward recipient resolution.
Impact
Users who have expired locks and whose tokens are managed by AVM will lose their rewards if claim_many() is called instead of claim(), and the rewards are sent to the AVM contract with no mechanism to forward them, resulting in permanent loss.
What the attacker needed
User delegates token to AVM; Lock expires; claim_many() is called
The fix
The mitigation was confirmed; the fix adds the AVM check to claim_many() to match claim() and refactors owner resolution into a shared internal function.
How it was found
- User A delegates their tokenId #123 to the AVM system.
- The lock for tokenId #123 expires.
- Someone calls claim(123): AVM check triggers and rewards go to User A (correct behavior).
- Someone calls claim_many([123]): No AVM check happens, rewards go to the AVM contract (incorrect behavior).
- User A permanently loses their rewards.
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.
This is a smart contract bug where two functions that should behave the same way don't. One function correctly sends rewards to the real owner of a token, but the other sends them to a manager contract that cannot forward them, so users lose their rewards.
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.