Rules › Anchor (Rust)
Unchecked account without a /// CHECK: note
AccountInfo and UncheckedAccount skip Anchor's owner and type checks; each needs an explicit reason and manual checks.
Why it matters
AccountInfo and UncheckedAccount tell Anchor to skip its owner, discriminator and type checks. Anchor refuses to build them without a /// CHECK: doc comment, because each one is a place where an attacker can pass any account they like. The comment should say why the account is safe, and the code should actually check it (key, owner or data).
Vulnerable
#[derive(Accounts)]
pub struct Proxy<'info> {
pub target: UncheckedAccount<'info>,
}
Fixed
#[derive(Accounts)]
pub struct Proxy<'info> {
/// CHECK: only used as the CPI target; its key is checked against EXPECTED_PROGRAM
#[account(address = EXPECTED_PROGRAM)]
pub target: UncheckedAccount<'info>,
}
What other tools call it
| Tool | Detector or reference |
|---|---|
| Anchor | anchor build error: unsafe field |
| Sealevel attacks | 2-owner-checks, 3-type-cosplay |
Check your code
Paste a contract into the in-browser checker, or let the Claude Code plugin scan before every deploy. The quick check for this rule is a pattern match: treat a hit as "look here", and a miss as no guarantee.
Related rules
- Authority account that isn't a Signer
- CPI to a program the caller chooses
- Account data deserialized without an owner check
- init_if_needed (reinitialization risk)
- Account closed by draining lamports by hand
- overflow-checks not enabled for release builds
Static analysis finds known bug classes; it can't prove code is safe and isn't an audit. Get a professional audit before deploying code that will hold value.