Protocol Security Cluster

Deep DiveUpdated Mar 29, 2026

Reentrancy Attack Analysis

This page explains why reentrancy remains a modern protocol-design problem even when teams know the classic pattern. It focuses on call-order discipline, bounded external interactions, invariant-based monitoring, and containment decisions that stop one unsafe execution loop from becoming systemic loss.

Published: Updated: Cluster: Protocol Security

Within this cluster

Why Is Reentrancy Still Relevant in Modern Protocols?

Teams often think of reentrancy as a solved 2019 problem until they ship composable execution with new hooks, callbacks, or asset flows that recreate the same vulnerability shape in a more complex form. The risk is not the label. The risk is that external control returns before the protocol’s own state is safely finalized.

Reentrancy Risk Areas
AreaMain failurePrimary defense
Balance-changing flowsState updates after external callFinalize state before external interaction
Hooked composabilityUnexpected callback chainsBound and isolate trusted call paths
Shared accountingCross-function state inconsistencyInvariant checks across function families
Emergency operationsContainment lags behind exploit loopFast scoped pause and rollback planning

What Should Teams Harden First?

Start with external-call review. Every value-moving, permission-moving, or state-sensitive path should prove that state is resolved before outside execution resumes. Reentrancy guards help, but they are secondary to correct state ordering.

  • Finalize accounting before external transfers or callbacks.
  • Reduce unnecessary external call surfaces.
  • Apply reentrancy guards where state ordering alone is insufficient.
  • Model invariants across function families, not just one function in isolation.
{
  "function": "withdraw",
  "stateFinalizedBeforeCall": true,
  "externalCallPresent": true,
  "guardEnabled": true,
  "invariantLinked": "total_assets_match_liabilities"
}
Reentrancy defense flow with state finalization, external call boundary, invariant checks, and containment
Modern reentrancy defense depends on safe call order plus invariants that confirm no unsafe state transition slipped through.

Which Signals Matter During Live Monitoring?

Runtime signals should detect recursive execution bursts, invariant divergence, unusual callback depth, and repeated failure patterns near sensitive accounting transitions.

  • Unexpected recursion depth on protected function families.
  • Asset/liability invariant mismatch after callback-heavy flows.
  • Rapid sequence of reverts and retries around the same action path.
  • Function combinations that never normally appear together inside one execution window.

How Should Teams Respond If Reentrancy Is Suspected?

Move quickly to isolate the affected path, preserve evidence, and contain blast radius through scoped emergency controls. Then validate which invariant actually failed before reopening.

  1. Freeze or scope-pause the affected function family.
  2. Preserve traces and affected state snapshots.
  3. Confirm the exploit path and broken invariant.
  4. Resume only after patched call order and verified invariant health.

Frequently Asked Questions

Is a reentrancy guard always enough?

No. Guards help, but teams still need correct state sequencing, bounded external calls, and invariants that prove funds and permissions remain safe across complex flows.

What is the best first hardening step?

Review every external call path and verify state is finalized before value-moving or control-moving interactions occur.