Security model and known limitations
ZK-Sniper is not deployed on any network and has had no external audit. It relies on a proof system and a generated verifier that zk-pad did not write. Do not put in more than you can afford to lose when a deployment appears, and read Risks.
This page is the player-facing summary. The developer-facing threat table, with the mitigation for
each threat, is the ZK-Sniper section of docs/THREAT_MODEL.md in the repository (section 3.6).
Before you put money in, read Economics and fairness (the numbers) and
House rounds (who may host a round). The limitations below are
accepted properties of the design: they are not fixed, the contract does not mitigate them, and
some cannot be fixed without knowing who the players are.
What the design guarantees
These follow from the contract and the circuit. They do not depend on anyone's good behaviour, other than the proof system being sound and zero-knowledge.
| Property | Why it holds |
|---|---|
| A hit or miss claim cannot be faked. The hider cannot call a hit a miss, and nobody can call a miss a hit. | answerShot checks an UltraHonk proof against [positionHash, x, y, isHit]. The proof binds the claimed result to the committed square. Any verifier failure is reported as InvalidProof |
| The hider cannot change their square. | The square is committed with Poseidon; a different square would need a hash collision |
| The hider cannot commit to a square that does not exist. | The circuit asserts both coordinates are below 8 |
| Proofs cannot be replayed. Not on another square, another round, or another shot at the same square. | Public inputs are rebuilt from the round's commitment and the named pending square on every answer. A square can be shot once, and a commitment can be used by one round only |
| Answers are not tied to the caller. Anyone can submit the proof; a stranger cannot change the outcome. | The proof, not msg.sender, authorizes |
| Published proofs do not reveal the square. Answering misses gives away only that those squares are not the hider's. | The verifier is the zero-knowledge flavour of UltraHonk (bb -t evm): blinded commitments and randomized proofs. The earlier non-ZK build did leak the square; see below |
| Money is conserved. Every wei in the contract is a live pool or a deferred credit. | totalEscrowed is updated with every transfer, including shot refunds; settlement zeroes the pool before paying |
| A receiver cannot block a round. Not a winner, not the hider, not the treasury, not a refund recipient. | Pushes use a fixed gas allowance, and a failure is credited for withdraw |
| No reentrancy through payouts. | Every function that moves funds or round state is nonReentrant, and settlement follows checks, effects, interactions. The owner functions and ownership transfer are deliberately not guarded: they move no funds, and a payout receiver gets only 50,000 gas, so it cannot act as the owner |
| Exits always work. Answering, claiming a timeout, starting and finishing an extraction, and withdrawing work while the contract is paused, and whatever the creation gate says. | Pause is applied to createRound, fireShot and sponsorRound only. The creation gate (openCreation, approvedHider) is read by createRound only. See the pause caveat under admin powers |
| Admin cannot touch funds, the verifier, a running clock or the existing rounds' rules. | The windows are copied into each round at creation. See Admin powers. Ownership cannot be renounced |
Who is trusted for what
| Party | Trusted for | Not trusted for |
|---|---|---|
| The contract owner | Setting the treasury, base-fee bounds and the two windows for new rounds, choosing who may host rounds (the creation gate), and pausing entries. Not pausing in order to remove snipers' last shots (see below) | Moving any pool or credit, changing the verifier, settling a round, changing a running round, upgrading the contract |
| The proof system (UltraHonk, Barretenberg, the public CRS, the generated verifier) | Soundness (no proof for a false statement) and zero-knowledge (proofs do not leak the square) | Nothing else. A soundness bug would let a hider fake answers; a privacy bug would let anybody read the square from calldata |
| The hider | Nothing. The hider cannot cheat the protocol directly, but can cheat snipers through a second address; see the limitation below. In House rounds, the platform's policy not to do so, which the chain cannot check | |
| A sniper | Nothing | |
| The treasury | Receiving the rake | Blocking settlement (a failed payout is credited) |
| The responder operator (the default choice for community hiders, and always the answerer in House rounds) | Keeping the 64 proofs secret, keeping its gas wallets funded, staying up (two redundant instances), and submitting proofs within seconds when a shot is pending | Moving funds. It learns the hider's square, though, and an outage of about 2 minutes lets a sniper claim the pool |
| The hider's browser (if the hider chooses "This browser") | Staying open and awake, holding the session key, and holding the proofs on the device | Moving collateral: the session key can only send answers |
| The chain (BSC validators, your RPC) | Including your transactions before the deadline |
The proof system had a privacy hole, and why it is fixed
The first version of this repository used the cheaper non-ZK verifier flavour and documented that no practical recovery of the hidden square was known. An adversarial review showed otherwise and two independent reviewers reproduced it: non-ZK proofs are deterministic with unblinded commitments, so the difference of the commitments of two proofs cancels the salt and leaves a quantity that depends only on public values and on the hidden square. After two answered misses anyone could test all 64 squares offline. The shipped verifier is now the ZK flavour. The mechanism, the sizes and the gas cost are on the circuit reference.
Two things remain true. The ZK flavour has the same lack of external review as everything else here, and the responder (below) still learns the square by design.
Known limitations
The hider shooting their own round
The contract stops the hider's own address from calling fireShot. It cannot stop the hider
from shooting through a second wallet, and it cannot stop the hider sponsoring the round. The chain
sees only addresses; nothing on chain ties an address to a person. This is an accepted property
of a game with no identity, not a bug waiting for a patch, and it lets a hider collect real
snipers' fees. Snipers in user-created (community) rounds are exposed to it. The two variants
cost the hider the same amount, 0.1 x (C + F) plus gas, where C is the collateral and F the
fee of the second wallet's shot: 0.065 BNB at C = 0.64 BNB and F = 0.01 BNB. The numbers
are on the economics page.
- The timeout void (sybil timeout order). The second wallet parks a shot at a square the hider knows is empty and never answers it. Every shot has the same answer window, so a shot fired earlier always expires earlier. A real sniper later fires the hider's real square; the hider declines to answer; the parked shot's deadline passes; the second wallet claims the timeout. The round ends in the hider's favour, the real sniper's shot is void before its own deadline, and the hider keeps 90% of the whole pool, real snipers' fees included. With the 2-minute default window the wait for the parked shot to expire is about 2 minutes instead of 27, and the cost to the cheater (the 10% rake) is unchanged.
- The self-hit exit. While the hider's own square has not been shot, the second wallet fires at it and the hider answers it as a hit. The round ends at once, with no extraction countdown, and the hider's side keeps 90% of the pool. This means the countdown is not a real risk to a hider willing to do this.
- Wash shots. Fire at squares the hider knows are empty and answer with miss proofs. This moves the price up the curve and makes the pool look more active than it is. The cost of faking activity is about 10% of the faked fees plus gas.
- Bait. Sponsor the round to inflate the visible pool. An escape returns the sponsorship less 10%.
What changed with concurrent shots: a second wallet can no longer hold the only slot through an extraction countdown while real snipers are locked out, and a hider cannot escape risk-free behind a parked shot, because an escape needs every pending shot answered or timed out. Neither variant above needs the countdown.
Why the contract does not fix it. Any rule that tells the hider's shot from a real sniper's needs to know who the hider is, and a second address costs nothing. Paying the earliest expired shot, the latest one, only after every shot has expired, or splitting the pool among them can each be beaten by a hider who places shots before or after the real one (a split by flooding squares). A hider bond that is burned on a timeout would make the timeout void expensive (it would need a bond of roughly 1.5 to 2 times the collateral to cost the cheater clearly more than the 10% rake it pays today), but it would not close the self-hit exit, because a bond is refunded when the hider is hit. That design is deferred, not built; see House rounds.
What the launch model does about it. Rounds are meant to be hosted by platform-approved addresses (House rounds). That changes who the hider is. It does not make the limitation go away: the chain cannot prove that a House hider owns no shooter address, so for a House round you are relying on the platform's policy and not on the contract. Community rounds (possible only if the owner opens creation) are lower trust and are labelled as such in the app.
Until then, treat any pending shot that is older than yours as a risk to your own: check
getRound(...).pendingBitmap and getShot before you fire, and weigh the odds accordingly. The
app's "read before you pay" block says this before you pay. See
Economics and fairness.
What this means for snipers: the pool size and the number of shots taken say nothing reliable about how many other snipers are playing. The price of the next shot and the squares still unguessed are arithmetic you can check yourself. Do not treat "lots of activity" as a signal.
The burst sweep
Anyone can fire every unshot square back to back and so always hold the winning shot, by a hit or by timeout. At the 10% rake a sweep of a fresh round clears only about 0.5% on roughly 8.5 times the collateral in capital, before gas of 64 transactions (the margin grows as the board fills: 9.3% after 32 shots, 46.0% after 60; the table is on the economics page), and a bot needs no knowledge of the square. It works on House rounds as well; the hider loses the whole collateral of a swept round. It also hands the answerer a burst of up to 63 pending shots at once (see Liveness). This is accepted, not mitigated.
Race between expired shots
When more than one pending shot is past its deadline, the first claimTimeout caller decides
which expired sniper is paid. The loser has no claim, and the contract does not rank expired shots.
Expired snipers should claim in the first block they can; a bot that watches deadlines does better
than a person. This is accepted.
What you can read from the chain after a round ends
Settlement deletes the stored record of every voided square, so after a round ends getShot shows a
non-zero sniper for the winning square only. A proven miss clears its own record. To find the winner
read the RoundHit or RoundTimedOut event. Do not treat any other non-zero record as a live shot;
a square is pending only if its bit is set in pendingBitmap.
The responder is a trusted party
Answers have to arrive in seconds, so most hiders cannot answer for themselves: a hider who sleeps, travels or closes a laptop would lose by timeout. The zk-pad responder is therefore the default and recommended answerer for community hiders, and the only answerer of House rounds. To answer instantly while the hider is away it holds all 64 proofs, including the one that says where the square is. This is no longer a niche opt-in: it is the main path, and its costs are the main costs of the game. They fall into three groups.
Privacy. A malicious or breached operator can shoot the hider's square from another address, or tell someone who will, and the hider loses the pool. The staging flow keeps proofs on two instances (the primary and its backup), which means more copies held by the same operator, not fewer. Because the operator holds the hit square of every round it serves, one compromise exposes all of them. The responder cannot take funds directly and cannot make the hider lose by lying: a wrong proof is rejected on chain. The contract cannot prevent the privacy loss. The create-round flow says it before the choice and again in the review. This is the same privacy cost the old opt-in carried; it is now the default recommendation, and the speed was bought with it. The non-custodial alternative is This browser, with the limits of a browser tab (below).
Availability. If the responder is down for the whole answer window (267 blocks, about 2 minutes,
by default), a sniper who fired during the outage can claim the pool. The hider, not the sniper, bears
that. A shorter window also means an outage does not have to be long: one of d minutes exposes
max(0, d - 2) minutes, and a human cannot page, log in and restart inside 2 minutes, so recovery has to
be automatic. Failover is built in rather than hoped for:
- Two instances of the same image run on different infrastructure, ideally in different regions and on different RPC providers. The primary answers at once. The backup waits a short delay (1.5 s by default), checks the chain, and answers only squares nobody has answered yet.
- Separate sender keys per instance and a pool of keys per instance, so a stuck nonce on one key never blocks another, and a burst is spread over several keys. Each key's in-flight transactions are capped, since public nodes hold only a limited number of pending transactions per account.
- A fast feed (a WebSocket subscription with a 250 ms polling fallback and a log cursor that survives restarts) and a stuck-transaction timer of 1.5 s with a gas-price bump.
- A public health endpoint,
GET /v1/sniper/health, with readiness, feed state, sender balances, peer state and answer latency over the last hour. It never returns proofs, squares or round lists. The operator must alert on it (not ok for 30 s, a transaction over 10 s, a low sender wallet, the peer down for 30 s, the feed on polling for 5 minutes, live rounds with a stale head) and watch it from a third location. Senders should hold enough for at least 200 answers, and at most one of the two instances should be deployed or restarted at a time.
What this does not cover: a bug that stops both instances (shared code), a poisoned store, and a compromised operator. A third independent implementation would be the next step; it is not built. The cost to a bot is small, which is why this matters: a probe costs one base fee, a win pays about 58.5 base fees, and the endpoint above is as readable by a bot as by an operator. The arithmetic is under the first-shot-timeout bot. There is no on-chain circuit breaker: pausing is a manual, entry-only owner power, and automating it is a security trade-off that is not built. The web app disables "Shoot" on a round whose responder reports unhealthy, which only helps honest users.
Its gas has a budget, and the budget is part of the deal. Each answer costs the responder about 2.4 million gas and pays it nothing, so an attacker could otherwise create a round, fire shots at it and drain the responder wallet at several times the attacker's own cost (the review estimated about 5x at 0.05 gwei and 13x at 1 gwei). The relayer therefore meters its spend, with the checks moved to the moment a round is admitted (staging) instead of refusing answers mid-round, because a refusal in the middle of a round turns into a free timeout for whoever caused it:
- at most 63 miss answers per round over its life (it was 8; with automatic answering that meant shot 9 onward silently timed out);
- the round's cheapest shot (
baseFee) must pay for one answer (counted as 2.5M gas) within 5% of the fee, priced at the higher of the current gas price and a floor (0.2 gwei by default), which is below the 10% rake, so making the responder spend X costs whoever funds the round at least X. The check runs at staging when the client declares its base fee and always again when the round is created; a round that fails it is not armed; - admission also reserves the worst case (64 answers at that price, 0.032 BNB at the floor) per round against a per-hider budget (0.1 BNB by default) and an overall budget (1 BNB by default), a minimum collateral of 0.064 BNB, a staging wallet that holds that much, and a dedicated responder key (required) so a drained responder never starves the relayer's own claims. Only an empty responder wallet and an emergency brake (ten times the overall budget spent in one window) refuse an answer in the middle of a round;
- House rounds are exempt from these checks: a refused answer on the House's own round would be a House loss, and the check exists to stop strangers spending the operator's gas.
What this means for a community hider: a thin round is refused or left unarmed and must use "This
browser", and an empty responder wallet stops answers. A fee reimbursement or an on-chain
answerer reward cannot be done in the relayer and would need a contract change; it is not built. The
limits are published by the service (GET /v1/sniper/config).
Capacity. Slots are limited (100 rounds by default, 10 per hider). An attacker with many funded addresses and locked collateral can fill them for as long as the rounds stay idle; the relayer requires a minimum collateral, a balance in the staging wallet, a per-hider and a global cap on staged uploads that expire after 15 minutes, evicts the longest-idle round when the store is full and drops stale proofs, but it cannot make slots impossible to squat.
Pre-signature work. An upload that declares a proofsHash is rejected on its signature before
the roughly 1 MB body is hashed (about 3 ms against about 48 ms of CPU). Uploads from clients that do
not send it share a small global budget, and every request passes a global limit; the per-client
limit keys an IPv6 client by its /64. Put the relayer behind a proxy with its own flood protection.
Restarts. An answer that was broadcast before a restart is re-adopted by the new process so that its stuck-transaction monitor can bump it, and a failing RPC lookup is never read as "not found", so nothing is resent while the node cannot be asked. The log cursor survives a restart, so a shot fired while the responder was down is answered when it returns, if its window is still open. A revoke that completes while an upload is being verified cancels the upload.
The browser session key
If a hider picks "This browser", a throwaway session key is stored in the browser, next to the hider key, and funded with a small amount of BNB. It sends the answers while the tab is open. It cannot touch the collateral, because the proof, not the sender, authorizes an answer. Its risks:
- The tab must stay open and awake. Hidden tabs are throttled, phones suspend tabs, and no browser API guarantees a background tab. This mode is best effort while the tab is open, and the app shows "degraded" when the tab is hidden and "not answering" when it has not polled for 10 seconds.
- Storage. The key sits in
localStoragewith the hider key, so a cross-site-scripting bug on the site could read both, and anything with local access to the browser profile can. Keep the balance small and sweep it. - Funding. Recommended about 0.0115 BNB at 0.05 gwei (about 0.23 BNB at 1 gwei). If gas rises and the key can no longer pay, answers stop. The key is not reused across rounds.
- The key and the hider key are not sent anywhere. Creation is refused if the browser cannot store them.
Liveness is your problem
A shot must be answered within the answer window or the sniper takes the pool. That window is 267 blocks by default (about 2 minutes on BSC) and is fixed in the round at creation. Normal answers arrive in seconds, because answering is automatic; the window is the failure budget. The hider is exposed to all of:
- the answerer being down: the responder (see above), or a closed, locked or throttled browser tab;
- losing the hider key (nobody can then build new proofs; an answerer already holding the proofs can keep answering);
- the public proving parameters (the CRS) being unreachable when proofs are being built, which now happens before the round, so it blocks creation rather than a shot;
- running out of gas money in the answering wallet: each answer costs about 2.37 million gas;
- a congested or censoring RPC, or a validator that delays the answer transaction past the deadline. The deadline is checked against the block that includes the answer.
Several shots at once mean several clocks, and a large burst takes several blocks to answer: 63 pending misses need about 149 million gas, which is about 3 BSC blocks at the current 70 million gas limit, so "answered in the next block" is not true of a very large burst. The 67-block minimum window covers it.
The answer time is part of the design, not an accident, and it has a published ceiling that the code is tested against (a 95th percentile under 6 seconds and nothing over 10 seconds on a local chain; not measured on BSC): see Answer times.
The verifier call is expensive and can burn gas
Verifying a proof costs about 2.35 million gas. A tampered proof can reach a failing bn254
precompile and burn every unit of gas it is given; the contract reports that as InvalidProof
as well. Nobody loses game funds because of it, but a careless client can lose a lot of gas money.
Clients must simulate and cap the gas of answerShot; the SDK helper simulateSniperAnswer and
the relayer's responder do. See circuit reference.
Extraction is fast, and can still be delayed
The default extraction countdown is 100 blocks, which is about 45 seconds on BSC. Snipers get roughly that long to react after a hider announces the exit, and may fire until the last block of the countdown. The window is configurable by the owner between 20 and 28,800 blocks for new rounds; a running round keeps the value it was created with. If BSC block times change, the same block counts mean different times.
A shot fired in the last block of the countdown has a full answer window (about 2 minutes by default) and must be answered or timed out before the hider can escape. Normally it is answered within seconds, but an exit is not instantaneous, and a hit on that shot still wins.
Admin powers that can hurt you
The owner cannot take funds, but can change the rules for the next round:
- Answer window. The owner can set it as low as 67 blocks (about 30 seconds) for rounds
created after the change. The value is copied into your round when you create it, so it cannot
shrink under you. A hider should read
answerWindowBlocksfromgetRoundand keep an eye onAnswerWindowBlocksSet. At the minimum, a responder failover (about 2 to 4 seconds) still fits, but a person cannot react in time, and a hider on "This browser" has no margin. - Extraction window. Up to 28,800 blocks (about 3.6 hours) for rounds created after the change. A long window gives snipers a long time to hit an exiting hider.
- Treasury. Changes where the rake of every later settlement goes, including rounds already running.
- Creation gate. The owner decides which addresses may host rounds (
setApprovedHider) and whether anyone may (setOpenCreation). This is entry-only: it cannot touch a running round, its pool, its answers or its exits. It is how the platform keeps community rounds out; it is also a power to refuse a hider's next round. - Pause. Stops new rounds, new shots and sponsorships. It does not stop answers,
timeouts, extraction, escapes or withdrawals, so no round can be frozen by the owner. But it
is an admin-trust assumption for snipers: extraction countdowns keep running while
fireShotis rejected, so a pause right after a hider callsinitiateExtractionremoves the snipers' last-chance shots and the hider escapes without facing them. A pause is also normal incident response, so the chain cannot tell the two apart. The owner cannot take funds this way. The contract does not extend a countdown for a pause. - Single key. The owner is whoever the deployment hands it to. Ownership cannot be renounced, so the key must exist, but the rest of zk-pad is owned by a single account today (trust assumptions); nothing here assumes a multisig or timelock for the game.
Commitment squatting
A commitment can be used by only one round, ever, and it contains no hider address. Someone who
sees your pending createRound can copy the hash and create a round first, so yours reverts. You
lose only gas and retry with a fresh salt; the squatter's round is unanswerable (they do not know
the opening) and only locks their own collateral. It cannot be turned into a way to steal your
game, but it can annoy you. This is accepted and not fixed.
Economics are untested
The pricing is a mechanical formula, not a promise of fairness. With a uniformly random hidden square the expected return of a shot passes 1x from the fourth shot on, and a sniper who can afford to keep firing does better than a hider who stays. Read Economics and fairness for the numbers and for what a hider can do about it. Rounding is down everywhere; the rake is rounded down and the winner gets the rest, so payout plus rake equals the pool exactly.
No audit
No external auditor has reviewed the circuit, the generated verifier, the contract, the responder
service or the web app. The verifier is generated by Barretenberg's write_solidity_verifier
from a nightly build, which is pinned for reproducibility but is not a stable release. The
contract's tests include real proofs, a fuzz of single-byte proof changes and an invariant suite,
which lower risk but do not replace review.
The public proving parameters are not integrity-checked
Proving needs the public CRS, which @aztec/bb.js downloads from crs.aztec-cdn.foundation (falling
back to crs.aztec-labs.com) and caches in the browser. It is not checked against a known hash, and
the web app's content security policy allows any https connection. No secret leaves the browser and a
wrong CRS cannot produce a proof the on-chain verifier accepts, so the failure mode is availability:
a hider whose download fails or is poisoned cannot prove, and an unanswered shot times out against
them. The request also tells the CRS host that this address is about to prove. Prepare proofs while
the download works.
Version drift
The circuit, the verifier, the browser prover and the SDK must agree. A browser running a different
bb.js or circuit file than the one the verifier was built from, or using the wrong
verifierTarget, produces proofs the chain rejects, and the hider then loses the shot by timeout.
The mitigations are checks that run before a release and against a deployment (they catch drift;
they do not prove the code is correct):
- Exact pins.
nargoandbbversions are enforced bycircuits/zk_sniper/build.sh, which now fails on a mismatch unlessALLOW_TOOLCHAIN_DRIFT=1is set for a throwaway build.@aztec/bb.jsmust equal thebbversion. The Noir Poseidon dependency is pinned by commit independencies.pin.json, because the pinnednargoaccepts only a git tag. - Artifact check (
scripts/check-sniper-artifacts.mjs, run by preflight and the release check). The verifier's realVK_HASHconstant, its header, both proof fixtures and the verifier creation code must all equalcircuits/zk_sniper/target/vk_hash; the web circuit must equal the compiled circuit byte for byte, hold no developer path and embed the pinned Poseidon sources; the committed artifacts must equal a rebuild ofcontracts/verifiers; and, when the pinnednargoandbbare installed, the circuit and verification key are re-derived and compared. - Release check (
scripts/release-check.sh). The verifier, the committed artifacts, the circuit and the web circuit are guarded paths next to the contracts: unmerged or unpushed work touching them, or a dirty tree, fails the release stamp. - Fixture check at deployment. The deploy scripts verify the committed hit and miss proofs against the deployed verifier before they deploy the game.
- Bytecode drift check (
scripts/check-deployed-bytecode.mjs). The deployed game, verifier and linked library must equal the committed build. Immutables are not blanket-masked: the game'sverifiermust equalgames.zkSniperVerifier, the verifier'sLOG_N,VK_HASH,NUM_PUBLIC_INPUTSand MSM-size values must equal what the source says,VK_HASHmust equaltarget/vk_hashandgames.zkSniperVkHash, and the library address must equalgames.zkSniperVerifierLibrary.
See circuit reference. These are tripwires run by the team. Nothing here is audited and ZK-Sniper is not deployed.
Reporting a problem
Report vulnerabilities through the disclosure page. Please do not publish a break of a deployed game before the owner has had a chance to pause it.