SCWE-121: Swallowed Revert Reasons
Stable Version v1.0
This content is in the version-(v1.0) and still under active development, so it is subject to change any time (e.g. structure, IDs, content, URLs, etc.).
Relationships¶
- CWE-388: Error Handling
https://cwe.mitre.org/data/definitions/388.html
Description¶
Ignoring revert data (e.g., using require(ok) without bubbling reason) hides the root cause of failures. Protocols may proceed under incorrect assumptions, misprice risk, or block user funds without actionable errors.
Remediation¶
- Bubble revert reasons from external calls (
(bool ok, bytes memory data), thenassembly { revert(add(data,32), mload(data)) }when!ok). - Standardize error handling with custom errors and propagate upstream.
- Emit diagnostics when external calls fail to aid monitoring.
Examples¶
Vulnerable¶
pragma solidity ^0.8.0;
(bool ok, ) = target.call(payload);
require(ok, "call failed"); // hides real reason