Security

Closing Accounts Vulnerability

A vulnerability that arises when a program closes an account by zeroing its data and transferring lamports without setting the account's discriminator or data to a sentinel closed state before the end of the instruction, leaving a window within the same transaction where other instructions can still interact with the now-empty account. The Solana runtime only removes an account from the account set when its lamports reach zero at the end of a transaction, so mid-transaction the account still exists and a subsequent instruction can re-fund it and reinstate stale data, enabling an account revival attack. Anchor's close constraint writes a CLOSED_ACCOUNT_DISCRIMINATOR (8 bytes of 0xff) and uses a force-defund mechanism to prevent resurrection.

IDclosing-accounts

Plain meaning

Start with the shortest useful explanation before going deeper.

A vulnerability that arises when a program closes an account by zeroing its data and transferring lamports without setting the account's discriminator or data to a sentinel closed state before the end of the instruction, leaving a window within the same transaction where other instructions can still interact with the now-empty account. The Solana runtime only removes an account from the account set when its lamports reach zero at the end of a transaction, so mid-transaction the account still exists and a subsequent instruction can re-fund it and reinstate stale data, enabling an account revival attack. Anchor's close constraint writes a CLOSED_ACCOUNT_DISCRIMINATOR (8 bytes of 0xff) and uses a force-defund mechanism to prevent resurrection.

Mental model

Use the quick analogy first so the term is easier to reason about when you meet it in code, docs, or prompts.

Think of it as a building block that connects one definition to the larger Solana system around it.

Technical context

Place the term inside its Solana layer so the definition is easier to reason about.

Failure modes, audits, attack surfaces, and safe design patterns.

Why builders care

Turn the term from vocabulary into something operational for product and engineering work.

This term unlocks adjacent concepts quickly, so it works best when you treat it as a junction instead of an isolated definition.

AI handoff

AI handoff

Use this compact block when you want to give an agent or assistant grounded context without dumping the entire page.

Closing Accounts Vulnerability (closing-accounts)
Category: Security
Definition: A vulnerability that arises when a program closes an account by zeroing its data and transferring lamports without setting the account's discriminator or data to a sentinel closed state before the end of the instruction, leaving a window within the same transaction where other instructions can still interact with the now-empty account. The Solana runtime only removes an account from the account set when its lamports reach zero at the end of a transaction, so mid-transaction the account still exists and a subsequent instruction can re-fund it and reinstate stale data, enabling an account revival attack. Anchor's close constraint writes a CLOSED_ACCOUNT_DISCRIMINATOR (8 bytes of 0xff) and uses a force-defund mechanism to prevent resurrection.
Related: Close Account, Rent, Account Revival Attack
Glossary Copilot

Ask grounded Solana questions without leaving the glossary.

Use glossary context, relationships, mental models, and builder paths to get structured answers instead of generic chat output.

Explain this code

Optional: paste Anchor, Solana, or Rust code so the Copilot can map primitives back to glossary terms.

Ask a glossary-grounded question

Ask a glossary-grounded question

The Copilot will answer using the current term, related concepts, mental models, and the surrounding glossary graph.

Concept graph

See the term as part of a network, not a dead-end definition.

These branches show which concepts this term touches directly and what sits one layer beyond them.

Branch

Close Account

The process of reclaiming an account's lamports and marking it for deletion. To close an account: transfer all lamports to a recipient, zero out the data, and (in Anchor) set the discriminator to a closed sentinel. The runtime garbage-collects zero-lamport accounts. Failing to zero data enables revival attacks.

Branch

Rent

A fee mechanism that charges accounts for storing data on-chain. Accounts must maintain a minimum lamport balance proportional to their data size (~6.96 SOL per MB) to be rent-exempt. Since 2022, all new accounts must be rent-exempt at creation. Accounts falling below the threshold are removed during rent collection.

Branch

Account Revival Attack

An exploit that resurrects an account that a program has logically closed within the same transaction by sending lamports back to it before the transaction finalizes, causing its on-chain data — which was never securely wiped — to re-appear as a funded, seemingly valid account in future transactions. Because the Solana runtime keeps an account alive as long as it holds any lamports, transferring even 1 lamport back to a closed-but-not-wiped account prevents its deletion and allows an attacker to reuse its stale state. The defense is to explicitly overwrite account data with a closed discriminator and to use force-defund patterns so any lamports transferred in during the same transaction are immediately drained.

Next concepts to explore

Keep the learning chain moving instead of stopping at one definition.

These are the next concepts worth opening if you want this term to make more sense inside a real Solana workflow.

Programming Model

Close Account

The process of reclaiming an account's lamports and marking it for deletion. To close an account: transfer all lamports to a recipient, zero out the data, and (in Anchor) set the discriminator to a closed sentinel. The runtime garbage-collects zero-lamport accounts. Failing to zero data enables revival attacks.

Programming Model

Rent

A fee mechanism that charges accounts for storing data on-chain. Accounts must maintain a minimum lamport balance proportional to their data size (~6.96 SOL per MB) to be rent-exempt. Since 2022, all new accounts must be rent-exempt at creation. Accounts falling below the threshold are removed during rent collection.

Security

Account Revival Attack

An exploit that resurrects an account that a program has logically closed within the same transaction by sending lamports back to it before the transaction finalizes, causing its on-chain data — which was never securely wiped — to re-appear as a funded, seemingly valid account in future transactions. Because the Solana runtime keeps an account alive as long as it holds any lamports, transferring even 1 lamport back to a closed-but-not-wiped account prevents its deletion and allows an attacker to reuse its stale state. The defense is to explicitly overwrite account data with a closed discriminator and to use force-defund patterns so any lamports transferred in during the same transaction are immediately drained.

Security

Denial of Service (DoS)

