Anyone can reset fees to 0 value when Vault is deployed
The changeFees function in the Vault contract does not check whether a fee change was actually proposed, so anyone can call it after the quit period and set fees to zero. This stops the protocol from collecting fees.
rvierdiiev Follow with immeas, hansfriese and 9 others
Originally disclosed on Code4rena
Submitted by rvierdiiev, also found by immeas, hansfriese, bin2chen, Lirios, ayeslick, jasonxiale, critical-or-high, mookimgo, Ruhum, hashminer0725, and hashminer0725
Anyone can reset fees to 0 value when Vault is deployed. As result protocol will stop collecting fees.
Proof of Concept
Anyone can call changeFees function in order to change fees variable to proposedFees.
https://github.com/code-423n4/2023-01-popcorn/blob/main/src/vault/Vault.sol#L540-L546
function changeFees() external {
if (block.timestamp < proposedFeeTime + quitPeriod)
revert NotPassedQuitPeriod(quitPeriod);
emit ChangedFees(fees, proposedFees);
fees = proposedFees;
}
There is a check that should not allow anyone to call function before quitPeriod has passed after fees changing was proposed.
However function doesn’t check that proposedFeeTime is not 0, so that means that after Vault has deployed, anyone can call this function and the check will pass.
That means that fees will be set to the proposedFees, which is 0.
As result protocol will stop collecting fees.
Use this test inside Vault.t.sol. Here you can see that no one proposed fee changing, but it was changed and set fees to 0.
function test__changeFees() public {
VaultFees memory newVaultFees = VaultFees({ deposit: 0, withdrawal: 0, management: 0, performance: 0 });
//noone proposed
//vault.proposeFees(newVaultFees);
vm.warp(block.timestamp + 3 days);
vm.expectEmit(false, false, false, true, address(vault));
emit ChangedFees(VaultFees({ deposit: 0, withdrawal: 0, management: 0, performance: 0 }), newVaultFees);
vault.changeFees();
(uint256 deposit, uint256 withdrawal, uint256 management, uint256 performance) = vault.fees();
assertEq(deposit, 0);
assertEq(withdrawal, 0);
assertEq(management, 0);
assertEq(performance, 0);
}
Tools Used
VS Code
Recommended Mitigation Steps
function changeFees() external {
if (proposedFeeTime == 0 || block.timestamp < proposedFeeTime + quitPeriod)
revert NotPassedQuitPeriod(quitPeriod);
emit ChangedFees(fees, proposedFees);
fees = proposedFees;
}
RedVeil (Popcorn) confirmed, but disagreed with severity
LSDan (judge) decreased severity to Medium
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 changeFees function lacks a check that proposedFeeTime is non-zero, allowing it to be called before any fee change is proposed.
Impact
The protocol stops collecting fees because all fees are set to zero.
What the attacker needed
Vault is deployed; quitPeriod has passed
The fix
Add a check that proposedFeeTime is not zero before allowing changeFees to proceed.
How it was found
- Deploy the Vault contract.
- Wait for the quit period to pass.
- Call changeFees without any prior proposal.
- Fees are set to zero.
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 a program on a blockchain. This vault contract lets someone change fees, but it forgot to check that a fee change was actually proposed first. Because of that, anyone can call the change function and set all fees to zero, so the protocol stops earning money.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.