Unable to withdraw Kerosene from vaultmanagerv2::withdraw as it expects a vault.oracle() method which is missing in Kerosene vaults
The withdraw function in VaultManagerV2 calls an oracle method on the vault contract, but Kerosene vaults do not implement this method, causing any Kerosene withdrawal to revert. As a result, users cannot withdraw their deposited Kerosene, and it remains stuck in the contract.
Circolors Follow with dinkras, ahmedaghadi and 39 others
Originally disclosed on Code4rena
Submitted by Circolors, also found by dinkras, ahmedaghadi, 0x175, Evo, 0xfox, d3e4, Al-Qa-qa, 0xlemon, Mahmud, Honour, sashik_eth, SBSecurity, amaron, TheSchnilch, Infect3d, ducanh2706, Limbooo, 3th, 0xShitgem, ke1caM, ljj, bhilare_, iamandreiski, Josh4324 (1, 2), 0xSecuri, bbl4de, Aamir, btk, alix40, 0xnilay, steadyman, shaflow2, cinderblock, AlexCzm, y4y, Egis_Security, web3km, 0xAlix2 (1, 2), 0x486776, itsabinashb, carrotsmuggler, dimulski, and 4rdiii
VaultManagerV2 has one withdraw function responsible for withdrawing both exogenous collateral (weth/wsteth) and endogenous collateral (Kerosene). However, the function expects the vault passed as an argument to have an oracle method. This is the case for Vault contracts, but not the case for the BoundedKerosineVault or UnboundedKerosineVault contracts. This means that whenever a user attempts to withdraw Kerosene deposited into the contract the call will revert, meaning the Kerosene remains stuck in the contract permanently.
Proof of Concept
Add the following test to v2.t.sol to highlight this:
function testCannotWithdrawKero() public {
// Set up alice
licenseVaultManager();
address alice = makeAddr("alice");
uint aliceTokenId = sendNote(alice);
sendKerosene(alice, 10_000 ether);
// Alice deposits kerosene into the protocol
vm.startPrank(alice);
contracts.vaultManager.addKerosene(aliceTokenId, address(contracts.unboundedKerosineVault));
Kerosine(MAINNET_KEROSENE).approve(address(contracts.vaultManager), 10_000 ether);
contracts.vaultManager.deposit(aliceTokenId, address(contracts.unboundedKerosineVault), 10_000 ether);
assertEq(ERC20(MAINNET_KEROSENE).balanceOf(alice), 0);
vm.roll(block.number + 42);
// Alice attempts to withdraw her kerosene but the tx reverts
contracts.vaultManager.withdraw(aliceTokenId, address(contracts.unboundedKerosineVault), 10_000 ether, alice);
}
The test reverts with the following stack traces:
├─ [9243] VaultManagerV2::withdraw(645, UnboundedKerosineVault: [0x416C42991d05b31E9A6dC209e91AD22b79D87Ae6], 10000000000000000000000 [1e22], alice: [0x328809Bc894f92807417D2dAD6b7C998c1aFdac6])
│ ├─ [558] 0xDc400bBe0B8B79C07A962EA99a642F5819e3b712::ownerOf(645) [staticcall]
│ │ └─ ← [Return] alice: [0x328809Bc894f92807417D2dAD6b7C998c1aFdac6]
│ ├─ [2623] 0x305B58c5F6B5b6606fb13edD11FbDD5e532d5A26::mintedDyad(VaultManagerV2: [0xA8452Ec99ce0C64f20701dB7dD3abDb607c00496], 645) [staticcall]
│ │ └─ ← [Return] 0
│ ├─ [261] UnboundedKerosineVault::asset() [staticcall]
│ │ └─ ← [Return] 0xf3768D6e78E65FC64b8F12ffc824452130BD5394
│ ├─ [262] 0xf3768D6e78E65FC64b8F12ffc824452130BD5394::decimals() [staticcall]
│ │ └─ ← [Return] 18
│ ├─ [214] UnboundedKerosineVault::oracle() [staticcall]
│ │ └─ ← [Revert] EvmError: Revert
│ └─ ← [Revert] EvmError: Revert
Recommended Mitigation
Given that the value of exogenous and endogenous collateral is calculated differently it is necessary to handle withdrawal of exogenous collateral and Kerosene differently. It would avoid added complexity to the function logic to have two different withdraw and withdrawKerosene functions.
shafu0x (DYAD) confirmed and commented:
Good find. This is correct.
Note: For full discussion, see here.
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 withdraw function assumes every vault implements an oracle() method, but Kerosene vaults do not, so the call reverts.
Impact
Users cannot withdraw their Kerosene, so it remains permanently stuck in the contract.
What the attacker needed
A user with a license and Kerosene tokens; Kerosene deposited into the protocol
The fix
The withdrawal logic should be split into separate functions for exogenous collateral and Kerosene, so that Kerosene withdrawals do not call oracle().
How it was found
- Set up a user with a license and Kerosene tokens.
- The user adds the Kerosene vault and deposits Kerosene into the protocol.
- The user attempts to withdraw the deposited Kerosene.
- The transaction reverts because the vault lacks an oracle() method.
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.
In this smart contract system, users can deposit different types of tokens as collateral. When they try to take back a special token called Kerosene, the withdrawal function asks the token's vault for an 'oracle' (a price feed), but the Kerosene vault doesn't have one. Because of this missing piece, the withdrawal always fails, and the Kerosene is locked forever.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.