StakedCitadel: wrong setupVesting function name
The StakedCitadel contract calls a vesting function named setupVesting, but the actual vesting contract only exposes a function called vest. As a result, the withdraw function reverts and users cannot withdraw their tokens.
Submitted by cccz, also found by TrungOre, wuwe1, reassor, 0xBug, georgypetrov, 0xDjango, scaraven, horsefacts, berndartmueller, CertoraInc, rayn, m9800, pedroais, and VAD37
In the \_withdraw function of the StakedCitadel contract, the setupVesting function of vesting is called, while in the StakedCitadelVester contract, the function name is vest, which will cause the _withdraw function to fail, so that the user cannot withdraw the tokens.
IVesting(vesting).setupVesting(msg.sender, _amount, block.timestamp);
token.safeTransfer(vesting, _amount);
...
function vest(
address recipient,
uint256 _amount,
uint256 _unlockBegin
) external {
require(msg.sender == vault, "StakedCitadelVester: only xCTDL vault");
require(_amount > 0, "StakedCitadelVester: cannot vest 0");
vesting[recipient].lockedAmounts =
vesting[recipient].lockedAmounts +
_amount;
vesting[recipient].unlockBegin = _unlockBegin;
vesting[recipient].unlockEnd = _unlockBegin + vestingDuration;
emit Vest(
recipient,
vesting[recipient].lockedAmounts,
_unlockBegin,
vesting[recipient].unlockEnd
);
}
Proof of Concept
https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/StakedCitadel.sol#L830
Recommended Mitigation Steps
Use the correct function name
interface IVesting {
function vest(
address recipient,
uint256 _amount,
uint256 _unlockBegin
) external;
}
...
IVesting(vesting).vest(msg.sender, _amount, block.timestamp);
token.safeTransfer(vesting, _amount);
dapp-whisperer (BadgerDAO) confirmed and resolved
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 interface used by StakedCitadel declares a function name that does not match the actual vesting contract's function, so the call reverts.
Impact
Users cannot withdraw their tokens because the withdraw function always fails.
What the attacker needed
None
The fix
The interface and call should use the correct function name, vest, instead of setupVesting; the report says this was confirmed and resolved.
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 is code on a blockchain. One contract tried to call a function by the wrong name, so the call always fails. That means a user action that depends on it, like withdrawing tokens, cannot complete.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.