docs(pda-rent-payer): caution note on the unrestricted caller of create_new_account - #732
Open
devtechedge wants to merge 1 commit into
Open
docs(pda-rent-payer): caution note on the unrestricted caller of create_new_account#732devtechedge wants to merge 1 commit into
devtechedge wants to merge 1 commit into
Conversation
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
Contributor
|
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. |
Contributor
There was a problem hiding this comment.
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:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
create_new_accountspends from a sharedrent_vaultPDA 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.
Testing
Comment-only change, no code touched.