Skip to content
Smart contracts Write-up Advanced

Critical Security Assessment of Veilo Privacy Protocol Smart Contracts

The report claims that the Veilo privacy protocol's zero-knowledge circuits, verification keys and trusted setup are not public, so the on-chain verifier cannot be checked against the intended rules. It also says the swap route hash is not constrained by the proof, letting a relayer substitute a different route while keeping a valid proof.

Amir Mohseni Follow

Published on medium.com

Bug

Amir Mohseni, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 9 min read.

Context

Veilo is a privacy protocol on Solana. The target of this assessment is its on-chain privacy pool program, privacy_pool, together with the repository VeiloSolana/privacy-program. The program is deployed on mainnet at:

Text
[redacted]

The protocol relies on Zero-Knowledge proofs, specifically Groth16, to authorise operations such as withdrawals and swaps while keeping amounts and ownership private. The instructions examined in the report are withdraw, transact_swap and transact_reissue. The on-chain program verifies proofs against a verification key that is hardcoded in vk_constants.rs.

The assessment was prepared for the Veilo Bug Bounty Program (Superteam) and dated 16 August 2026. It is a static review of the source code and documentation, not a live exploitation exercise.

Setup

The work was carried out against the public repository and the official documentation. The report describes the analysis as static code review, documentation and planning for a local fork simulation. No mainnet transactions were executed, and no user funds were moved or put at risk.

Two preconditions shape everything that follows:

  1. The Circom circuits, the R1CS constraint files, the proving keys and the Multi-Party Computation (MPC) trusted setup transcript are not in the public repository. The project's AUDIT.md and repository structure are cited as the evidence for this.
  2. The on-chain program is upgradeable through a Squads v4 3-of-4 multisig wallet, with no timelock.

The report describes the first two findings as unconditional and the third as conditional on the integrity of the ZK circuits that are absent from the repository.

Finding it

The starting observation is that the protocol's security rests entirely on Groth16 proof verification, yet the artefacts needed to check what those proofs actually prove are missing. The on-chain verifier checks that a proof satisfies the R1CS constraints encoded in the hardcoded verification key. It has no notion of the business rules the circuit is supposed to enforce.

The rules that the circuit is meant to enforce, as stated in the report, are:

  • sumIns + publicAmount = sumOuts (balance conservation).
  • Proper nullifier and commitment management.

With the circuit absent, the public cannot verify three things: whether the circuit correctly enforces the protocol rules, whether the trusted setup was generated honestly, and whether the static verification key actually corresponds to the intended constraints. That gap is the first critical finding.

The second observation comes from the swap path. The SwapParams structure contains a field named swap_data_hash, described as the SHA-256 hash of the Jupiter swap route data. The official documentation states:

swap_data_hash is NOT constrained by the proof until the circuit and verification key are upgraded.

So the Jupiter route is not validated by the ZK circuit. The circuit only constrains min_amount_out and dest_amount, and the relayer supplies the actual route data at execution time. That is the second finding.

The third finding generalises the first: the Groth16 verifier in groth16.rs does not evaluate the business logic of the program, only the mathematical constraints of the R1CS. Without public circuits there is no guarantee that those constraints enforce correct nullifier consumption, correct Merkle tree inclusion proofs, or accurate accounting of input and output notes (amount, asset_id).

A fourth, lower-severity observation concerns governance: the upgrade authority can change program logic instantly, with no timelock to give users time to exit. The README.md also states the software is provided "as is" and warns against production use without auditing, which the report notes reinforces the criticality of the missing circuit components.

Exploitation

Step 1: Abuse the absent circuit to break value conservation

The report frames this as a scenario available to a malicious actor or an internal team member with access to the circuits:

  1. Modify the Circom circuit to violate the value conservation rule, for example by minting extra outputs.
  2. Generate a valid proof, valid mathematically against the altered circuit.
  3. Submit this proof to the live contract. The on-chain verifier, lacking context about the correct circuit logic, accepts the proof as valid.
  4. The contract releases funds to the attacker's address, draining the privacy pool.

No simulation is shown, because the circuits are not public. The report states the logical exploit is fully reproducible by the Veilo team if they provide the missing files.

Step 2: Replace the swap route while keeping the proof

Because swap_data_hash is not a public input to the proof, a malicious relayer or a front-running attacker can intercept a valid user transaction and substitute different swap_data while keeping the original ZK proof intact. The scenario in the report:

  1. The user generates a proof for swapping 1 SOL into a minimum of 200 USDC.
  2. The relayer submits the transaction but replaces the route with a path through a highly illiquid pool or a malicious pool the relayer controls.
  3. Since swap_data_hash is not part of the proof, the contract cannot verify the route's integrity.
  4. The swap executes via the malicious pool.

