BathBuddy contract should implement methods to pause and unpause contract
The BathBuddy contract inherits OpenZeppelin's Pausable but does not expose any public or external function to pause or unpause it. As a result, the protocol admin cannot pause the getReward function when needed.
Submitted by adriro, also found by brgltd, 0xnacho, zhuXKET, Ace-30, ddimitrov22, markus_ether, AlexCzm, qbs, luciana, juancito, said, cccz, bytes032 and T1MOH.
The BathBuddy contract inherits from OpenZeppelin Pausable contract with the intention of adding pausing features to the contract.
https://github.com/code-423n4/2023-04-rubicon/blob/main/contracts/periphery/BathBuddy.sol#L38
38: contract BathBuddy is ReentrancyGuard, IBathBuddy, Pausable {
The Pausable implementation contains all the logic to implement pausing, but doesn’t include any external or public functionality to actually trigger the pause or resume, this task is left to the derived contract.
The BathBuddy contract fails to implement these functions, as there is no callable function from the outside that modifies the pause state. The pausing mechanism is intended to be used in the getReward function, as this function includes the whenNotPaused:
https://github.com/code-423n4/2023-04-rubicon/blob/main/contracts/periphery/BathBuddy.sol#L168-L185
168: function getReward(
169: IERC20 rewardsToken,
170: address holderRecipient
171: )
172: external
173: override
174: nonReentrant
175: whenNotPaused
176: updateReward(holderRecipient, address(rewardsToken))
177: onlyBathHouse
178: {
179: uint256 reward = tokenRewards[address(rewardsToken)][holderRecipient];
180: if (reward > 0) {
181: tokenRewards[address(rewardsToken)][holderRecipient] = 0;
182: rewardsToken.safeTransfer(holderRecipient, reward);
183: emit RewardPaid(holderRecipient, reward);
184: }
185: }
This means that protocol admin won’t be able to pause this function if needed as there is no accessible function to enable the mechanism at all.
Proof of Concept
The BathBuddy contract code doesn’t include any external or public function to pause or resume the contract. The OpenZeppelin implementations only contains internal functions to provide support so that the derived contract implements the public interface:
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
Recommendation
The BathBuddy contract should implement the functions to expose the pausing mechanism. These functions should only be accessible to the owner of the contract.
function pause() external onlyOwner {
_pause();
}
function unpause() external onlyOwner {
_unpause();
}
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
Impact
The protocol admin cannot pause the getReward function, so the intended emergency stop mechanism is unavailable.
What the attacker needed
None
The fix
The contract should implement public pause and unpause functions restricted to the owner that call the internal _pause and _unpause methods.
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 pause feature lets an admin stop certain actions in a smart contract, like a safety switch. The contract includes the internal machinery for pausing but forgot to add the public buttons that the admin could press to actually pause or resume. So the safety switch exists but cannot be used.
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.