skills/vulnerability-patterns/asserting-contract-from-code-size/SKILL.md
- Contract uses `extcodesize` or `address.code.length` to check whether an address is an EOA vs. a contract
npx skillsauth add apegurus/solidity-argus asserting-contract-from-code-sizeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
extcodesize or address.code.length to check whether an address is an EOA vs. a contractmodifier onlyEOA() {
// During constructor execution, extcodesize returns 0
// An attacker calling from their constructor bypasses this check
require(msg.sender.code.length == 0, "no contracts");
_;
}
function mint() external onlyEOA {
_mint(msg.sender, 1);
}
// Assembly variant
function isContract(address addr) internal view returns (bool) {
uint256 size;
assembly { size := extcodesize(addr) }
return size > 0; // Returns false during constructor
}
extcodesize, .code.length, or helper functions named isContractrequire(... == 0) to allow only EOAs)tx.origin == msg.sender as an alternative EOA check — flag it as incompatible with account abstraction (ERC-4337) and smart contract walletsextcodesize is used to check if a contract EXISTS at an address (not to distinguish EOA vs contract)isContract checks from security-critical paths// Instead of gating by caller type, use per-address limits
mapping(address => bool) public hasMinted;
function mint() external {
require(!hasMinted[msg.sender], "already minted");
hasMinted[msg.sender] = true;
_mint(msg.sender, 1);
}
testing
Specialist profile for mechanically applying the attack-vector deck and classifying vectors as skip, drop, or investigate.
tools
Specialist profile for libraries, helpers, base contracts, adapters, encoders, wrappers, and integration glue.
testing
Specialist profile for rounding, scale, decimal, downcast, and arithmetic accounting edge cases.
testing
Specialist profile for extracting conservation laws and state couplings, then searching for violating paths.