I am currently experimenting a bit with Solana accounts and I am wondering if it is possible to change the owner of an account.
I am curious it is possible since the security of some programs are relying on this owner check, as explained here
I am also looking into the assign function and on how it works, but I was not able to make it work yet.
Am I misunderstanding something or just was not able to make it work?
Here the Python code is used:
tx = Transaction().add(
create_account(CreateAccountParams(
from_pubkey=attacker_keypair.public_key,
new_account_pubkey=account_keypair.public_key,
lamports=client.get_minimum_balance_for_rent_exemption(0)["result"],
space=0,
program_id=attacker_keypair.public_key,
))
)
send_and_confirm_tx(client, tx, attacker_keypair, account_keypair)
print('Sending 1st tx to program')
tx = Transaction().add(TransactionInstruction(
keys=[
AccountMeta(pubkey=account_keypair.public_key, is_signer=False, is_writable=False),
],
program_id=PROGRAM_ID,
))
send_and_confirm_tx(client, tx, attacker_keypair)
print('Sending 2nd tx to program')
tx = Transaction().add(assign(AssignParams(
account_pubkey=account_keypair.public_key,
program_id=attacker2_keypair.public_key
)))
send_and_confirm_tx(client, tx, account_keypair)
Error message is: InvalidAccountForFee