Skip to content

Prove that pda system account store lamports really secure

Notifications You must be signed in to change notification settings

docongminh/pda-system-account-proof

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

pda-system-account-proof

Prove pda system account storage lamports really secure. Some people concern about pda account, that assigned for system program rather than itself program id is not secure. This 's a piece of code that prove that pda account assigned for system program always secure.

Explained

TODO

Program init pda account

   #[program]
   pub mod pda {
        use super::*;

        pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
            let bump = *ctx.bumps.get("escrow_account").unwrap();
            ctx.accounts.create_native_account_vault(bump)?;
            Ok(())
        }
   }

Program init hack pda account

    #[program]
    pub mod hacker {
        use super::*;

        pub fn drain(ctx: Context<Drain>) -> Result<()> {
            let bump = *ctx.bumps.get("escrow_account").unwrap();
            ctx.accounts.drain_sol(bump)?;
            Ok(())
        }
    }

Step by Step

  • Deploy program: deploy pda:

      cd programs/pda
      anchor build && anchor deploy
    
  • Deploy hacker:

       cd prgrams/hacker
       anchor build && anchor deploy
    

Notes: Update program in declare id in all program

    declare_id!("FcBBAczSDVtSwJ55RWfbGAwEQTyQ3Urh29UHi3qrFPJf");
  • Run client

      cd client && cargo build
    

    run test:

      /target/debug/client --pda-program-id programId --hacker-program-id programId

    Example:

      ./target/debug/client --pda-program-id DzSN8ZCEURUe3nXtUi23L4N6jCQT16B8GjfZQ1CkoQEh --hacker-program-id FcBBAczSDVtSwJ55RWfbGAwEQTyQ3Urh29UHi3qrFPJf

About

Prove that pda system account store lamports really secure

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages