Sapien

QuantstampFiles named in the report

Quantstamp reviewed Sapien on 30 Mar 2025: 14 findings, 0 critical; 9 marked fixed, 5 acknowledged.

No open critical findings
Open the reportOpen Sapien’s security record

Report hosted on certificate.quantstamp.com.

Trustblock does not review code.

Findings17

Statuses are the security firm’s own, from its report.

SeverityOpenAcknowledgedFixed
Critical000
High002
Medium024
Low033
HighMissing Balance Deduction in Unstaking Functions Allows Contract Drainage and Lock Period BypassFixed

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.

HighSignature Replay Attack Possible Between Stake, Unstake and Reward Functions Enabling Unauthorized Token ClaimsFixed

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

MediumBloom Filter Implementation Can Lead to False Positives Preventing Valid Reward ClaimsFixed

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

MediumEmergency Pause Functionality Not ImplementedFixed

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.

MediumGetting Max Staking Rewards Possible While Bypassing the Lockup PeriodsFixed

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.

MediumMissing Access Control on Token Release FunctionFixed

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.

LowMissing `_disableInitializers()` Call in the ConstructorFixed

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).

LowThe Received Allocations Might Not Be the Expected Ones.Fixed

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.

LowVesting Can Be Updated in Any Way Desired by the MultisigFixed

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.

Contracts in scope

No deployed address is recorded for this audit.

The report names a repository or files. Open the report to see its scope.

Repository and files the report names (3)

  • contracts/SapTestToken.sol
  • contracts/Rewards.sol
  • contracts/SapienStaking.sol

Part of Sapien’s security record

Sapien
Audits2 audits by 1 firmLast audit Jul 2025, by Quantstamp.
Critical findingsNo open critical findingsAcross 2 reports.
Open Sapien’s security record

Security firm

Quantstamp

240 projects reviewed · 338 reports · latest Nov 2026

See Quantstamp’s audits

Something 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