Seguridad

Reentrancy Guard

A protective pattern that prevents a program from being invoked recursively through cross-program invocations, mitigating reentrancy attacks. While the Solana runtime inherently prevents direct same-program reentrancy (a program cannot CPI into itself), indirect reentrancy through shared mutable accounts via third-party programs is still possible. Reentrancy guards typically use a flag in account state that is set at instruction entry and cleared at exit, causing reentrant calls to fail. Less critical on Solana than on EVM chains due to the runtime's built-in protection.

IDreentrancy-guard

Lectura rápida

Empieza por la explicación más corta y útil antes de profundizar.

A protective pattern that prevents a program from being invoked recursively through cross-program invocations, mitigating reentrancy attacks. While the Solana runtime inherently prevents direct same-program reentrancy (a program cannot CPI into itself), indirect reentrancy through shared mutable accounts via third-party programs is still possible. Reentrancy guards typically use a flag in account state that is set at instruction entry and cleared at exit, causing reentrant calls to fail. Less critical on Solana than on EVM chains due to the runtime's built-in protection.

Modelo mental

Usa primero la analogía corta para razonar mejor sobre el término cuando aparezca en código, docs o prompts.

Piensa en esto como un bloque de construcción que conecta una definición aislada con el sistema mayor donde vive.

Contexto técnico

Ubica el término dentro de la capa de Solana en la que vive para razonar mejor sobre él.

Fallos, auditorías, superficies de ataque y patrones seguros.

Por qué le importa a un builder

Convierte el término de vocabulario en algo operacional para producto e ingeniería.

Este término desbloquea conceptos adyacentes rápido, así que funciona mejor cuando lo tratas como un punto de conexión y no como una definición aislada.

Handoff para IA

Handoff para IA

Usa este bloque compacto cuando quieras dar contexto sólido a un agente o asistente sin volcar toda la página.

Reentrancy Guard (reentrancy-guard)
Categoría: Seguridad
Definición: A protective pattern that prevents a program from being invoked recursively through cross-program invocations, mitigating reentrancy attacks. While the Solana runtime inherently prevents direct same-program reentrancy (a program cannot CPI into itself), indirect reentrancy through shared mutable accounts via third-party programs is still possible. Reentrancy guards typically use a flag in account state that is set at instruction entry and cleared at exit, causing reentrant calls to fail. Less critical on Solana than on EVM chains due to the runtime's built-in protection.
Relacionados: Reentrancia (Solana), Invocación Entre Programas (CPI), Account Reloading Attack
Glossary Copilot

Haz preguntas de Solana con contexto aterrizado sin salir del glosario.

Usa contexto del glosario, relaciones entre términos, modelos mentales y builder paths para recibir respuestas estructuradas en vez de output genérico.

Abrir workspace completa del Copilot
Explicar este código

Opcional: pega código Anchor, Solana o Rust para que el Copilot mapee primitivas de vuelta al glosario.

Haz una pregunta aterrizada en el glosario

Haz una pregunta aterrizada en el glosario

El Copilot responderá usando el término actual, conceptos relacionados, modelos mentales y el grafo alrededor del glosario.

Grafo conceptual

Ve el término como parte de una red, no como una definición aislada.

Estas ramas muestran qué conceptos toca este término directamente y qué existe una capa más allá de ellos.

Rama

Reentrancia (Solana)

In Solana's context, reentrancy refers to a scenario during a CPI call where the called program invokes back into the calling program (direct reentrancy) or into a shared mutable account via a third program (indirect reentrancy), potentially causing the calling program to re-execute logic with state that has been partially modified by the intervening CPI. The Solana runtime prevents direct same-program reentrancy at the VM level — a program cannot CPI into itself — but indirect reentrancy through mutable shared accounts is possible and can cause account-reloading vulnerabilities where a program's cached account data becomes stale. Programs should reload account state after every CPI that may have modified shared accounts and avoid assuming pre-CPI state invariants hold afterward.

Rama

Invocación Entre Programas (CPI)

A mechanism for one program to call another program's instructions during execution. CPIs enable composability—e.g., a DeFi program can call the Token Program to transfer tokens. CPI depth is limited to 4 levels. The caller passes accounts and instruction data, and the callee runs with the same transaction context.

Rama

Account Reloading Attack

A vulnerability in Anchor programs where a program reads an account's data before making a CPI call, the CPI modifies that account's lamports or data, but the program continues using the stale pre-CPI snapshot instead of reloading the account from the runtime. In Anchor, after a CPI the account reference still holds the pre-call data unless account.reload() is explicitly called, meaning balance checks, state assertions, or further computation can operate on incorrect values. Attackers can exploit this to pass checks using an initial account state that the CPI subsequently invalidates.

Siguientes conceptos para explorar

Mantén la cadena de aprendizaje en movimiento en lugar de parar en una sola definición.

Estos son los siguientes conceptos que vale la pena abrir si quieres que este término tenga más sentido dentro de un workflow real de Solana.

