Mythril is a security analysis tool for EVM bytecode that uses symbolic execution to explore many execution paths at once. It is particularly good at low-level bug classes such as reentrancy, unchecked external calls and integer issues. This guide explains reentrancy from The DAO to read-only reentrancy, then shows how to run Mythril and interpret its findings.

What reentrancy actually is
Reentrancy happens when a contract makes an external call before it updates its own state. The external callee can call back into the original function while the old state still applies, repeating an action — classically, withdrawing the same balance several times.
// Vulnerable pattern: external call before state update
function withdraw() public {
uint256 amount = balances[msg.sender];
(bool ok, ) = msg.sender.call{value: amount}(""); // external call first
require(ok);
balances[msg.sender] = 0; // state updated too late
}
Because balances[msg.sender] is only zeroed after the call returns, a malicious contract’s receive() can call withdraw() again while its balance still reads the original amount.
The checks-effects-interactions fix
function withdraw() public {
uint256 amount = balances[msg.sender];
balances[msg.sender] = 0; // effect first
(bool ok, ) = msg.sender.call{value: amount}(""); // interaction last
require(ok);
}
Update state before the external call, and optionally add a reentrancy guard. Note that a guard on one function does not stop cross-function or read-only reentrancy, where a view function used by another protocol returns stale values mid-transaction.
Installing Mythril
# pip
pip install mythril
# Docker
docker pull mythril/myth
myth version
Running an analysis
# Analyse a Solidity source file (choose the compiler version)
myth analyze contracts/Vault.sol --solv 0.8.21
# Analyse already-deployed bytecode
myth analyze -a 0xYourContractAddress --rpc infura-mainnet
# Increase exploration depth for deeper paths
myth analyze contracts/Vault.sol --solv 0.8.21 --max-depth 32 -t 3
The -t flag sets the number of transactions Mythril chains together; many stateful bugs only appear after two or three transactions, so raising it finds more at the cost of time.
Reading the output
Mythril reports findings with a SWC identifier (Smart Contract Weakness Classification), the function and a sample transaction trace. Common ones:
| SWC | Issue | Meaning |
|---|---|---|
| SWC-107 | Reentrancy | External call before state change. |
| SWC-104 | Unchecked call return value | Low-level call result ignored. |
| SWC-101 | Integer over/underflow | Mostly historical since Solidity 0.8 checks by default. |
| SWC-105 | Unprotected ether withdrawal | Missing access control on a withdrawal. |
Symbolic execution explores many paths but can produce false positives and cannot reason about business logic or economic attacks. Treat Mythril as one layer: combine it with Slither static analysis, Echidna fuzzing and manual review.
Using Mythril in CI
# Fail the build if an issue at or above a severity is found
myth analyze contracts/Vault.sol --solv 0.8.21 -o json > myth.json
# then parse myth.json in your pipeline and gate on severity
Key takeaways
- Reentrancy is caused by an external call before a state update — fix with checks-effects-interactions.
- A reentrancy guard does not stop cross-function or read-only reentrancy.
- Raise
-t(transaction count) to catch stateful bugs that need several calls. - Mythril is one layer of an audit, not a replacement for manual review.
Frequently asked questions
What is reentrancy in Solidity?
Reentrancy happens when a contract makes an external call before updating its own state, allowing the callee to call back into the contract and act on stale state — for example withdrawing the same balance several times.
Does Mythril replace a manual audit?
No. Mythril explores execution paths automatically and is excellent for low-level bugs, but it cannot understand business logic, economic attacks or cross-protocol assumptions. Use it as one layer of a full audit.
Is ReentrancyGuard enough to prevent reentrancy?
It blocks re-entering functions protected by the same guard, but not cross-contract or read-only reentrancy. Combine checks-effects-interactions, guards and careful review of view functions used by other protocols.
