1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
use anchor_lang::prelude::*; #[program] pub mod test_program { use super::*; pub fn unsafe_lamport(ctx: Context<TestCtx>) -> Result<()> { // VULNERABILITY: Direct lamport manipulation **ctx.accounts.user.lamports.borrow_mut() -= 1000000; Ok(()) } pub fn unsafe_arithmetic(ctx: Context<TestCtx>) -> Result<()> { // VULNERABILITY: Arithmetic overflow let mut counter: u32 = 0; counter = counter.saturating_add(u32::MAX); Ok(()) } } #[derive(Accounts)] pub struct TestCtx<'info> { #[account(mut)] pub user: AccountInfo<'info>, }