Excessive require makes the transaction fail unexpectedly
The deposit function checks a block lock on the RENCRV vault even when the deposit does not involve that vault, causing unrelated deposits to revert if the vault was used earlier in the same block. An attacker could exploit this to cause denial of service for other users' deposits.
Submitted by WatchPug
The check for RENCRV_VAULT.blockLock is only needed when if (_amounts[1] > 0 || _amounts[2] > 0).
However, in the current implementation, the check is done at the very first, making transactions unrelated to RENCRV_VAULT fail unexpectedly if there is a prior transaction involved with RENCRV_VAULT in the same block.
function deposit(uint256[4] calldata _amounts, uint256 _minOut)
public
whenNotPaused
{
// Not block locked by setts
require(
RENCRV_VAULT.blockLock(address(this)) < block.number,
"blockLocked"
);
require(
IBBTC_VAULT.blockLock(address(this)) < block.number,
"blockLocked"
);
uint256[4] memory depositAmounts;
for (uint256 i = 0; i < 4; i++) {
if (_amounts[i] > 0) {
ASSETS[i].safeTransferFrom(
msg.sender,
address(this),
_amounts[i]
);
if (i == 0 || i == 3) {
// ibbtc and sbtc
depositAmounts[i] += _amounts[i];
}
}
}
if (_amounts[1] > 0 || _amounts[2] > 0) {
// Use renbtc and wbtc to mint ibbtc
// NOTE: Can change to external zap if implemented
depositAmounts[0] += _renZapToIbbtc([_amounts[1], _amounts[2]]);
}
// ...
}
shuklaayush (BadgerDAO) confirmed
GalloDaSballo (BadgerDAO) commented:
Agree with the finding, we would have to check for those locks only under specific condition, not doing so opens up to unnecessary reverts
GalloDaSballo (BadgerDAO) patched:
We have mitigated by following the advice of the warden
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 require statement for RENCRV_VAULT.blockLock is placed before the conditional that checks if renBTC or wBTC amounts are positive, so it runs even when those tokens are not used.
What the attacker needed
A prior transaction in the same block uses RENCRV_VAULT
The fix
The check should be moved inside the conditional block so it only runs when renBTC or wBTC amounts are positive; the report states the issue was mitigated by following this advice.
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 function checks a lock that only matters for certain tokens, but it does so for every deposit. If someone else used the locked vault earlier in the same block, your deposit fails even though it doesn't use that vault. This is like a door that only needs a key for one room, but the key is required to enter the building at all.
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.