What is symbolic execution in smart contracts?
Symbolic execution analyzes a contract by running its functions on symbolic values, such as a and b, instead of concrete numbers (ethereum.org). At each branch it records the condition needed to go each way, and a constraint solver then says whether a path to a failing assertion is possible and, if it is, returns inputs that take it.
How does symbolic execution find a bug?
In the function below, random inputs would need to land on a pair where b is exactly 2a + 12345 with a above 1,000, which almost never happens. Symbolic execution reads that condition off the branch and solves it directly, returning for example a = 1001 and b = 14347.
A failure behind a narrow branch condition (illustrative, not audited code) HiddenPath.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;
contract HiddenPath {
bool public broken;
function poke(uint256 a, uint256 b) external {
if (a > 1000 && a < 2 ** 128 && b == a * 2 + 12345) {
broken = true; // the state no test was meant to reach
}
assert(!broken);
}
}
Which tools use symbolic execution?
Mythril describes itself as a symbolic-execution-based security analysis tool for EVM bytecode (Mythril), and ethereum.org also lists Manticore and hevm as symbolic execution tools (ethereum.org). Trail of Bits lists Halmos, with Certora and KEVM, among formal verification tools (Trail of Bits).
What are its limits?
Each branch can double the number of paths, so loops and long call sequences cause path explosion, and tools cap how deep they go. Hashes such as keccak256 of an input are hard for a solver to invert, and calls to unknown contracts have to be modeled. A path the tool didn't explore is not a path proved safe, which is the difference from formal verification against a full specification.
- Use it on functions with narrow branch conditions that fuzzing keeps missing.
- Keep the target bounded: few loops and no unknown external calls.
- Turn each counterexample into a regular test, so the bug stays fixed.
Sources
- Formal verification of smart contracts, ethereum.org checked 3 December 2026
- Mythril, Consensys (GitHub) checked 3 December 2026
- The call for invariant-driven development, Trail of Bits checked 3 December 2026