Skip to main content

What Is the “Approve-and-Pull” Race Condition Vulnerability and How Can It Be Mitigated?

This vulnerability occurs when a user wants to change an existing allowance. If a user has an allowance of 100 and wants to reduce it to 50, they submit a transaction to approve 50.

A malicious contract could watch for this and, in the short time before the new transaction is mined, submit a transaction to spend the original 100. Then, once the new approval is mined, they could spend the new 50 as well, for a total of 150.

Mitigation involves setting the allowance to 0 first, then setting the new amount.

Can an External Attacker Exploit a Vulnerability in the Logic Contract before It Is Upgraded?
Could a ‘Fork’ of the Cryptocurrency to a New, Secure Algorithm Prevent a Total Economic Collapse of Its Ecosystem?
Does Setting an Allowance to Zero (Revoking) Cost the Same as Setting It to a Non-Zero Value?
Can a User Increase an Existing Allowance, and What Are the Security Implications?