🚀 Join our AI Wargame at Black Hat Asia and our Workshop + Wargame at NDC Sydney .

Hash Collision

A hash collision occurs when multiple distinct inputs produce the same hash value or map to the same hash bucket. In adversarial contexts (on-chain tables, maps or hash tables), an attacker who can craft many colliding keys can concentrate operations on a single bucket, driving up compute/gas cost and causing insertion/lookup failures. This is a pure collision problem — not a logic bug in higher layers — where the attack surface is the mapping from input → bucket.

Remediation

  • Use a collision-resistant hash for bucket assignment where adversarial inputs are possible (e.g., Keccak256 / SHA-256 / BLAKE2).
  • Prevent attacker control of the hash seed/salt; derive any seed from contract-controlled, non-influenceable entropy.
  • Limit per-bucket growth: enforce bucket size caps, per-caller insertion quotas, or per-tx insertion limits to bound worst-case cost.
  • Design table operations to be incremental and gas-bounded (avoid single transactions that must traverse an unbounded bucket).
  • Add on-chain detection and fail-safe behaviour: if a bucket exceeds thresholds, reject further inserts and surface an alertable event rather than attempting expensive processing.
  • Apply economic friction for bulk inserts (fees, stake or collateral) so mass collision creation becomes costly.

Metadata

  • Severity: medium
  • Slug: hash-collision

CWEs

  • 327: Use of a Broken or Risky Cryptographic Algorithm
  • 328: Use of Weak Hash

OWASP

  • SC09:2025: Insecure Randomness

Available Labs

Select a language to explore available labs for this vulnerability.

No matching labs found

Try adjusting your language filter.

Try it yourself

Find, Hack and Fix Your First Vulnerability

Reading about security bugs is one thing — fixing one is how the skill sticks. Play a free challenge from the wargame, no setup required.