Missing signer checks on Solana: what the bug is, how to fix it, and how to find it
A Solana program trusts whatever accounts the transaction hands it. If one of those accounts is meant to be your admin, your vault’s owner or a user approving a withdrawal, the program has to check that the key actually signed the transaction. Skip that check and anyone can pass in your admin’s public address, which is public by definition, and act as them.
It’s a simple bug, and an easy one to write by accident.
What it looks like
This is the insecure example from sealevel-attacks, the public repo Coral (the Anchor team) wrote to teach common Solana bugs:
#[derive(Accounts)]
pub struct LogMessage<'info> {
authority: AccountInfo<'info>,
}AccountInfo tells Anchor to load the account and nothing more. It doesn’t check the owner of that key signed anything. The example program only logs a message, so it’s harmless. Put the same line in front of a withdraw, a config change or a mint, and it isn’t.
The fix is one word
#[derive(Accounts)]
pub struct LogMessage<'info> {
authority: Signer<'info>,
}With Signer, Anchor rejects the instruction unless that key signed the transaction. This is the repo’s recommended version.
If you need to keep AccountInfo, or you write native programs, check it by hand. This is the repo’s other fixed version:
if !ctx.accounts.authority.is_signer {
return Err(ProgramError::MissingRequiredSignature);
}has_one is not a signer check
This one catches people out. has_one = authority checks that the key you passed matches the one stored on the account. It doesn’t check that key signed. An attacker who passes your real authority’s address satisfies has_one without your private key.
Use both: has_one to tie the authority to the account it controls, Signer to prove it’s really them.
#[derive(Accounts)]
pub struct Withdraw<'info> {
#[account(mut, has_one = authority)]
pub vault: Account<'info, Vault>,
pub authority: Signer<'info>,
}Check your own program in five minutes
- Search your program for
AccountInfoandUncheckedAccount. - For each one inside a
#[derive(Accounts)]struct, ask: does this account act as an authority, admin, owner or approver? - If yes, it should be a
Signer, or the instruction should checkis_signerbefore doing anything. - Look again at every
has_oneon an authority. Is the authority also aSigner?
Or let Probus check it
Probus reads your Solana repo, the Anchor or native program and the backend code around it, and flags missing signer checks along with the other common Solana bugs. On sealevel-attacks it flagged the insecure version of this example and nothing in the two fixed ones. 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.
Next in the series: missing owner checks.