Two outcomes are described. In Case A the swap fails because slippage exceeds min_amount_out, and the user's funds are locked or lost through transaction reverts or state corruption. In Case B the pool is malicious and returns a tiny amount of USDC that barely meets min_amount_out, if the route is carefully crafted, effectively stealing the MEV or value from the user.

The proof-of-concept sketch in the report is:

JavaScript
const validProof = generateSwapProof({    destAmount: 200_000_000, // 200 USDC (decimals adjusted)    minAmountOut: 190_000_000});const maliciousSwapData = getMaliciousRoute();

It shows a proof generated for a destination amount of 200 USDC and a minimum out of 190 USDC, paired with a route obtained independently of that proof. The point is that nothing ties the two together.

Step 3: Craft a proof that passes verification but violates accounting

If the circuits are flawed or contain backdoors, an attacker can craft a proof that passes mathematical verification while violating the protocol's accounting rules. The report calls this a classic "verifier does not know what it is verifying" vulnerability. As with the first finding, no simulation is shown.

Step 4: Instant upgrade through the multisig

The program is upgradeable via a Squads v4 3-of-4 multisig with no timelock. The upgrade authority can therefore modify program logic instantly, which could freeze or drain user funds if the multisig holders are compromised or act maliciously. The report notes that a timelock, for example 48 to 72 hours, is standard practice in DeFi so that users can exit if a malicious upgrade is proposed.

Root cause

The root cause of the first and third findings is a design dependency: the protocol's invariants live entirely inside circuits that are not published, while the on-chain verifier only checks that a proof satisfies whatever constraints the hardcoded verification key encodes. The verifier has no way to know whether those constraints express value conservation, nullifier handling or note accounting. Publishing the verification key without the circuit, the R1CS and the trusted setup transcript leaves the binding between key and intended logic unverifiable.

The root cause of the second finding is an unconstrained input. swap_data_hash exists in SwapParams, but the documentation states it is not constrained by the proof until the circuit and verification key are upgraded. The circuit constrains only min_amount_out and dest_amount, so the route itself is supplied by the relayer at execution time and is not bound to the proof. Existing defences do not cover this: the proof is valid, and the contract has no independent way to check the route's integrity.

The governance observation has a simpler cause: the upgrade path through the Squads v4 3-of-4 multisig has no delay, so there is no window in which users can react to a proposed change.

Impact

For the absent-circuit findings, the impact is described as draining the privacy pool. The condition is access to the circuits: a malicious actor or an internal team member who can modify the circuit and generate a matching proof can have the contract release funds to an attacker address. The report notes that such a drain would not leave a trace on the traditional Solana execution logs, and calls this black-box reliance the most critical threat vector. The third finding is explicitly conditional on the circuits being flawed or containing backdoors.

For the swap finding, the affected party is the user whose transaction is intercepted, and the actor is a malicious relayer or a front-running attacker. The outcome depends on the substituted route: either the swap fails and funds are locked or lost through reverts or state corruption, or the route is crafted so the output barely meets min_amount_out and value is stolen. The report's summary table rates this High / Critical.

For the governance observation, the exposure is to all users of the pool if the multisig holders are compromised or act maliciously, since program logic can change instantly. The report's summary table rates this Medium.

The report's summary table records the findings as follows:

# Vulnerability Severity Status Action Required
1 Reliance on absent ZK circuits Critical Unconditional Immediate publication of circuits and re-do trusted setup
2 Unconstrained swap_data_hash High/Critical Unconditional Upgrade circuit to include route hash and redeploy VK
3 Value conservation violation via circuits Critical Conditional Third-party audit of circuits; make public
4 No timelock on upgrade authority Medium Observation Add a 48-hour timelock to the multisig upgrade process

Fix

The report recommends the following.

For the absent circuits:

  1. Publish all circuits, R1CS files and the trusted setup transcript in a dedicated public repository.
  2. Implement reproducible builds for the circuits so the verification key in the contract can be generated independently by the community.
  3. Re-do the trusted setup with a new multi-party ceremony involving prominent community members, given the lack of transparency.
  4. Add a mechanism to the contract or build process that verifies the deployed verification key corresponds to the correct circuit hash.

For the swap path:

  1. Add swap_data_hash as a public input to the ZK circuit.
  2. Deploy the updated verification key to the mainnet program.
  3. Until the circuit is upgraded, implement a hardcoded whitelist of trusted Jupiter quote APIs, or introduce a relayer-bond and slashing mechanism to disincentivise route manipulation.

For the circuit-dependent accounting risk:

  • Make the circuits and R1CS publicly available and have them audited by third-party firms, with Trail of Bits and Kudelski named as examples, before mainnet release.
  • Store a hash of the canonical circuit R1CS on chain. The report says the contract cannot verify this natively without off-chain support, but that it creates a binding commitment to the intended logic.

For governance:

  • Add a timelock, with 48 hours given as the figure in the summary table and 48 to 72 hours as the general practice, to the multisig upgrade process.

The report closes with four immediate remediation steps for Veilo: open source the circuits, re-do the trusted setup with community participation, patch the swap circuit to integrate swap_data_hash, and implement a timelock on the upgrade authority.

Variants to test

  • Other privacy pools with hardcoded verification keys. Check whether the circuit source, R1CS and trusted setup transcript are published alongside the key. A positive result is a deployed verifier whose key cannot be tied to any public circuit, which reproduces the black-box condition described here.
  • Other relayer-supplied parameters that are hashed but not constrained. Look for fields named like *_hash in instruction parameters and check whether they appear as public inputs in the proof. A positive result is a field the documentation or code admits is not yet constrained, as with swap_data_hash.
  • Swap and DEX-aggregator integrations in ZK systems. Test whether the route, pool or venue is bound to the proof or only the minimum output amount. A positive result is a transaction where substituting the route leaves the proof valid.
  • Upgrade authorities without a timelock. Enumerate programs whose upgrade authority is a multisig and check for a delay between proposal and execution. A positive result is an instant upgrade path on a program holding user funds.
  • Documentation that disclaims production readiness. Where a README states the software is provided "as is" and warns against production use without auditing, check whether the deployed program nonetheless holds funds. A positive result is a live deployment whose own documentation disclaims its readiness.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 25 min read.

What happened, in plain words

Veilo is a privacy protocol on Solana. Solana is a blockchain: a public ledger of transactions that anyone can read, run by many computers at once. A privacy protocol is a service built on top of a blockchain that tries to hide who sent what to whom, while still letting the blockchain confirm that the transfer is legitimate. Veilo does this with a privacy pool, which is a shared pot of money that many users pay into and later withdraw from, in a way designed to break the visible link between the deposit and the withdrawal.

The thing that was reviewed is Veilo's on-chain privacy pool program. A program on Solana is a piece of code that lives on the blockchain and runs when someone sends it an instruction. The program in question is called privacy_pool, and its source code is in a public GitHub repository called VeiloSolana/privacy-program. The live copy of the program on Solana's main network (mainnet, the real network where real money moves) has this address:

Text
[redacted]

That string is a program identifier. Think of it as the street address of the program on the blockchain: anyone can look it up and see the code that is deployed there.

The protocol relies on Zero-Knowledge proofs, specifically a scheme called Groth16, to authorise operations such as withdrawals and swaps while keeping amounts and ownership private. A Zero-Knowledge proof (ZK proof) is a way for one computer to convince another that a statement is true without revealing the information behind it. A useful everyday comparison: you can prove you are over 18 by showing a document that only says "over 18", without showing your date of birth or your name. The verifier learns one bit, "true", and nothing else. In Veilo, the statement being proven is roughly "I am allowed to take this money out of the pool, and the amounts add up", and the proof is supposed to show that without revealing which deposit the money came from.

The instructions examined in the report are withdraw, transact_swap and transact_reissue. An instruction is a single command sent to a blockchain program, like one line of a shopping order. withdraw takes money out of the pool. transact_swap exchanges one token for another inside the pool. transact_reissue is another operation the report names but does not describe in detail.

The on-chain program verifies proofs against a verification key that is hardcoded in vk_constants.rs. A verification key is the public half of the cryptographic setup: it is the small piece of data the verifier needs in order to check proofs. "Hardcoded" means it is written directly into the program's source as a fixed value, so it cannot be changed without deploying a new version of the program. vk_constants.rs is the file in the repository where that fixed value lives.

The assessment was prepared for the Veilo Bug Bounty Program (Superteam) and dated 16 August 2026. A bug bounty program is a scheme where a project offers a reward to people who find and report security problems in it, instead of those people using the problems for harm. Superteam is named as the organiser of this particular program. The work is a static review of the source code and documentation, not a live exploitation exercise. "Static review" means reading the code and the docs carefully, without running attacks against the live system.

Setup

The work was carried out against the public repository and the official documentation. The report describes the analysis as static code review, documentation and planning for a local fork simulation. A local fork simulation means making a private copy of the blockchain on your own computer, so you can try things out without touching the real network. No mainnet transactions were executed, and no user funds were moved or put at risk.

Two preconditions shape everything that follows:

  1. The Circom circuits, the R1CS constraint files, the proving keys and the Multi-Party Computation (MPC) trusted setup transcript are not in the public repository. The project's AUDIT.md and repository structure are cited as the evidence for this.
  2. The on-chain program is upgradeable through a Squads v4 3-of-4 multisig wallet, with no timelock.

Those two sentences are dense, so let us unpack them term by term.

A circuit, in this context, is the written description of the rule that a ZK proof is supposed to prove. Circom is the programming language used to write such circuits. If the proof is like a sealed envelope saying "this statement is true", the circuit is the statement itself. Without the circuit, you cannot check what the envelope is actually claiming.

R1CS constraint files are the compiled, machine-readable form of the circuit. "Constraints" here means mathematical equations that must hold. R1CS stands for Rank-1 Constraint System, which is a standard way of writing those equations down so a proving tool can work with them. Think of the circuit as the recipe and the R1CS file as the exact ingredient list the kitchen machine reads.

Proving keys are the secret-side material a user needs in order to produce a proof. The verification key is the public-side material a verifier needs to check one. They come as a pair.

A Multi-Party Computation (MPC) trusted setup is a ceremony in which several independent participants jointly generate the secret material behind the proving and verification keys, so that no single person ever knows the whole secret. "Trusted setup" is the honest name for a known awkwardness in some ZK systems: the setup produces secret values, and if one person kept a copy of those secrets, they could forge proofs. Splitting the generation across many parties is meant to make that impossible as long as at least one participant was honest. The transcript is the public record of that ceremony, which lets outsiders check it was run properly.

A multisig wallet is a wallet that requires several signatures to move money or make changes, instead of one. "3-of-4" means there are four key holders and any three of them together can approve an action. Squads v4 is the name of the multisig product used here. A timelock is a forced waiting period between approving a change and the change taking effect. Without one, an approved change happens immediately.

The report describes the first two findings as unconditional, meaning they can be argued from on-chain logic and code analysis alone, and the third as conditional on the integrity of the ZK circuits that are absent from the repository. "Unconditional" here means: you do not need to know whether the hidden circuits are good or bad. The problem exists either way. "Conditional" means: the problem only bites if the hidden circuits turn out to be flawed.

Finding it

The starting observation is that the protocol's security rests entirely on Groth16 proof verification, yet the artefacts needed to check what those proofs actually prove are missing. Groth16 is one specific, widely used ZK proof scheme. It is efficient, which is why blockchains like it, but it depends on a trusted setup as described above.

The on-chain verifier checks that a proof satisfies the R1CS constraints encoded in the hardcoded verification key. It has no notion of the business rules the circuit is supposed to enforce. This is the heart of the whole report, so it is worth a comparison. Imagine a nightclub with a door scanner. The scanner checks that the card in your hand is a valid card of the right shape and signature. It does not know, and cannot know, what rule the card was issued under. If the card issuer secretly started handing out cards to anyone, the scanner at the door would still happily beep green. The scanner verifies the card, not the policy. In Veilo, the on-chain verifier is the scanner, and the circuit is the policy.

The rules that the circuit is meant to enforce, as stated in the report, are:

  • sumIns + publicAmount = sumOuts (balance conservation).
  • Proper nullifier and commitment management.

Balance conservation is the rule that money is not created out of thin air. sumIns is the total of the amounts going in, publicAmount is an amount that is visible on chain, and sumOuts is the total of the amounts coming out. The equation says: everything that goes in plus whatever is publicly added must equal everything that comes out. If that equation holds, the pool cannot be drained by inventing money.

A commitment is a cryptographic fingerprint of a hidden value. You can publish the fingerprint without revealing the value, and later prove that a particular value matches a particular fingerprint. In a privacy pool, each deposit becomes a commitment, so the pool can track that a deposit exists without revealing whose it is. A nullifier is a one-time marker that stops the same deposit being spent twice. When you withdraw, you reveal a nullifier derived from your deposit; the program records it, and if the same nullifier appears again, the withdrawal is rejected. The comparison is a cloakroom ticket: the ticket proves you own a coat, and once it is handed in, it cannot be used again.

With the circuit absent, the public cannot verify three things: whether the circuit correctly enforces the protocol rules, whether the trusted setup was generated honestly, and whether the static verification key actually corresponds to the intended constraints. That gap is the first critical finding.

The second observation comes from the swap path. A swap is an exchange of one token for another. The SwapParams structure contains a field named swap_data_hash, described as the SHA-256 hash of the Jupiter swap route data. A structure, in programming, is a bundle of named fields grouped together, like a form with several boxes. A hash is a short fingerprint computed from a larger piece of data: change one character of the input and the fingerprint changes completely, and you cannot work backwards from the fingerprint to the input. SHA-256 is the specific hashing algorithm used here. Jupiter is a swap aggregator on Solana: a service that finds a route through various pools to get you the best exchange. A route is the specific path the swap takes, for example token A to token B through pool X, then B to token C through pool Y.

The official documentation states:

swap_data_hash is NOT constrained by the proof until the circuit and verification key are upgraded.

"Constrained by the proof" means the proof mathematically forces the value to be a particular thing. If a value is constrained, a user cannot swap in a different value without invalidating the proof. If it is not constrained, the value can be changed freely and the proof still checks out. The documentation is openly saying: the route fingerprint is not yet tied to the proof.

So the Jupiter route is not validated by the ZK circuit. The circuit only constrains min_amount_out and dest_amount, and the relayer supplies the actual route data at execution time. min_amount_out is the minimum amount of the output token the user will accept; if the swap would return less, it should fail. dest_amount is the intended destination amount. A relayer is an intermediary service that takes a user's signed transaction and submits it to the blockchain on their behalf, often because the user does not want to pay fees or reveal their own address. That is the second finding.

The third finding generalises the first: the Groth16 verifier in groth16.rs does not evaluate the business logic of the program, only the mathematical constraints of the R1CS. Without public circuits there is no guarantee that those constraints enforce correct nullifier consumption, correct Merkle tree inclusion proofs, or accurate accounting of input and output notes (amount, asset_id). A Merkle tree is a way of summarising a large list of items into one short fingerprint, such that you can later prove "my item is in this list" without showing the whole list. An inclusion proof is exactly that proof. A note, in privacy-pool terminology, is a record of value, like a banknote: it has an amount and an asset_id (which token it is).

A fourth, lower-severity observation concerns governance: the upgrade authority can change program logic instantly, with no timelock to give users time to exit. "Upgrade authority" is whoever holds the power to replace the program's code. The README.md also states the software is provided "as is" and warns against production use without auditing, which the report notes reinforces the criticality of the missing circuit components. A README is the front page of a code repository, where the authors explain what the project is and how to use it.

Exploitation

Step 1: Abuse the absent circuit to break value conservation

The report frames this as a scenario available to a malicious actor or an internal team member with access to the circuits:

  1. Modify the Circom circuit to violate the value conservation rule, for example by minting extra outputs.
  2. Generate a valid proof, valid mathematically against the altered circuit.
  3. Submit this proof to the live contract. The on-chain verifier, lacking context about the correct circuit logic, accepts the proof as valid.
  4. The contract releases funds to the attacker's address, draining the privacy pool.

In plain words: if you can edit the rulebook and nobody outside can read the rulebook, you can write a rule that says "outputs may be larger than inputs", produce a proof that honestly follows your edited rule, and the door scanner will beep green because it only checks that the proof matches the key, not what the rule says. "Minting extra outputs" means creating value that was never deposited.

No simulation is shown, because the circuits are not public. The report states the logical exploit is fully reproducible by the Veilo team if they provide the missing files. A proof of concept (PoC) is a small demonstration that a claimed problem is real. Here the author could not build one, because the missing files are exactly what a demonstration would need.

Step 2: Replace the swap route while keeping the proof

Because swap_data_hash is not a public input to the proof, a malicious relayer or a front-running attacker can intercept a valid user transaction and substitute different swap_data while keeping the original ZK proof intact. A public input is a value that the proof openly commits to: it is visible to the verifier and the proof is only valid for that exact value. Front-running means seeing someone else's pending transaction and getting your own transaction in ahead of it to profit from it.

The scenario in the report:

  1. The user generates a proof for swapping 1 SOL into a minimum of 200 USDC.
  2. The relayer submits the transaction but replaces the route with a path through a highly illiquid pool or a malicious pool the relayer controls.
  3. Since swap_data_hash is not part of the proof, the contract cannot verify the route's integrity.
  4. The swap executes via the malicious pool.

SOL and USDC are two tokens on Solana: SOL is the network's native token, USDC is a stablecoin pegged to the US dollar. An illiquid pool is one with very little money in it, so trading through it moves the price sharply against you.

Two outcomes are described. In Case A the swap fails because slippage exceeds min_amount_out, and the user's funds are locked or lost through transaction reverts or state corruption. Slippage is the difference between the price you expected and the price you actually got. A revert is a blockchain transaction that is cancelled partway through and undone. In Case B the pool is malicious and returns a tiny amount of USDC that barely meets min_amount_out, if the route is carefully crafted, effectively stealing the MEV or value from the user. MEV stands for maximal extractable value: the profit someone can make by choosing the order and content of transactions.

The proof-of-concept sketch in the report is:

JavaScript
const validProof = generateSwapProof({    destAmount: 200_000_000, // 200 USDC (decimals adjusted)    minAmountOut: 190_000_000});const maliciousSwapData = getMaliciousRoute();

Line by line, in plain words:

  • const validProof = generateSwapProof({ starts a new variable called validProof and fills it with the result of a function called generateSwapProof, which is given a settings object. A variable is a named box that holds a value. A function is a named piece of code that does something and returns a result.
  • destAmount: 200_000_000, // 200 USDC (decimals adjusted) sets the destination amount to 200,000,000 units. The comment explains that tokens on Solana are counted in small units, so 200,000,000 units corresponds to 200 USDC once the decimal places are accounted for.
  • minAmountOut: 190_000_000 sets the minimum acceptable output to 190,000,000 units, that is 190 USDC.
  • }); closes the settings object and the function call.
  • const maliciousSwapData = getMaliciousRoute(); creates a second variable holding a route obtained from a separate function, getMaliciousRoute, which is not tied to the proof at all.

It shows a proof generated for a destination amount of 200 USDC and a minimum out of 190 USDC, paired with a route obtained independently of that proof. The point is that nothing ties the two together. The proof says "I will accept at least 190 USDC"; the route says "here is how we get there"; and because the route's fingerprint is not inside the proof, the route can be swapped for any other route that still lands at or above 190 USDC.

Step 3: Craft a proof that passes verification but violates accounting

If the circuits are flawed or contain backdoors, an attacker can craft a proof that passes mathematical verification while violating the protocol's accounting rules. The report calls this a classic "verifier does not know what it is verifying" vulnerability. A backdoor is a hidden weakness deliberately built into a system. As with the first finding, no simulation is shown.

Step 4: Instant upgrade through the multisig

The program is upgradeable via a Squads v4 3-of-4 multisig with no timelock. The upgrade authority can therefore modify program logic instantly, which could freeze or drain user funds if the multisig holders are compromised or act maliciously. "Compromised" means their keys were stolen or their devices were taken over. The report notes that a timelock, for example 48 to 72 hours, is standard practice in DeFi so that users can exit if a malicious upgrade is proposed. DeFi stands for decentralised finance: financial services built on blockchains rather than run by banks.

Root cause

The root cause of the first and third findings is a design dependency: the protocol's invariants live entirely inside circuits that are not published, while the on-chain verifier only checks that a proof satisfies whatever constraints the hardcoded verification key encodes. An invariant is a rule that must always hold, such as "money is never created". The verifier has no way to know whether those constraints express value conservation, nullifier handling or note accounting. Publishing the verification key without the circuit, the R1CS and the trusted setup transcript leaves the binding between key and intended logic unverifiable. "Binding" here means the provable link between the key and the rule it is supposed to enforce.

The root cause of the second finding is an unconstrained input. swap_data_hash exists in SwapParams, but the documentation states it is not constrained by the proof until the circuit and verification key are upgraded. The circuit constrains only min_amount_out and dest_amount, so the route itself is supplied by the relayer at execution time and is not bound to the proof. Existing defences do not cover this: the proof is valid, and the contract has no independent way to check the route's integrity.

The governance observation has a simpler cause: the upgrade path through the Squads v4 3-of-4 multisig has no delay, so there is no window in which users can react to a proposed change.

Impact

For the absent-circuit findings, the impact is described as draining the privacy pool. The condition is access to the circuits: a malicious actor or an internal team member who can modify the circuit and generate a matching proof can have the contract release funds to an attacker address. The report notes that such a drain would not leave a trace on the traditional Solana execution logs, and calls this black-box reliance the most critical threat vector. Execution logs are the records a blockchain keeps of what each transaction did; if the proof is valid, the logs show a normal-looking withdrawal. The third finding is explicitly conditional on the circuits being flawed or containing backdoors.

For the swap finding, the affected party is the user whose transaction is intercepted, and the actor is a malicious relayer or a front-running attacker. The outcome depends on the substituted route: either the swap fails and funds are locked or lost through reverts or state corruption, or the route is crafted so the output barely meets min_amount_out and value is stolen. The report's summary table rates this High / Critical.

For the governance observation, the exposure is to all users of the pool if the multisig holders are compromised or act maliciously, since program logic can change instantly. The report's summary table rates this Medium.

The report's summary table records the findings as follows:

# Vulnerability Severity Status Action Required
1 Reliance on absent ZK circuits Critical Unconditional Immediate publication of circuits and re-do trusted setup
2 Unconstrained swap_data_hash High/Critical Unconditional Upgrade circuit to include route hash and redeploy VK
3 Value conservation violation via circuits Critical Conditional Third-party audit of circuits; make public
4 No timelock on upgrade authority Medium Observation Add a 48-hour timelock to the multisig upgrade process

Severity is a rough ranking of how bad a problem is if it is used. "Critical" is the top of the scale, "High" is just below, "Medium" is moderate. "Observation" means it is noted as a weakness rather than a demonstrated attack.

Fix

The report recommends the following.

For the absent circuits:

  1. Publish all circuits, R1CS files and the trusted setup transcript in a dedicated public repository.
  2. Implement reproducible builds for the circuits so the verification key in the contract can be generated independently by the community.
  3. Re-do the trusted setup with a new multi-party ceremony involving prominent community members, given the lack of transparency.
  4. Add a mechanism to the contract or build process that verifies the deployed verification key corresponds to the correct circuit hash.

A reproducible build is a build process that always produces exactly the same output from the same input, so anyone can rebuild it and compare. A build is the step that turns source code into the finished program. If the build is reproducible, a community member can compile the published circuit themselves and check that the resulting verification key matches the one in the live program.

For the swap path:

  1. Add swap_data_hash as a public input to the ZK circuit.
  2. Deploy the updated verification key to the mainnet program.
  3. Until the circuit is upgraded, implement a hardcoded whitelist of trusted Jupiter quote APIs, or introduce a relayer-bond and slashing mechanism to disincentivise route manipulation.

A whitelist is a fixed list of things that are allowed. An API (application programming interface) is a way for one piece of software to ask another for data or actions; a Jupiter quote API is the service that returns a proposed swap route and price. A relayer bond is money a relayer must put up as a guarantee of good behaviour, and slashing is the practice of taking that money away if they misbehave. The comparison is a security deposit on a rented flat.

For the circuit-dependent accounting risk:

  • Make the circuits and R1CS publicly available and have them audited by third-party firms, with Trail of Bits and Kudelski named as examples, before mainnet release.
  • Store a hash of the canonical circuit R1CS on chain. The report says the contract cannot verify this natively without off-chain support, but that it creates a binding commitment to the intended logic.

An audit is a structured review of code by an independent expert. "Canonical" means the single official version. "Off-chain support" means help from software outside the blockchain, since the blockchain program itself cannot recompute the hash.

For governance:

  • Add a timelock, with 48 hours given as the figure in the summary table and 48 to 72 hours as the general practice, to the multisig upgrade process.

The report closes with four immediate remediation steps for Veilo: open source the circuits, re-do the trusted setup with community participation, patch the swap circuit to integrate swap_data_hash, and implement a timelock on the upgrade authority. Remediation means fixing the problem.

Variants to test

These are the same kinds of problem to look for in other projects. They are written as patterns, not as instructions to attack anyone.

  • Other privacy pools with hardcoded verification keys. Check whether the circuit source, R1CS and trusted setup transcript are published alongside the key. A positive result is a deployed verifier whose key cannot be tied to any public circuit, which reproduces the black-box condition described here.
  • Other relayer-supplied parameters that are hashed but not constrained. Look for fields named like *_hash in instruction parameters and check whether they appear as public inputs in the proof. A positive result is a field the documentation or code admits is not yet constrained, as with swap_data_hash.
  • Swap and DEX-aggregator integrations in ZK systems. Test whether the route, pool or venue is bound to the proof or only the minimum output amount. A positive result is a transaction where substituting the route leaves the proof valid. A DEX is a decentralised exchange, and an aggregator is a service that routes your trade across several of them.
  • Upgrade authorities without a timelock. Enumerate programs whose upgrade authority is a multisig and check for a delay between proposal and execution. A positive result is an instant upgrade path on a program holding user funds.
  • Documentation that disclaims production readiness. Where a README states the software is provided "as is" and warns against production use without auditing, check whether the deployed program nonetheless holds funds. A positive result is a live deployment whose own documentation disclaims its readiness.

Glossary

  • API (application programming interface): a way for one piece of software to ask another for data or actions.
  • Audit: a structured review of code by an independent expert.
  • Backdoor: a hidden weakness deliberately built into a system.
  • Balance conservation: the rule that the total going into a pool plus any publicly added amount equals the total coming out, so money cannot be created.
  • Binding: a provable link between two things, such as a verification key and the rule it is meant to enforce.
  • Blockchain: a public ledger of transactions maintained by many computers at once.
  • Bug bounty program: a scheme that rewards people for finding and reporting security problems instead of exploiting them.
  • Build: the step that turns source code into a finished program.
  • Canonical: the single official version of something.
  • Circuit: the written description of the rule that a ZK proof is supposed to prove.
  • Circom: the programming language used to write ZK circuits.
  • Commitment: a cryptographic fingerprint of a hidden value, published without revealing the value.
  • Compromised: a key or device that has been stolen or taken over.
  • Conditional: a finding that only bites if some other condition holds, here the hidden circuits being flawed.
  • Constrained by the proof: a value that the proof mathematically forces to be a particular thing, so it cannot be changed without invalidating the proof.
  • DeFi (decentralised finance): financial services built on blockchains rather than run by banks.
  • DEX (decentralised exchange): an exchange that runs on a blockchain rather than through a company.
  • Execution logs: the records a blockchain keeps of what each transaction did.
  • Front-running: seeing someone else's pending transaction and getting your own in ahead of it to profit.
  • Function: a named piece of code that does something and returns a result.
  • Governance: the rules and people that control changes to a system.
  • Groth16: a specific, widely used Zero-Knowledge proof scheme that depends on a trusted setup.
  • Hardcoded: written directly into a program's source as a fixed value that cannot change without a new deployment.
  • Hash: a short fingerprint computed from a larger piece of data, which cannot be reversed to recover the input.
  • Illiquid pool: a trading pool with very little money in it, so trades move the price sharply.
  • Inclusion proof: a proof that a particular item is in a list, without showing the whole list.
  • Instruction: a single command sent to a blockchain program.
  • Invariant: a rule that must always hold.
  • Jupiter: a swap aggregator on Solana that finds routes across pools.
  • Mainnet: the real network where real money moves.
  • MEV (maximal extractable value): the profit someone can make by choosing the order and content of transactions.
  • Merkle tree: a way of summarising a large list into one short fingerprint so membership can be proven later.
  • min_amount_out: the minimum amount of output token a user will accept from a swap.
  • MPC (Multi-Party Computation): a technique where several parties jointly compute something so that no single party knows the whole secret.
  • Multisig wallet: a wallet that requires several signatures to act, instead of one.
  • Note: a record of value in a privacy pool, with an amount and an asset identifier.
  • Nullifier: a one-time marker that stops the same deposit being spent twice.
  • Off-chain support: help from software outside the blockchain, since the blockchain program cannot do everything itself.
  • On-chain: living on the blockchain itself.
  • Program: a piece of code that lives on a blockchain and runs when it receives an instruction.
  • Proof of concept (PoC): a small demonstration that a claimed problem is real.
  • Proving key: the secret-side material a user needs to produce a ZK proof.
  • Public input: a value the proof openly commits to, visible to the verifier, for which the proof is only valid.
  • R1CS (Rank-1 Constraint System): a standard way of writing a circuit's equations so proving tools can work with them.
  • README: the front page of a code repository, explaining what the project is and how to use it.
  • Relayer: an intermediary service that submits a user's signed transaction to the blockchain on their behalf.
  • Relayer bond: money a relayer must put up as a guarantee of good behaviour.
  • Remediation: fixing a problem.
  • Reproducible build: a build that always produces exactly the same output from the same input, so anyone can rebuild and compare.
  • Revert: a blockchain transaction that is cancelled partway through and undone.
  • Route: the specific path a swap takes through one or more pools.
  • Severity: a rough ranking of how bad a problem is if it is used.
  • SHA-256: the specific hashing algorithm used to fingerprint the swap route data.
  • Slashing: taking away a bond when a party misbehaves.
  • Slippage: the difference between the price you expected and the price you actually got.
  • Solana: a blockchain network.
  • SOL: the native token of Solana.
  • Squads v4: the multisig product used to control the Veilo program's upgrade authority.
  • Static review: reading code and documentation carefully without running attacks against the live system.
  • Structure: a bundle of named fields grouped together in programming.
  • Swap: an exchange of one token for another.
  • Timelock: a forced waiting period between approving a change and the change taking effect.
  • Token: a unit of value on a blockchain.
  • Transcript: the public record of a trusted setup ceremony, which lets outsiders check it was run properly.
  • Trusted setup: a ceremony that generates the secret material behind proving and verification keys, which is only safe if no single party kept the secrets.
  • Unconditional: a finding that can be argued from code and on-chain logic alone, regardless of other unknowns.
  • Upgrade authority: whoever holds the power to replace a program's code.
  • USDC: a stablecoin on Solana pegged to the US dollar.
  • Variable: a named box in a program that holds a value.
  • Verification key: the public-side material a verifier needs to check a ZK proof.
  • Whitelist: a fixed list of things that are allowed.
  • Zero-Knowledge proof (ZK proof): a way to convince someone that a statement is true without revealing the information behind it.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.