Missing _token.approve() to curvePool in setZapConfig
The setZapConfig function updates the curvePool and token addresses but does not approve the new token for the new curvePool. If governance changes these addresses, the contract's minting function would fail because the token transfer would revert.
Submitted by WatchPug
SettToRenIbbtcZap.sol L162-L183
function setZapConfig(
uint256 _idx,
address _sett,
address _token,
address _curvePool,
address _withdrawToken,
int128 _withdrawTokenIndex
) external {
_onlyGovernance();
require(_sett != address(0));
require(_token != address(0));
require(
_withdrawToken == address(WBTC) || _withdrawToken == address(RENBTC)
);
zapConfigs[_idx].sett = ISett(_sett);
zapConfigs[_idx].token = IERC20Upgradeable(_token);
zapConfigs[_idx].curvePool = ICurveFi(_curvePool);
zapConfigs[_idx].withdrawToken = IERC20Upgradeable(_withdrawToken);
zapConfigs[_idx].withdrawTokenIndex = _withdrawTokenIndex;
}
In the current implementation, when curvePool or token got updated, token is not approved to curvePool, which will malfunction the contract and break minting.
Recommendation
Change to:
function setZapConfig(
uint256 _idx,
address _sett,
address _token,
address _curvePool,
address _withdrawToken,
int128 _withdrawTokenIndex
) external {
_onlyGovernance();
require(_sett != address(0));
require(_token != address(0));
require(
_withdrawToken == address(WBTC) || _withdrawToken == address(RENBTC)
);
if (zapConfigs[_idx].curvePool != _curvePool && _curvePool != address(0)) {
IERC20Upgradeable(_token).safeApprove(
_curvePool,
type(uint256).max
);
}
zapConfigs[_idx].sett = ISett(_sett);
zapConfigs[_idx].token = IERC20Upgradeable(_token);
zapConfigs[_idx].curvePool = ICurveFi(_curvePool);
zapConfigs[_idx].withdrawToken = IERC20Upgradeable(_withdrawToken);
zapConfigs[_idx].withdrawTokenIndex = _withdrawTokenIndex;
}
GalloDaSballo (BadgerDAO) confirmed:
Agree with the finding, it should be noted that adding a pool does handle for the scenario, this would break the pool in case we update it or change the token
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 setZapConfig function updates the curvePool and token addresses but does not call safeApprove to grant the new curvePool allowance to spend the new token.
Impact
If governance updates the curvePool or token, the contract's minting function would break because the token transfer would revert due to missing approval.
What the attacker needed
Governance updates curvePool or token
The fix
The setZapConfig function should be modified to call safeApprove for the new curvePool when it changes, as shown in the recommendation.
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 a configuration update forgets to grant permission for a new token to be spent by a new pool. Without that permission, any later attempt to move the token will fail, breaking the contract's main function.
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.