Vault#setController() owner of the Vault contracts can drain funds from the Vault
The Vault contract lets its owner point the controller at any address, and the migration and utilize functions then move all vault funds to that address. A malicious or compromised owner could therefore drain every token held by the vault.
Submitted by WatchPug
function setController(address _controller) public override onlyOwner {
require(_controller != address(0), "ERROR_ZERO_ADDRESS");
if (address(controller) != address(0)) {
controller.migrate(address(_controller));
controller = IController(_controller);
} else {
controller = IController(_controller);
}
emit ControllerSet(_controller);
}
The owner of the Vault contract can set an arbitrary address as the controller.
function utilize() external override returns (uint256 _amount) {
if (keeper != address(0)) {
require(msg.sender == keeper, "ERROR_NOT_KEEPER");
}
_amount = available(); //balance
if (_amount > 0) {
IERC20(token).safeTransfer(address(controller), _amount);
balance -= _amount;
controller.earn(address(token), _amount);
}
}
A malicious controller contract can transfer funds from the Vault to the attacker.
Proof of Concept
A malicious/compromised can:
-
Call
Vault#setController()and setcontrollerto a malicious contract;- L489 the old controller will transfer funds to the new, malicious controller.
-
Call
Vault#utilize()to deposit all the balance in the Vault contract into the malicious controller contract. -
Withdraw all the funds from the malicious controller contract.
Recommendation
Consider disallowing Vault#setController() to set a new address if a controller is existing, which terminates the possibility of migrating funds to a specified address provided by the owner. Or, putting a timelock to this function at least.
oishun1112 (Insure) acknowledged and disagreed with severity:
we assume ownership control is driven safely
Agree with warden that the privilege addresses should not be able to use approvals in a way that rugs users funds.
Based on the fact that we have seen many rug pulls in the space based on compromised “owner” keys, this is a valid attack path.
3 — High: Assets can be stolen/lost/compromised directly (or indirectly if there is a valid attack path that does not have hand-wavy hypotheticals).
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 owner can replace the controller at any time and the migration and utilize paths forward the vault's full balance to whatever address the owner names, with no timelock or restriction.
Impact
A malicious or compromised owner could steal all assets held by the vault; the project argued that ownership is assumed to be handled safely, but the judge accepted the attack path as high severity.
What the attacker needed
Owner key is malicious or compromised
The fix
The setController function should be disallowed from changing an existing controller, or at least be placed behind a timelock; the text does not say it was fixed.
How it was found
- Call the setController function and set the controller to a malicious contract, which receives the old controller's funds.
- Call the utilize function so the vault sends its whole balance to the malicious controller.
- Withdraw all the funds from the malicious controller contract.
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 vault is a smart contract that holds other people's tokens. Its owner can swap out the helper contract that manages those tokens, and the vault then sends its whole balance to that helper. If the owner is malicious or their key is stolen, they can point the helper at their own contract and walk away with the money.
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.