skills/vulnerability-patterns/hash-collision/SKILL.md
- Contract uses `abi.encodePacked()` to encode data before hashing (typically with `keccak256`)
npx skillsauth add apegurus/solidity-argus hash-collisionInstall 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.
abi.encodePacked() to encode data before hashing (typically with keccak256)encodePacked call are variable-length types (strings, bytes, dynamic arrays)function verify(string memory a, string memory b, bytes memory sig) external {
// abi.encodePacked("a", "bc") == abi.encodePacked("ab", "c")
// Attacker shifts bytes between arguments to forge a valid hash
bytes32 hash = keccak256(abi.encodePacked(a, b));
require(ECDSA.recover(hash, sig) == trustedSigner);
_execute(a, b);
}
// Array variant:
// abi.encodePacked([addr1, addr2], [addr3])
// == abi.encodePacked([addr1], [addr2, addr3])
abi.encodePacked( callsaddress[], uint256[])keccak256 for security-sensitive purposes (signature verification, access control, deduplication)abi.encode() is used instead of abi.encodePacked() (includes length prefixes, no collision)abi.encodePacked() with abi.encode() — it includes length prefixes that prevent collisionsencodePacked must be used for gas efficiency, ensure at most one argument is a variable-length type// Safe: abi.encode includes length prefixes
bytes32 hash = keccak256(abi.encode(a, b));
// Also safe: only one variable-length argument
bytes32 hash = keccak256(abi.encodePacked(fixedAddr, dynamicString));
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.