Skip to main content

Can the CEI Pattern Prevent All Types of Reentrancy?

The Checks-Effects-Interactions (CEI) pattern is highly effective against the classic, direct reentrancy attack that drains funds. However, it cannot prevent all types.

It does not prevent "read-only" reentrancy, where the attacker calls back to read a stale state variable before the Effects step is complete. It also may not prevent cross-contract reentrancy in complex systems where Contract A calls B, which calls C, and C then calls back to A in an unexpected way.

For full protection, CEI is often paired with a reentrancy guard.

How Does a Read-Only Reentrancy Attack Differ from These Two Types?
What Security Vulnerability Is Associated with “Reentrancy” in Smart Contracts?
Does a Checksum Offer Protection against Malicious Attacks or Only Accidental Errors?
Provide a Simple Code Example of a Function Following the CEI Pattern