Prime Number Staking Contract

QuillAuditsFiles named in the report

Audit · firm’s term: audit report

QuillAudits reviewed Prime Numbers Labs (Prime Number Staking Contract) on 7 Apr 2025: 7 findings, 0 critical; 5 marked fixed, 2 open.

No open critical findings
Open the reportOpen Prime Numbers Labs’s security record

Report hosted on quillaudits.com.

Trustblock does not review code.

Findings7

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

SeverityOpenAcknowledgedFixed
Critical000
High000
Medium002
Low203
MediumBypassing Withdrawal ApprovalFixed

The approveWithdrawRequest() function sets a boolean flag _canWithdraw[user] = true, allowing a user to withdraw funds. However, this flag is not time-bound or tied to the stake amount at the time of approval. An attacker can exploit this by getting approval for a small stake and delaying their actual withdrawal. Later, they can stake a large amount and withdraw without requiring further approval, thus bypassing the intended per-withdrawal approval mechanism. This behavior breaks the intended protocol security model, where every withdrawal should be ap proved based on the user's current stake and context

MediumUse of "transfer" opcode to send ETH can lockrewards and withdrawals if recipient is a contractFixed

In the PrimeStakedXDC contract, native XDC is sent to users during reward claims and withdrawals using Solidity’s .transfer function. This opcode only forwards 2300 gas, which is risky and outdated. This is dangerous for two reasons: - Gas costs of EVM instructions may change signifcantly during hard forks which may previously be assumed fxed gas costs. EIP 1884 as an example, broke several existing smart contracts due to a cost increase of the SLOAD instruction. - If the recipient is a contract or a multisig safe, with a “receive”/”fallback” function which requires >2300 gas, e.g. safes that execute extra logic in the “receive”/”fallback” function, the transfer function will always fail for them due to out of gas errors

LowAttacker can delay rewards of users by calling notifyRewardAmount with some WeisFixed

The notifyRewardAmount() function can be called by any address with no access control or minimum reward threshold. This enables a griefing attack where an adversary sends trivial reward amounts (e.g., 1 wei) repeatedly to reset the lastUpdateTime and extend periodFinish by the full rewardsDuration. As a result, rewardPerToken() accrual is disrupted, and stakers experience significant delays or denial of expected rewards. This attack does not incur meaningful cost for the attacker but can indefinitely block proper reward distribution for all users.

LowMissing State Tracking in contract for requestWithdraw and cancelWithdrawRequestsFixed

The requestWithdraw() and cancelWithdrawRequest() functions emit events to signal a user’s intent- to withdraw or cancel a withdrawal. However, these functions do not update any internal state to refect the user’s current withdrawal status. The actual logic that allows a user to withdraw is fully controlled by the owner via approveWith drawRequest(), which sets canWithdraw[user] = true. As a result, there’s no on-chain tracking of whether a user has an active withdrawal request or has canceled it; only off-chain listeners can infer that by watching events.

LownotifyRewardAmount() Does Not Track Rewards in contract StateFixed

The notifyRewardAmount() function allows the owner to deposit ETH (XDC) into the contract as rewards for stakers. While it emits a RewardAdded(reward) event, the function does not store the reward amount in state or update any cumulative reward tracking variable.<br>This means there’s no on-chain record of how much total reward has been added over time. The only way to trace this is through off-chain event logs, which can be incomplete or unreliable if logs are pruned, missed, or not indexed properly

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)

  • tracts/blob/main/contracts/PrimeStakedXDC.sol
  • contracts/PrimeStakedXDC.sol
  • PrimeStakedXDC.sol

Part of Prime Numbers Labs’s security record

Prime Numbers Labs
Audits1 audit by 1 firmLast audit Apr 2025, by QuillAudits.
Critical findingsNo open critical findingsIn 1 report.
Open Prime Numbers Labs’s security record

Security firm

QuillAudits

350 projects reviewed · 459 reports · latest Apr 2025

See QuillAudits’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