PDA mistakes on Solana: seeds that are shared and bumps you didn’t choose
A program derived address, or PDA, is an address your program controls without a private key. You get one from a list of seeds, your program’s ID and a one-byte “bump”. Your program can sign for it, so PDAs often hold the funds or act as the authority over a vault.
That makes the seeds and the bump part of your security. Get either wrong and someone else can use an address you thought was yours alone. Both mistakes below come from sealevel-attacks, the public repo Coral (the Anchor team) wrote to teach common Solana bugs.
Mistake 1: seeds that more than one user shares
In the insecure example, a token pool signs for its vault with a PDA built from the pool’s mint:
let seeds = &[ctx.accounts.pool.mint.as_ref(), &[ctx.accounts.pool.bump]]; token::transfer(ctx.accounts.transfer_ctx().with_signer(&[seeds]), amount)
Every pool for the same mint gets the same signing address. So the authority over one user’s vault is also the authority over everyone else’s vault for that token. An attacker sets up a pool of their own that points at someone else’s vault and their own withdrawal account, and the program signs the transfer for them.
The fix is to build the seeds from something unique to the thing being protected. The repo’s fixed version uses the withdrawal account, and in Anchor checks it in the account constraints:
#[account(
has_one = vault,
has_one = withdraw_destination,
seeds = [withdraw_destination.key().as_ref()],
bump = pool.bump,
)]
pool: Account<'info, TokenPool>,The general rule: anything per user, put the user’s key in the seeds. Anything per pool or per vault, put that account’s key in.
Mistake 2: taking a bump from the caller
The same seeds can produce more than one valid address, one per bump. The canonical bump is the first one that works counting down from 255, and it’s the one find_program_address returns. In the insecure example, the caller sends the bump and the program builds the address from it:
pub fn set_value(ctx: Context<BumpSeed>, key: u64, new_value: u64, bump: u8) -> ProgramResult {
let address =
Pubkey::create_program_address(&[key.to_le_bytes().as_ref(), &[bump]], ctx.program_id)?;The check passes for any bump that gives a valid address, so one set of seeds can point at several accounts. If your program assumes “these seeds mean this one account”, an attacker can bring a second one.
The repo’s recommended fix lets Anchor find the canonical bump:
#[account(seeds = [key.to_le_bytes().as_ref()], bump)] data: Account<'info, Data>,
The repo also suggests storing the bump in the account when you create it, then checking against it withbump = data.bump, which is cheaper. In native code, call find_program_address and reject any other bump.
Check your own program in five minutes
- Search for
seeds =,create_program_addressandfind_program_address. - For each PDA, ask: could two users, or two pools, end up with the same seeds? If so, add the key that tells them apart.
- Check that no instruction takes a bump as an argument and trusts it. Use
bumpin Anchor, or a stored canonical bump.
Or let Probus check it
Probus reads your Solana repo, the Anchor or native program and the backend code around it, and flags both of these along with the other common Solana bugs. On sealevel-attacks it flagged the insecure version of each example and nothing in their fixed versions. See the full report.
That’s an audit of your code for the mistakes that cost Solana teams the most, done in minutes rather than weeks.
Run a free scan on your own repo. No card.