Tokens can be burned with no access control
The Vault contract's `utilize()` function lacks a check that the `controller` address is non-zero, and if both `keeper` and `controller` are left at their default zero addresses, any address can call `utilize()` to burn the vault's available funds by sending them to the zero address. A user with no debt could lose their entire underlying token balance.
Originally disclosed on Code4rena
Submitted by sirhashalot
The Vault.sol contract has two address state variables, the keeper variable and the controller variable, which are both permitted to be the zero address. If both variables are zero simultaneously, any address can burn the available funds (available funds = balance - totalDebt) by sending these tokens to the zero address with the unprotected utilitize() function. If a user has no totalDebt, the user can lose their entire underlying token balance because of this.
Proof of Concept
The problematic utilize() function is found here. To see how the two preconditions can occur:
- The keeper state variable is only changed by the
setKeeper()function found here. If this function is not called, the keeper variable will retain the default value of address(0), which bypasses the only access control for the utilize function. - There is a comment here on line 69 stating the controller state variable can be zero. There is no zero address check for the controller state variable in the Vault constructor.
If both address variables are left at their defaults of address(0), then the safeTransfer() call on line 348 would send the tokens to address(0).
Recommended Mitigation Steps
Add the following line to the very beginning of the utilize() function: require(address(controller) != address(0))
This check is already found in many other functions in Vault.sol, including the _unutilize() function.
oishun1112 (Insure) confirmed and resolved:
https://github.com/InsureDAO/pool-contracts/blob/audit/code4rena/contracts/Vault.sol#L382
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
Likely the `utilize()` function only checks that the caller is the `keeper`, but does not check that the `controller` address is non-zero, and the constructor does not enforce a non-zero `controller`.
Impact
Any address could burn the vault's available funds, causing users with no debt to lose their entire underlying token balance.
What the attacker needed
Keeper and controller both left as zero address; no access control on utilize()
The fix
Add a check at the start of `utilize()` that the `controller` address is not zero, as is already done in other functions.
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 two special addresses that control who can call a function. If those addresses are never set, they stay as the zero address, which means anyone can call the function. The function then sends the contract's tokens to the zero address, which is like a black hole, so the tokens are lost forever.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.