Attacker can call sweepRewardToken() when bribesProcessor==0 and reward funds will be lost because there is no check in sweepRewardToken() and _handleRewardTransfer() and _sendTokenToBribesProcessor()
The contract's sweepRewardToken function transfers reward tokens to the bribesProcessor address without checking if it is the zero address. If bribesProcessor is unset or set to zero, an attacker can call sweepRewardToken to send all reward tokens to the zero address, causing permanent loss.
Originally disclosed on Code4rena
Submitted by unforgiven, also found by GimelSec, and zzzitron
Impact
If the value of bribesProcessor was 0x0 (the default is 0x0 and governance() can set to 0x0) then attacker can call sweepRewardToken() make contract to send his total balance in attacker specified token to 0x0 address.
Proof of Concept
The default value of bribesProcessor is 0x0 and governance can set the value to 0x0 at any time. Rewards are stacking in contract address and they are supposed to send to bribesProcessor.
This is sweepRewardToken() and _handleRewardTransfer() and _sendTokenToBribesProcessor() code:
/// @dev Function to move rewards that are not protected
/// @notice Only not protected, moves the whole amount using _handleRewardTransfer
/// @notice because token paths are hardcoded, this function is safe to be called by anyone
/// @notice Will not notify the BRIBES_PROCESSOR as this could be triggered outside bribes
function sweepRewardToken(address token) public nonReentrant {
_onlyGovernanceOrStrategist();
_onlyNotProtectedTokens(token);
uint256 toSend = IERC20Upgradeable(token).balanceOf(address(this));
_handleRewardTransfer(token, toSend);
}
function _handleRewardTransfer(address token, uint256 amount) internal {
// NOTE: BADGER is emitted through the tree
if (token == BADGER) {
_sendBadgerToTree(amount);
} else {
// NOTE: All other tokens are sent to bribes processor
_sendTokenToBribesProcessor(token, amount);
}
}
function _sendTokenToBribesProcessor(address token, uint256 amount) internal {
// TODO: Too many SLOADs
IERC20Upgradeable(token).safeTransfer(address(bribesProcessor), amount);
emit RewardsCollected(token, amount);
}
As you can see calling sweepRewardToken() eventually (sweepRewardToken() -> _handleRewardTransfer() -> _sendTokenToBribesProcessor()) would transfer reward funds to bribesProcessor and there is no check that bribesProcessor!=0x0 in execution follow. so attacker can call sweepRewardToken() when bribesProcessor is 0x0 and contract will lose all reward tokens.
Tools Used
VIM
Recommended Mitigation Steps
Check the value of bribesProcessor in _sendTokenToBribesProcessor().
Alex the Entreprenerd (BadgerDAO) confirmed and commented:
A transfer to address 0 would cause a loss, we should have a check or add a safe default (governance for example).
Mitigated by adding a 0 check.
jack-the-pug (judge) validated
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 function _sendTokenToBribesProcessor lacks a check that bribesProcessor is not the zero address before transferring tokens.
Impact
All reward tokens of the specified token can be permanently lost, as they are sent to the zero address.
What the attacker needed
BribesProcessor is zero address; attacker can call sweepRewardToken
The fix
The contract was mitigated by adding a zero-address check in _sendTokenToBribesProcessor.
How it was found
- Ensure bribesProcessor is set to the zero address (default or by governance).
- Call sweepRewardToken with a token address that is not protected.
- The function transfers the entire token balance to the zero address.
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 holds reward tokens and is supposed to send them to a special address called bribesProcessor. If that address is not set (it is the zero address), calling a public function sends all tokens to the zero address, which is like a black hole. The contract should check that the address is not zero before sending.
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.