Skip to main content

Baseline Checklist

  1. 检查程序是否使用了外部的account关联 重要的权限 / spl-token accounts / … ,外部注册的 account 拥有私钥,可以签名交易。
  2. Account Reloading
  3. ATA Check
  4. 确认load_instruction_at_checked读到的IX有没有绑定program_id
  5. 如果用户是Signer,可能是SystemAccount(包括多签钱包)或者PDA。不需要用户签名时,不能假定用户是SystemAccount,只能是UncheckedAccount。
  6. 如果调用了 spl_token::instruction::close_account ,如果 token account 不是 WSOL,应确保在本 ix 中转出的 amount == token_account.amount ,而不是任何内部记账值。Anchor 关键字: CloseAccount
  7. 在 program 中 新建 ATA 账户必须使用 init_if_needed constraint,使用 init 会导致 DOS。见 anchor 源码: https://github.com/coral-xyz/anchor/blob/c93b33a27ef68f7380e573711b53bdda81b3632d/lang/syn/src/codegen/accounts/constraints.rs#L625-L639https://github.com/coral-xyz/anchor/blob/c93b33a27ef68f7380e573711b53bdda81b3632d/spl/src/associated_token.rs#L10-L30 ,并没有额外的特殊处理(讲道理额外处理一下更好,应该不会有额外的安全风险?)