Faulty Escrow config will lock up reward tokens in Staking contract
A vault owner can add a reward token with an escrow configuration that has a zero duration and a very low percentage, which passes without validation. When users later try to claim rewards, the escrow lock always reverts, so the reward tokens become permanently stuck in the staking contract.
Submitted by gjaldon, also found by Aymen0909, 0x52, hansfriese, KIntern_NA, and rvierdiiev
https://github.com/code-423n4/2023-01-popcorn/blob/main/src/vault/VaultController.sol#L443-L471
https://github.com/code-423n4/2023-01-popcorn/blob/main/src/utils/MultiRewardStaking.sol#L265-L270
https://github.com/code-423n4/2023-01-popcorn/blob/main/src/utils/MultiRewardStaking.sol#L178-L179
https://github.com/code-423n4/2023-01-popcorn/blob/main/src/utils/MultiRewardStaking.sol#L201
https://github.com/code-423n4/2023-01-popcorn/blob/main/src/utils/MultiRewardEscrow.sol#L97-L98
Impact
When a Vault owner creates/adds a reward token to the Staking contract with faulty escrow config parameters, the reward tokens sent to the Staking contract will forever be locked up. This can happen since there are no validity checks on the values of the Escrow config for the reward tokens when adding a reward token to the Staking contract via the VaultController.
Proof of Concept
Below are the steps to reproduce the issue:
-
Vault Creator/Owner adds a reward token to the Staking contract of a vault they own/created, passing Escrow configuration parameters of
useEscrow= true,escrowDuration= 0 andescrowPercentage= 1. This passes without issue since there are no validity checks for the Escrow config in the following lines:https://github.com/code-423n4/2023-01-popcorn/blob/main/src/vault/VaultController.sol#L443-L471
https://github.com/code-423n4/2023-01-popcorn/blob/main/src/utils/MultiRewardStaking.sol#L265-L271
-
This issue not noticeable until someone attempts to
claimRewardsfor that misconfigured rewardToken from the Staking contract. This will always revert for all users trying to claim rewards for the affected rewardToken since it always attempts to lock some funds in escrow:https://github.com/code-423n4/2023-01-popcorn/blob/main/src/utils/MultiRewardStaking.sol#L178-L180
And one of these checks in
Escrow.lockwill always fail sinceescrowDurationwas set to 0 andescrowPercentageis so low that rewards must be so high for the escrow amount to not be 0: https://github.com/code-423n4/2023-01-popcorn/blob/main/src/utils/MultiRewardEscrow.sol#L97-L98 -
Reward tokens for that misconfigured rewardToken contract will now forever be locked in the Staking contract leading to loss of funds vault creator/owner.
Tools Used
VS Code
Recommended Mitigation Steps
- Add validity checks for escrowDuration and escrowPercentage before these lines: https://github.com/code-423n4/2023-01-popcorn/blob/main/src/utils/MultiRewardStaking.sol#L265-L270
Make sure that escrowDuration is greater than 0 and that escrowPercentage is high enough that it won’t always trigger reverts when users claim rewards.
- If reward amounts are too small, the escrow amount will be 0 and that will revert the
claimRewardsso users will not be able to claim rewards. Maybe check if there are escrowed amounts greater than 0 and only callEscrow.lockif it is. That way, users with small rewards will always be able to claim funds. Note that only users with larger rewards at time of claiming will have funds escrowed for smaller escrow percentages.
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 lack of validation on escrow configuration parameters when adding a reward token, allowing a zero duration and a percentage so low that the escrow amount rounds to zero and causes a revert.
Impact
Reward tokens for the misconfigured reward token are permanently locked, causing a loss of funds for the vault creator or owner.
What the attacker needed
Vault owner adds reward token; faulty escrow config (duration 0, low percentage); users attempt to claim rewards
The fix
Add validity checks so that escrowDuration is greater than zero and escrowPercentage is high enough to avoid always reverting, and only call Escrow.lock when the escrow amount is greater than zero.
How it was found
- Vault owner adds a reward token to the staking contract with useEscrow true, escrowDuration 0, and escrowPercentage 1.
- The configuration is accepted because no validity checks exist.
- A user attempts to claim rewards for that reward token.
- The claim reverts because the escrow lock check fails due to the zero duration and tiny percentage.
- The reward tokens remain locked in the staking 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 owner sets up a reward token with escrow settings that are invalid, like a zero lock time. The system does not check these settings, so the setup succeeds. Later, when anyone tries to claim rewards, the escrow step fails and the tokens cannot be moved, leaving them stuck forever.
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.