Skip to content

Commit 1f2f09a

Browse files
committed
Touch up signer check example
1 parent 4f678cc commit 1f2f09a

File tree

1 file changed

+4
-4
lines changed
  • not-so-smart-contracts/solana/signer_check

1 file changed

+4
-4
lines changed

not-so-smart-contracts/solana/signer_check/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ In Solana, each public key has an associated private key that can be used to gen
44
In case certain permissions are required to perform a sensitive function of the contract, a missing signer check becomes an issue. Without this check, an attacker would be able to call the respective access controlled functions permissionlessly.
55

66
## Exploit Scenario
7-
The following contract sets an escrow account's state to `Complete`. Unfortunately, the contract does not check whether the escrow account holder has signed the transaction.
8-
Therefore, a malicious actor can set the state to `Complete`, without needing access to the escrow account holders’s private key.
7+
The following contract sets an escrow account's state to `Complete`. Unfortunately, the contract does not check whether the `State` account's `authority` has signed the transaction.
8+
Therefore, a malicious actor can set the state to `Complete`, without needing access to the `authority`’s private key.
99

1010
### Example Contract
1111
```rust
12-
fn pay_escrow(_program_id: &Pubkey, accounts: &[AccountInfo], _instruction_data: &[u8]) -> ProgramResult {
12+
fn complete_escrow(_program_id: &Pubkey, accounts: &[AccountInfo], _instruction_data: &[u8]) -> ProgramResult {
1313
let account_info_iter = &mut accounts.iter();
1414
let state_info = next_account_info(account_info_iter)?;
1515
let authority = next_account_info(account_info_iter)?;
1616

1717
let mut state = State::deserialize(&mut &**state_info.data.borrow())?;
1818

19-
if state.authority == authority.key {
19+
if &state.authority == authority.key {
2020
state.escrow_state = EscrowState::Complete;
2121
state.serialize(&mut &mut **state_info.data.borrow_mut())?;
2222
}

0 commit comments

Comments
 (0)