The dataset is currently empty. Upload or create new data files. Then, you will be able to explore them in the Dataset Viewer.

YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

Veilo privacy_pool — Security Finding V-01 (Mainnet Bounty Submission)

Affected program: GYy4kM6GHhpgLCUscuABbzkD2ZbJ2fneYryaZ6Ch7fFU (Veilo / privacy_pool, Solana Mainnet-Beta) Instruction: phoenix_ember_unwrap Severity: Medium-High Category: Token accounting / TVL integrity Fund-loss path: YES — bounded (cannot mint third-party funds) Source: github.com/VeiloSolana/privacy-program (public, Anchor framework) No live funds moved. No mainnet state mutated. All validation below is read-only / local-test / fork-simulation.


1. Summary

In the Phoenix exit flow, phoenix_ember_unwrap credits the vault total_tvl and the per-exit pending_reissue.amount bucket by a caller-supplied amount, without verifying that the EMBER unwrap CPI actually delivered that much USDC into the executor's token account.

If EMBER delivers less than amount (insufficient PhUSD/USDC reserve, rounding, or a wrong emberUsdcReserve/phUsdMint supplied in remaining_accounts), the vault is over-credited: total_tvl and the exit bucket record more USDC than physically arrived. The defect is bounded by the per-user slot.withdrawn cap (phoenix.rs:1531), so it cannot be used to mint notes against other users' funds — but it breaks the 1:1 backing of the exiting user's bucket and can produce a localized insolvency / revert-on-reissue.


2. Vulnerable code — programs/privacy-pool/src/phoenix.rs (~1605–1671)

After the EMBER withdraw CPI (expected to release amount USDC into executor_token_account), the handler does NOT measure the executor ATA balance delta. It unconditionally transfers and credits amount:

invoke_signed(&ember_unwrap_ix, &ember_unwrap_cpi_infos, &[executor_seeds])?;

// transfer `amount` from executor ATA to vault
token::transfer(
    CpiContext::new_with_signer(
        ctx.accounts.token_program.to_account_info(),
        token::Transfer {
            from: ctx.accounts.executor_token_account.to_account_info(),
            to: ctx.accounts.vault_token_account.to_account_info(),
            authority: ctx.accounts.executor.to_account_info(),
        },
        &[executor_seeds]
    ),
    amount                       // <-- caller-supplied, NOT measured
)?;

// TVL credit uses `amount`, not actual delivered
cfg.total_tvl = cfg.total_tvl.checked_add(amount)
    .ok_or(error!(PrivacyError::ArithmeticOverflow))?;

// pending reissue credit uses `amount`, not actual delivered
pending.amount = pending.amount.checked_add(amount)
    .ok_or(error!(PrivacyError::ArithmeticOverflow))?;

amount comes verbatim from instruction args. There is no before/after balance read on executor_token_account across the EMBER CPI.

3. Why it is exploitable (bounded)

  • phoenix_ember_unwrap enforces new_pending <= slot.withdrawn (phoenix.rs:1531).
  • phoenix_reissue_notes enforces pending.amount >= amount (phoenix.rs:1766), same cap.
  • slot.withdrawn is what the same user queued from their own deposit — so no third-party theft.

The defect manifests as: the exiting user's pending_reissue / total_tvl is over-credited relative to real USDC in the vault. The pending.amount over-credit later lets the claimant attempt to reissue notes for USDC the vault never received → reissue reverts, or a localized insolvency of that exit bucket, breaking 1:1 backing.

4. Recommended fix

Measure the executor USDC ATA balance delta across the EMBER CPI and use the actual received amount for the transfer, TVL bump, and pending increment:

let before = deserialize_token_account(&ctx.accounts.executor_token_account)?.amount;
invoke_signed(&ember_unwrap_ix, &ember_unwrap_cpi_infos, &[executor_seeds])?;
let after = deserialize_token_account(&ctx.accounts.executor_token_account)?.amount;
let received = after.checked_sub(before).ok_or(error!(PrivacyError::ArithmeticOverflow))?;
// transfer `received` to vault; bump total_tvl and pending.amount by `received`

Also validate remaining[11] (EMBER_USDC_RESERVE) and remaining[9] (phUsdMint) against pinned constants — the deposit path already does this (phoenix.rs:376–378); the unwrap path should too.

5. Reproduction (no chain required)

Deterministic pure-Rust harness replicating the exact credit arithmetic at phoenix.rs:1640–1669. Runs with plain cargo test — no validator, no RPC, no mainnet state.

struct Vault { total_tvl: u64 }
struct PendingReissue { amount: u64, claimant_pubkey: [u8; 32] }

fn ember_unwrap_credit(vault: &mut Vault, pending: &mut PendingReissue, amount: u64) {
    // program NEVER reads how much EMBER actually delivered
    vault.total_tvl = vault.total_tvl.checked_add(amount).unwrap();
    pending.amount = pending.amount.checked_add(amount).unwrap();
}

#[test]
fn v01_overcredit_when_ember_delivers_less_than_amount() {
    let amount: u64 = 1_000_000;          // attacker-supplied
    let actual_delivered: u64 = 100_000;  // EMBER only delivered 10%
    let mut vault = Vault { total_tvl: 0 };
    let mut pending = PendingReissue { amount: 0, claimant_pubkey: [0u8; 32] };
    ember_unwrap_credit(&mut vault, &mut pending, amount);
    assert_eq!(vault.total_tvl, 1_000_000);
    let phantom = vault.total_tvl.saturating_sub(actual_delivered);
    assert_eq!(phantom, 900_000, "vault over-credited by phantom USDC");
    assert_ne!(vault.total_tvl, actual_delivered,
        "V-01: credit is based on caller amount, not actual USDC delivered");
}
cd pocs/v-01-proof && cargo test
# test v01_overcredit_when_ember_delivers_less_than_amount ... ok
# test v01_pending_allows_reissue_of_phantom_funds ... ok
# test result: ok. 2 passed; 0 failed

6. Source == mainnet (deployed program is the audited source)

The Anchor instruction discriminator SHA256("global:<name>")[..8] for every value-moving instruction (transact, phoenix_ember_unwrap, phoenix_reissue_notes, jperp_reissue_notes, open_position, close_position, …) is byte-present in both the mainnet-dumped binary and a local cargo build-sbf build — i.e. the deployed instruction set is identical to the audited source. Raw SHA-256 differs only due to a documented pinned custom-heap / overflow-checks=true build profile, not a source divergence.

7. Submission checklist

  • Affected mainnet contract + instruction named
  • Clear bug explanation
  • Fund-loss path described (bounded over-credit)
  • Reproducible PoC (cargo test, 2 passed) + read-only demonstrator
  • Source == mainnet proven via Anchor discriminators
  • Suggested fix provided (§4)
  • No live funds moved / no mainnet state mutated
Downloads last month
35