Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

detect implicit signer check #69

Open
0xalpharush opened this issue May 23, 2023 · 0 comments
Open

detect implicit signer check #69

0xalpharush opened this issue May 23, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@0xalpharush
Copy link

0xalpharush commented May 23, 2023

The missing signer check lint will warn on the from account despite being implicitly checked by the system's transfer instruction (It creates an instruction with AccountMeta:new(from, is_signer:true)). We can check if accounts are used in instructions for which they are required to be signers to improve the precision.

Example false positive:

pub fn my_transfer_func<'a>(
    from: &AccountInfo<'a>,
    to: &AccountInfo<'a>,
    system_program: &AccountInfo<'a>,
    amount: u64,
) -> Result<(), ProgramError> {
    let instruction = transfer(from.key, to.key, amount);
    // [...]
    invoke(
        &instruction,
        &[from.clone(), to.clone(), system_program.clone()],
    )?;
    Ok(())
}
@0xalpharush 0xalpharush added the enhancement New feature or request label May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant