Skip to content

Stake account should assert on state #3

@mcintyre94

Description

@mcintyre94

As currently written, the stake account tests do not include any assertions if the state is not initialized or stake:

    const assertions: StakeAccountAssertion[] = [];

    if (
      simulatedAccount.accountType === 'initialized' ||
      simulatedAccount.accountType === 'stake'
    ) {
      // add assertions
    }

    let builder = assertStakeAccountMulti(umi, {
      targetAccount: publicKey(simulatedAccount.address),
      logLevel,
      assertions,
    });

Assuming a sophisticated attacker can control the simulation result, they could provide a state that is not one of these. The actual transaction could then steal eg the withdraw authority, which there would be no assertion for.

I think we should protect against this by asserting the state is as expected from the simulation result, failing the transaction if the stake account is put into an unexpected state.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions