Skip to content

docs(pda-rent-payer): caution note on the unrestricted caller of create_new_account - #732

Open
devtechedge wants to merge 1 commit into
solana-foundation:mainfrom
devtechedge:pda-rent-payer-note-671
Open

docs(pda-rent-payer): caution note on the unrestricted caller of create_new_account#732
devtechedge wants to merge 1 commit into
solana-foundation:mainfrom
devtechedge:pda-rent-payer-note-671

Conversation

@devtechedge

Copy link
Copy Markdown

What and why

create_new_account spends from a shared rent_vault PDA and the only signer is the newly created account itself, so anyone can drain the vault one rent-exempt minimum at a time. That is intentional here - the example exists to show a PDA signing for itself - but it is exactly the kind of helper that gets copied into real programs, per the discussion in #671.

This adds the suggested caution comment above the instruction in all three flavors (anchor, native, pinocchio) so the note travels with whatever version a reader copies. No behavior changes; the example keeps teaching what it teaches.

Fixes #671

AI disclosure

Check exactly one. See CONTRIBUTING.md.

  • No AI tooling was used beyond editor autocomplete.
  • AI tooling was used. Tool and extent: drafted the comment text with Claude; I reviewed the diff across the three flavors and matched each file's style before opening.

Testing

Comment-only change, no code touched.

create_new_account spends from a shared rent_vault PDA and the only
signer is the newly created account itself, so anyone can drain the
vault one rent-exempt minimum at a time. Add a caution note above the
instruction in the anchor, native and pinocchio flavors pointing copyists
at the authority checks a real rent vault needs. The example itself is
unchanged since it exists to show a PDA signing for itself.

Fixes solana-foundation#671
@greptile-apps

greptile-apps Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

The comment-only change is non-blocking, but the mitigation guidance should explicitly tie the selected vault to an authenticated signer before readers copy it.

Findings

  1. P2 Incomplete authority guidance

Summary

  • Adds equivalent warnings to the Anchor, native, and Pinocchio variants.
  • Leaves executable behavior unchanged.
  • The proposed mitigation examples should more explicitly require an authenticated signer tied to the selected vault.

Reviews (1) · Last reviewed commit: "pda-rent-payer: note that create_new_acc..."

Comment on lines +4 to +8
// 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.

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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

basics/pda-rent-payer: create_new_account has no caller check — worth a note for people copying it?

1 participant