A class of attacks that prevent legitimate users from successfully executing transactions against a Solana program, either by exhausting the compute budget (e.g., triggering O(n) iteration over an unbounded on-chain list to force CU exhaustion), filling an account's allocated space to block appends, or exploiting program logic to cause systematic transaction failure. On Solana, each transaction has a compute budget cap of 1.4 million CUs by default (extendable to 1.4 million via ComputeBudgetInstruction), so programs that loop over caller-controlled data sizes are vulnerable. Mitigations include bounding all on-chain collections, paginating iteration, and preferring off-chain indexing over on-chain enumeration.

Commonly confused with

Terms nearby in vocabulary, acronym, or conceptual neighborhood.

These entries are easy to mix up when you are reading quickly, prompting an LLM, or onboarding into a new layer of Solana.

Securityduplicate-mutable-accounts

Duplicate Mutable Accounts

A vulnerability where the same account is passed twice in the accounts list for a single instruction under different argument names, and the program writes to what it believes are two independent accounts, with the second write silently overwriting the first on the single underlying account in the runtime's account map. For example, if from and to in a transfer handler reference the same key, debiting from and crediting to nets out to a free credit. In native programs the check requires comparing account keys; Anchor automatically detects duplicate mutable accounts and returns an error when the same pubkey appears more than once in writable positions within a single instruction's account list.

Securityremaining-accounts

Remaining Accounts Misuse

A vulnerability arising from the use of ctx.remaining_accounts in Anchor (or unchecked trailing accounts in native programs), where accounts passed beyond the explicitly declared account struct are not subject to any automatic owner, signer, or constraint checks, leaving it entirely to the program to validate them. Attackers can exploit this by injecting unexpected accounts — fake mints, unauthorized signers, or accounts owned by a malicious program — that the program then treats as trusted inputs. Programs using remaining_accounts must manually verify every account's key, owner, is_signer, and is_writable properties before use, making this pattern a frequent audit finding.

Securityvulnerability-disclosure

Vulnerability Disclosure

Process of responsibly reporting security flaws to affected parties before public disclosure. Solana has a bug bounty program through Immunefi, and most major protocols maintain responsible disclosure policies. Coordinated disclosure gives teams time to patch vulnerabilities before exploitation.

Related terms

Follow the concepts that give this term its actual context.

Glossary entries become useful when they are connected. These links are the shortest path to adjacent ideas.

Programming Modelclose-account

Close Account

The process of reclaiming an account's lamports and marking it for deletion. To close an account: transfer all lamports to a recipient, zero out the data, and (in Anchor) set the discriminator to a closed sentinel. The runtime garbage-collects zero-lamport accounts. Failing to zero data enables revival attacks.

Programming Modelrent

Rent

A fee mechanism that charges accounts for storing data on-chain. Accounts must maintain a minimum lamport balance proportional to their data size (~6.96 SOL per MB) to be rent-exempt. Since 2022, all new accounts must be rent-exempt at creation. Accounts falling below the threshold are removed during rent collection.

Securityrevival-attack

Account Revival Attack

An exploit that resurrects an account that a program has logically closed within the same transaction by sending lamports back to it before the transaction finalizes, causing its on-chain data — which was never securely wiped — to re-appear as a funded, seemingly valid account in future transactions. Because the Solana runtime keeps an account alive as long as it holds any lamports, transferring even 1 lamport back to a closed-but-not-wiped account prevents its deletion and allows an attacker to reuse its stale state. The defense is to explicitly overwrite account data with a closed discriminator and to use force-defund patterns so any lamports transferred in during the same transaction are immediately drained.

More in category

Stay in the same layer and keep building context.

These entries live beside the current term and help the page feel like part of a larger knowledge graph instead of a dead end.

Security

Missing Signer Check

A vulnerability where a program accepts an account in a privileged role (e.g., admin, authority, payer) without verifying that the account actually signed the transaction, allowing any caller to impersonate that authority by simply passing the target pubkey as an instruction account. In native Solana programs, the check requires asserting account.is_signer == true; in Anchor, the Signer<'info> type enforces this automatically. Exploitation lets an attacker bypass all access control gated on authority equality checks, making it one of the most critical and commonly audited vulnerabilities in Solana programs.

Security

Missing Owner Check

A vulnerability where a program deserializes and trusts account data without first confirming that the account is owned by the expected program, allowing an attacker to substitute a maliciously crafted account owned by a different program whose byte layout happens to satisfy the deserialization. On Solana, every account stores a 32-byte owner field set to the program that created it; native programs must assert account.owner == &expected_program_id, while Anchor's Account<'info, T> wrapper performs this check automatically. Failure to validate ownership can lead to complete auth bypass if an attacker can construct a fake account whose data parses into a struct with elevated privileges.

Security

Arbitrary CPI

A vulnerability where a program accepts an arbitrary program account from the caller and invokes it via Cross-Program Invocation (CPI) without verifying it matches a known, trusted program ID, effectively letting an attacker substitute a malicious program that executes under the victim program's authority or manipulates accounts the victim program passes to it. A common pattern is accepting a token_program account without checking it equals spl_token::ID, so the attacker passes a lookalike program that records or drains account data. Prevention requires hard-coding or explicitly checking the program ID before every CPI call.

Security

PDA Substitution Attack

A vulnerability where a program derives a PDA internally but accepts an externally supplied account as that PDA without re-deriving and comparing the address, allowing an attacker to pass a different PDA (derived from attacker-controlled seeds) that the program will treat as legitimate. Because PDAs are deterministic, the only way to guarantee account identity is to call Pubkey::find_program_address (or equivalent) with the expected seeds inside the program and assert the result equals the supplied key. Anchor's seeds and bump constraints on the Account type automate this re-derivation and equality check.