skills/vulnerability-patterns/assert-violation/SKILL.md
- Contract uses `assert()` statements
npx skillsauth add apegurus/solidity-argus assert-violationInstall 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.
assert() statementsassert condition can be reached through valid program execution (not a true invariant)assert() is used to validate user input or external call results instead of require()function transfer(address to, uint256 amount) external {
// WRONG: assert used for input validation — should be require
// In Solidity <0.8.0, this consumes ALL remaining gas on failure
assert(balances[msg.sender] >= amount);
balances[msg.sender] -= amount;
balances[to] += amount;
}
function withdraw() external {
uint256 bal = balances[msg.sender];
balances[msg.sender] = 0;
(bool success,) = msg.sender.call{value: bal}("");
// WRONG: assert used to check external call result
assert(success);
}
assert( calls in the codebaserequire() insteadassert uses the 0xfe INVALID opcode and consumes ALL remaining gas; in >=0.8.0, it reverts with Panic(uint256) error code 0x01 (refunds remaining gas but provides no custom message)assert can be triggered by an attacker, check if the gas consumption creates a griefing vectorassert checks a genuine invariant (e.g., assert(totalSupply == sumOfAllBalances) after a provably correct operation)require() for input validation and external call checks — it refunds remaining gas and accepts an error messageassert() only for invariant checks that should never fail in a correct contractrequire for gas-efficient error handling// Correct: require for input validation
function transfer(address to, uint256 amount) external {
require(balances[msg.sender] >= amount, "insufficient balance");
balances[msg.sender] -= amount;
balances[to] += amount;
// assert is appropriate here: totalSupply should never change during transfer
assert(balances[msg.sender] + balances[to] == oldSum);
}
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.