Quantstamp reviewed Sapien on 30 Mar 2025: 14 findings, 0 critical; 9 marked fixed, 5 acknowledged.
Report hosted on certificate.quantstamp.com.
Trustblock does not review code.
Statuses are the security firm’s own, from its report.
| Severity | Open | Acknowledged | Fixed |
|---|---|---|---|
| Critical | 0 | 0 | 0 |
| High | 0 | 0 | 2 |
| Medium | 0 | 2 | 4 |
| Low | 0 | 3 | 3 |
The `initiateUnstake()` and `unstake()` functions in the staking contract contain a critical vulnerability that allows users to drain the entire contract's token balance. When unstaking, the functions fail to deduct the staked amount from the user's balance in the `StakingInfo` struct. This means a user can: 1. Stake tokens once to create a valid staking position 2. Call `initiateUnstake()` to start the cooldown period 3. After the cooldown period, call `unstake()` multiple times with the same `orderId` to repeatedly withdraw tokens 4. Each withdrawal succeeds since the staking position remains active and the balance is never decremented As a result, a malicious user could drain all tokens from the contract by repeatedly calling `unstake()` with a single valid staking position, far exceeding their initial stake. This also tricks the reward mechanism off-chain, because the user `isActive` state variable is never updated, which signals that the user stake is still active, as well as having the original amount that was staked. In addition to the above, the lock duration is not checked during unstaking. Meaning that an attacker can game the reward system by staking for the maximum duration, and then unstake immediately.
A critical signature replay vulnerability exists in the `SapienRewards` and `SapienStaking` contracts. The `verifyOrder()` function in both contracts uses the same signature format and validation logic: ```solidity bytes32 messageHash = keccak256(abi.encodePacked(userWallet, rewardAmount, orderId)); ``` This allows signatures to be reused across different contract functions. Specifically: 1. A signature generated for staking tokens can be replayed to claim rewards in the `SapienRewards` contract 2. The same signature can also be replayed multiple times for staking and unstaking within `SapienStaking` This means an attacker who obtains a valid signature meant for staking could: - Use it to claim unauthorized rewards from `SapienRewards` - Drain tokens through repeated unstaking operations (see SAP-1) - Accidentally overwrite existing staking positions, causing themselves to lose their staked tokens The vulnerability allows: - Unauthorized claiming of rewards using stake signatures - Multiple drains of the same stake amount - Overwriting of legitimate user stakes
The `Rewards` contract uses a Bloom filter to track redeemed order IDs, but this implementation can lead to false positives that prevent users from claiming legitimate rewards. The issue arises from the limited size of the filter (256 bits) combined with multiple hash insertions per order. Each order sets 3 bits in the 256-bit filter. With users expected to claim up to 1000 rewards, this results in up to 3000 bits being set in a 256-bit space, leading to a high probability of collisions. **Impact** - As users claim more rewards, the Bloom filter becomes increasingly saturated - This increases the probability of hash collisions causing false positives - Valid orders may be incorrectly identified as already redeemed - Users will be unable to claim legitimate rewards once collisions occur
The `Rewards` contract inherits from `PausableUpgradeable` and includes pause checks in critical functions, but does not implement the actual `pause()` and `unpause()` functions. This means the contract cannot be paused in case of an emergency, despite functions being marked with `whenNotPaused` modifier.
The staking contract determines the multiplier a user gets depending on the staking amount and the lockup period. Where the lockup period is the most important factor since it determines the max multiplier. However, any of the unstake-related functions check if the lockup period has actually elapsed. There are two consequences: 1. A user can stake the needed amount for the max multiplier for 12 months to get the maximum rewards but only lock up the funds for two days after calling `initiateUnstake()` immediately after staking. 2. A user can mistakenly call `instantUnstake()` after the lockup period has ended which would cost an unnecessary penalty.
The `releaseTokens()` function in the `SapTestToken` contract lacks access control, allowing any address to call it. The intention is that it is only callable via the `SapienRewards.releaseTokenRewards()` function by the owner of that contract. However, a user is able to bypass this and instead directly call `releaseTokens()` on the `SapTestToken` contract.
To prevent initialization of the implementation contract, lock it down by calling `_disableInitializers()` in the constructor. Read more in the OpenZeppelin documentation for the [initializable contract](https://docs.openzeppelin.com/contracts/5.x/api/proxy#Initializable).
The `initialize()` function mints the amount of `_totalSupply`. However, there is no guarantee that it is the sum of all the expected allocations (1B tokens). If `_totalSupply` is less than the sum of all allocations, the vesting schedules will be created with amounts that can never be fully claimed. If `_totalSupply` is greater than 1B, the excess tokens will be minted to the Gnosis Safe but won't be part of any vesting schedule.
The `updateVestingSchedule()` function allows the Gnosis Safe to modify any parameter of a vesting schedule without restrictions. This includes: * Setting `amount` to 0 even after tokens have been released or reducing it below what has already been released creates an inconsistent state. * Setting the `duration` lower than the `cliff` period, which breaks the vesting logic. Users would have to wait for the cliff to be able to claim everything at once instead of periodically. * Modifying start time to a future date even after vesting has begun also creates an inconsistent state. * Changing the safe address mid-vesting could break integration with other contracts expecting specific safe addresses.
The report names a repository or files. Open the report to see its scope.
Repository and files the report names (3)
240 projects reviewed · 338 reports · latest Nov 2026
See Quantstamp’s auditsSomething wrong on this page? A missing report, a wrong date, a finding that was fixed since. Tell us and we check it against its source.
Tell us