Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
use anchor_lang::prelude::*;
use anchor_lang::system_program::{create_account, CreateAccount};

// NOTE: this example does not restrict who may call it. A real rent vault
// needs an authority check: a `has_one` against an admin recorded at
// initialization, seeds that bind the vault to one funder, or a per-caller
// limit. A bare `authority: Signer` alone is not enough, since any keypair
// can sign for itself.
Comment on lines +4 to +8

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Incomplete authority guidance

The caution presents funder-bound PDA seeds, has_one, and per-caller limits as standalone authority checks. However, an attacker can still pass another funder’s PDA unless the related funder or admin must also sign, and disposable keypairs can bypass per-caller limits. Since readers may copy this example, clarify that the selected vault must be tied to an authenticated signer. The native and Pinocchio comments contain the same guidance.

Knowledge Base Used:

#[derive(Accounts)]
pub struct CreateNewAccount<'info> {
#[account(mut)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ use solana_program::{

use crate::state::RentVault;

// NOTE: this example does not restrict who may call it. A real rent vault
// needs an authority check: an authority recorded at initialization with
// seeds that bind the vault to one funder, or a per-caller limit. A bare
// signer alone is not enough, since any keypair can sign for itself.
pub fn create_new_account(program_id: &Pubkey, accounts: &[AccountInfo]) -> ProgramResult {
let accounts_iter = &mut accounts.iter();
let new_account = next_account_info(accounts_iter)?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ use pinocchio::{

use crate::state::RentVault;

// NOTE: this example does not restrict who may call it. A real rent vault
// needs an authority check: an authority recorded at initialization with
// seeds that bind the vault to one funder, or a per-caller limit. A bare
// signer alone is not enough, since any keypair can sign for itself.
pub fn create_new_account(
program_id: &Address,
accounts: &mut [AccountView],
Expand Down