Skip to content

Commit c4a3d1f

Browse files
authored
Create Improper PDA bump seed validaiton
1 parent 507fcd1 commit c4a3d1f

File tree

1 file changed

+16
-0
lines changed
  • not-so-smart-contracts/solana/improper_pda_validation

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
# Improper PDA bump seed validation
3+
4+
PDAs (Program Derived Addresses) are, by definition, [program-controlled](https://docs.solana.com/terminology#program-derived-account-pda) accounts and therefore can be used to sign without the need to provide a private key. PDAs are generated through a set of seeds and a program id, which are then collectively hashed to verify that the key doesn't lie on the ed25519 curve (curve used by Solana to sign transactions).
5+
6+
Values on this elliptic curve have a corresponding private key, which wouldn't make it a PDA.
7+
In the case a public key lying on the elliptic curve is found, our 32-byte address is modified through the addition of a bump to "bump" it off the curve. A bump, represented by a singular byte iterating through 255 to 0 is added on to our input until an address that doesn’t lie on the elliptic curve is generated, meaning that we’ve found an address without an associated private key.
8+
9+
The issue arises with seeds being able to have multiple bumps, thus allowing varying PDAs that are valid from the same seed. An attacker can create a PDA with fabricated data - the program_id and seeds are the same as the expected PDA but with different bump seeds. Without any explicit check against the bump seed itself, the program leaves itself vulnerable to the attacker tricking the program into thinking they’re the expected PDA and thus interacting with the contract on behalf of them.
10+
11+
## Exploit Scenario
12+
13+
### Example Contract
14+
15+
## Mitigation
16+

0 commit comments

Comments
 (0)