Seguridad

Reentrancia (Solana)

In Solana's context, reentrancy refers to a scenario during a CPI call where the called program invokes back into the calling program (direct reentrancy) or into a shared mutable account via a third program (indirect reentrancy), potentially causing the calling program to re-execute logic with state that has been partially modified by the intervening CPI. The Solana runtime prevents direct same-program reentrancy at the VM level — a program cannot CPI into itself — but indirect reentrancy through mutable shared accounts is possible and can cause account-reloading vulnerabilities where a program's cached account data becomes stale. Programs should reload account state after every CPI that may have modified shared accounts and avoid assuming pre-CPI state invariants hold afterward.

Modelo de Programación

Invocación Entre Programas (CPI)

A mechanism for one program to call another program's instructions during execution. CPIs enable composability—e.g., a DeFi program can call the Token Program to transfer tokens. CPI depth is limited to 4 levels. The caller passes accounts and instruction data, and the callee runs with the same transaction context.

Seguridad

Account Reloading Attack

A vulnerability in Anchor programs where a program reads an account's data before making a CPI call, the CPI modifies that account's lamports or data, but the program continues using the stale pre-CPI snapshot instead of reloading the account from the runtime. In Anchor, after a CPI the account reference still holds the pre-call data unless account.reload() is explicitly called, meaning balance checks, state assertions, or further computation can operate on incorrect values. Attackers can exploit this to pass checks using an initial account state that the CPI subsequently invalidates.

Seguridad

Reinitialization Attack

A vulnerability where a program allows an already-initialized account to be initialized a second time, overwriting its state — including authority or ownership fields — with attacker-supplied data, effectively letting the attacker seize control of an existing account without going through normal privilege checks. The canonical defense is storing an is_initialized boolean or an Anchor discriminator in the account and asserting it is false (or that the discriminator is unset) at the start of every initialization instruction; Anchor's init constraint enforces this by failing if the account's discriminator is already non-zero.

Comúnmente confundido con

Términos cercanos en vocabulario, acrónimo o vecindad conceptual.

Estas entradas son fáciles de mezclar cuando lees rápido, haces prompting a un LLM o estás entrando en una nueva capa de Solana.

Seguridadreentrancy

Reentrancia (Solana)

In Solana's context, reentrancy refers to a scenario during a CPI call where the called program invokes back into the calling program (direct reentrancy) or into a shared mutable account via a third program (indirect reentrancy), potentially causing the calling program to re-execute logic with state that has been partially modified by the intervening CPI. The Solana runtime prevents direct same-program reentrancy at the VM level — a program cannot CPI into itself — but indirect reentrancy through mutable shared accounts is possible and can cause account-reloading vulnerabilities where a program's cached account data becomes stale. Programs should reload account state after every CPI that may have modified shared accounts and avoid assuming pre-CPI state invariants hold afterward.

Términos relacionados

Sigue los conceptos que realmente le dan contexto a este término.

Las entradas del glosario se vuelven útiles cuando están conectadas. Estos enlaces son el camino más corto hacia ideas adyacentes.

Seguridadreentrancy

Reentrancia (Solana)

In Solana's context, reentrancy refers to a scenario during a CPI call where the called program invokes back into the calling program (direct reentrancy) or into a shared mutable account via a third program (indirect reentrancy), potentially causing the calling program to re-execute logic with state that has been partially modified by the intervening CPI. The Solana runtime prevents direct same-program reentrancy at the VM level — a program cannot CPI into itself — but indirect reentrancy through mutable shared accounts is possible and can cause account-reloading vulnerabilities where a program's cached account data becomes stale. Programs should reload account state after every CPI that may have modified shared accounts and avoid assuming pre-CPI state invariants hold afterward.

Modelo de Programacióncpi

Invocación Entre Programas (CPI)

A mechanism for one program to call another program's instructions during execution. CPIs enable composability—e.g., a DeFi program can call the Token Program to transfer tokens. CPI depth is limited to 4 levels. The caller passes accounts and instruction data, and the callee runs with the same transaction context.

Seguridadaccount-reloading

Account Reloading Attack

A vulnerability in Anchor programs where a program reads an account's data before making a CPI call, the CPI modifies that account's lamports or data, but the program continues using the stale pre-CPI snapshot instead of reloading the account from the runtime. In Anchor, after a CPI the account reference still holds the pre-call data unless account.reload() is explicitly called, meaning balance checks, state assertions, or further computation can operate on incorrect values. Attackers can exploit this to pass checks using an initial account state that the CPI subsequently invalidates.

Más en la categoría

Quédate en la misma capa y sigue construyendo contexto.

Estas entradas viven junto al término actual y ayudan a que la página se sienta parte de un grafo de conocimiento más amplio en lugar de un callejón sin salida.

Seguridad

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.

Seguridad

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.

Seguridad

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.

Seguridad

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.