Vault.blacklistProtocol can revert in emergency
The Vault.blacklistProtocol function attempts to withdraw all underlying balance from a protocol, which can revert if the protocol is hacked or paused, preventing the protocol from being blacklisted. This could leave the system unable to remove a compromised protocol, potentially causing operational issues.
HonorLt Follow with rvierdiiev
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2023-01-derby-judging/issues/128
Found by
HonorLt, rvierdiiev
Summary
Vault.blacklistProtocol can revert in emergency, because it tries to withdraw underlying balance from protocol, which can revert for many reasons after it's hacked or paused.
Vulnerability Detail
Vault.blacklistProtocol is created for emergency cases and it's needed to remove protocol from protocols that allowed to deposit.
https://github.com/sherlock-audit/2023-01-derby/blob/main/derby-yield-optimiser/contracts/Vault.sol#L477-L483
function blacklistProtocol(uint256 _protocolNum) external onlyGuardian {
uint256 balanceProtocol = balanceUnderlying(_protocolNum);
currentAllocations[_protocolNum] = 0;
controller.setProtocolBlacklist(vaultNumber, _protocolNum);
savedTotalUnderlying -= balanceProtocol;
withdrawFromProtocol(_protocolNum, balanceProtocol);
}
The problem is that this function is trying to withdraw all balance from protocol.
This can create problems as in case of hack, attacker can steal funds, pause protocol and any other things that can make withdrawFromProtocol function to revert.
Because of that it will be not possible to add protocol to blacklist and as result system will stop working correctly.
Impact
Hacked or paused protocol can't be set to blacklist.
Code Snippet
Provided above
Tool used
Manual Review
Recommendation
Provide needToWithdraw param to the blacklistProtocol function. In case if it's safe to withdraw, then withdraw, otherwise, just set protocol as blacklisted. Also you can call function with true param again, once it's safe to withdraw.
Example of hack situation flow:
1.underlying vault is hacked
2.you call setProtocolBlacklist("vault", false) which blacklists vault
3.in next tx you call setProtocolBlacklist("vault", true) and tries to withdraw
Discussion
sjoerdsommen
Disagree with severity because it's unlikely to result in (extra) loss of funds
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 blacklistProtocol function combines the blacklisting action with a withdrawal attempt, so if the withdrawal reverts, the blacklisting is also blocked.
Impact
A hacked or paused protocol cannot be blacklisted, which may prevent the system from functioning correctly.
What the attacker needed
Protocol is hacked or paused
The fix
The blacklistProtocol function should accept a parameter to optionally skip the withdrawal, allowing blacklisting even when withdrawal is unsafe.
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 has a function to blacklist a protocol in an emergency, but that function also tries to withdraw all funds from the protocol. If the protocol is hacked or paused, the withdrawal fails, so the blacklisting never happens. This means the system cannot properly respond to an emergency.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.