Trying to understand how the #[account(close = <target_account>)]
constraint works and it says:
Marks the account as closed at the end of the instruction’s execution (sets its discriminator to the CLOSED_ACCOUNT_DISCRIMINATOR
) and sends its lamports to the specified account.
Setting the discriminator to a special variant makes account revival attacks (where a subsequent instruction adds the rent exemption lamports again) impossible.
Requires mut to exist on the account.
Also looked through the examples here: https://github.com/coral-xyz/sealevel-attacks/tree/master/programs/9-closing-accounts
Could someone provide an example of how an account revival attack can be used as an exploit and explain why it is insecure to close an account without setting the discriminator to a special variant?