function pushMulti(
address locker, address[] calldata assets, uint256[] calldata amounts, bytes[] calldata data
) external onlyOwner nonReentrant {
require(
IZivoeGlobals_DAO(GBL).isLocker(locker),
"ZivoeDAO::pushMulti() !IZivoeGlobals_DAO(GBL).isLocker(locker)"
);
require(assets.length == amounts.length, "ZivoeDAO::pushMulti() assets.length != amounts.length");
require(amounts.length == data.length, "ZivoeDAO::pushMulti() amounts.length != data.length");
require(ILocker_DAO(locker).canPushMulti(), "ZivoeDAO::pushMulti() !ILocker_DAO(locker).canPushMulti()");
for (uint256 i = 0; i < assets.length; i++) {
IERC20(assets[i]).safeIncreaseAllowance(locker, amounts[i]);
emit Pushed(locker, assets[i], amounts[i], data[i]);
}
ILocker_DAO(locker).pushToLockerMulti(assets, amounts, data);
for (uint256 i = 0; i < assets.length; i++) {
// ZivoeDAO MUST ensure "locker" has 0 allowance for each ERC20 token before this function concludes.
>>> if (IERC20(assets[i]).allowance(address(this), locker) > 0) { IERC20(assets[i]).safeDecreaseAllowance(locker, 0); }
}
}
Impact
While currently, all lockers will consume their entire allowance and will not cause issues, it may introduce problems if there is a locker that doesn't all allowance in the future.
use
safeApprove
instead ofsafeDecreaseAllowance
when removing allowance inside DAOLow/Info issue submitted by saidam017
Summary
After DAO push tokens to lockers, it will try to remove all the approval to 0 but wrongly use
safeDecreaseAllowance
instead ofsafeApprove
.Vulnerability Detail
It can be observed that when removing allowance to 0, it use
safeDecreaseAllowance
instead ofsafeApprove
.https://github.com/sherlock-audit/2024-03-zivoe/blob/main/zivoe-core-foundry/src/ZivoeDAO.sol#L239-L247
https://github.com/sherlock-audit/2024-03-zivoe/blob/main/zivoe-core-foundry/src/ZivoeDAO.sol#L282-L301
Impact
While currently, all lockers will consume their entire allowance and will not cause issues, it may introduce problems if there is a locker that doesn't all allowance in the future.
Code Snippet
https://github.com/sherlock-audit/2024-03-zivoe/blob/main/zivoe-core-foundry/src/ZivoeDAO.sol#L239-L247 https://github.com/sherlock-audit/2024-03-zivoe/blob/main/zivoe-core-foundry/src/ZivoeDAO.sol#L282-L301
Tool used
Manual Review
Recommendation
use
safeApprove
instead ofsafeDecreaseAllowance
when removing allowance to 0.