69772 sc insight after a revert stakewithpermit might be prevented
Submitted on Mar 16th 2026 at 18:32:26 UTC by @max10afternoon for Audit Comp | Folks Finance: Staking Contracts
Report ID: #69772
Report Type: Smart Contract
Report severity: Insight
Target: https://github.com/Folks-Finance/folks-staking-contracts/blob/main/src/Staking.sol
Impacts:
Griefing (e.g. no profit motive for an attacker, but damage to the users or the protocol)
Description
Brief/Intro
After a revert, a second execution of stakeWithPermit can be prevented, as long as the second amount is larger (bypassing the try-catch protection).
Vulnerability Details
If a stakeWithPermit call reverts (if either of the slipage/time checks fails or if there is not enought caps for that particular staking period), the correspondant signature for the permit will still be valid, as the nonce has never been consumed (due to the overall revert). Meaning that the following stakeWithPermit call can be front ran with the permit from the previous call, even if the amounts are different. This will set the allowance to the value specified on the first permit (as the permit of the second transaction will fail due to nonce reuse), and it will cause the second transaction to revert, as long as the new amount is larger than the previous, as the allowance from the first permit will not be large enough for the second execution.
This might happen if, after a revert on the first stakeWithPermit call, the user decides to stake on another staking index with different parameters (which may imply a different stake amount decision) or if they simply decide to stake a larger amount on the same period.
A stakeWithPermit call might revert due to the following safety checks, while still having enough liquidity for a larger deposit:
Or if there are multiple staking periods available, also on:
In this last case a malicous user can stake dust amount of tokens, to force the check to fail, if the staking user is trying to consume the entire cap (this will be the scenario implemented in the coded PoC).
Deadline
Although there is a deadline parameter this is often set, in real and common implementations, to a large enough amount of time for this to be exploitable (eg. both uniswap and pancakeswap suggest deadlines of over 20 minutes, for similar functionalities. https://github.com/joshstevens19/simple-pancakeswap-sdk https://docs.uniswap.org/sdk/v3/guides/swaps/trading ). Meaning that it is feasible to grief the second execution of stakeWithPermit of a user that is manually interacting with the contract, on safe and often suggested values for this parameter.
Impact Details
Griefing: under the right conditions a user can prevent others from staking into the contract.
Proof of Concept
Add the following test case in the test file /test/Staking.t.sol:
Was this helpful?