5

pda are generated with combination of seeds and bump, so if I know seeds and bump (in case if I don't know the bump, I can brute force it[0-255]) used by program to generates a pda to hold some tokens. can I generate the same pda and do some malicious transaction acting as authority for that pda.

Please help me understand this topic

2 Answers 2

5

PDAs are all about two key points

  • Being able to generate predictable addresses
  • Allowing programs (and only them) to sign transactions without a private key (using seeds and bump), which serves as foundation for Cross Program Invocations (CPI)

A different thing is the data living at that PDA address, i.e. the account. All accounts in Solana have a program owner, and is that program the one in charge of putting in place the rules enforcing which parties can modify the accounts data or do other operations like CPIs. Usually it is recommended that you store the seeds and bump of the PDA in the account living at that PDA address, so later on you can verify it.

Going back to your question, as you can see from the above, the seeds and bump of PDAs are not a secret. They are usually stored on-chain (meaning they are all public info) and you can check a lot of open source programs source code or their corresponding JS SDKs to see how PDAs are generated, including Solana's.

The important detail to remember is that it doesn't matter if you know how to generate the PDA, you won't be able to sign for it from client side (only the program from which it was derived can) and the program owning the account living at the PDA is the one that restrict access based on it's own rules and (hopefully) it won't let you do much if you are not one of the authorized parties.

Recommended readings:

6

PDAs are found, not generated, they aren't designed to be secretive.

let [pda, bump] = await PublicKey.findProgramAddress(
  [...arrayOfSeeds],
  programId
);

You don't need to know or "brute force" the bump. The findProgramAddress method will start with bump = 255 and simply iterate down through bump = 254, bump = 253, etc. until it finds an address that is not on the elliptic curve.

can I generate the same pda and do some malicious transaction acting as authority for that pda

So you can find the PDA but it's entirely dependent on the program whether you can "do some malicious transaction".

Since only the owner of an account can modify it's data or debit lamports:

  1. The owning program will need to have an instruction to carry out those actions otherwise it won't be possible to do anything malicious
  2. You can't "act" as an authority. Only the "signing authority" (in this case the program) has the authority on that account.

If necessary checks are not in place on the program side, anyone "could" instruct the program to modify the data or debit the lamports from a PDA. (Considering instructions exist to do so)

1
  • Does that mean I can pass PDA to my program without checking its seed and bump like: #[account(mut)] pub my_pda: Account<'info, MyPda> ??
    – Russo
    Commented Sep 4 at 8:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.