Specific Issue: The code uses abi.encodePacked()
to construct a details
string for informational purposes. While this string is not directly used in a hash function in the provided context, abi.encodePacked()
concatenates dynamic data types (like strings and toString()
outputs) without padding. This practice is inherently unsafe for any scenario where the concatenated output might later be used for hashing or unique identification, as different input combinations can result in identical packed outputs, leading to potential hash collisions.
Low
Root Cause: The use of abi.encodePacked()
to concatenate dynamic types for the details
string in src/OrderBook.sol
.
Solidity
Likelihood: Low
Impact: Low
Impact 1: If the details
string's usage changes in the future, and it is subsequently used as input for a hash function in a security-sensitive context (e.g., to generate a unique order hash, or for signature verification), then hash collisions could lead to severe logical errors, replay attacks, or data manipulation.
Impact 2: While not a direct exploit in its current form, it represents a "code smell" or bad practice. It deviates from recommended secure coding patterns for abi.encodePacked()
and could lead to confusion or subtle vulnerabilities if similar patterns are replicated in contexts where data integrity is paramount.
This PoC demonstrates how abi.encodePacked()
can lead to hash collisions due to a lack of padding, compared to abi.encode()
.
Solidity
While the direct impact is low for display-only purposes, it's best practice to avoid abi.encodePacked()
with dynamic types due to its known collision risks if the output is ever used in a hashing context. For concatenating strings for display, string.concat()
(available in Solidity 0.8.12+) is the most idiomatic and clear approach without introducing padding.
Diff
Reference Files
src/OrderBook.sol
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.