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 Do Decentralized Exchanges (DEXs) Mitigate Reentrancy Risks in Their Swap Functions?
How Can Reentrancy Attacks Be Prevented in Smart Contracts?
Can a Coin with High Difficulty Still Be Vulnerable to Other Types of Attacks?
What Security Vulnerability Is Associated with “Reentrancy” in Smart Contracts?
How Does a Read-Only Reentrancy Attack Differ from These Two Types?
Can the CEI Pattern Be Applied to Other Security Vulnerabilities besides Reentrancy?
Does a Checksum Offer Protection against Malicious Attacks or Only Accidental Errors?
Provide a Simple Code Example of a Function Following the CEI Pattern

Glossar