In ./src/OrderBook.sol
, the OrderBook::getOrderDetailsString(uint256 _orderId)
function uses abi.encodePacked()
to concatenate various dynamic and static values (strings, addresses, numbers) into a single details
string, which is returned for off-chain or UI usage.
However, using abi.encodePacked()
with multiple dynamic types (e.g., string
, bytes
) or mixed with static types can lead to hash collisions if the resulting string is ever hashed (e.g., with keccak256
) for uniqueness, authentication, or digital signatures. This behavior introduces a silent vulnerability if developers assume the string is safe to hash.
File | Function | Lines | Note |
---|---|---|---|
./src/OrderBook.sol |
getOrderDetailsString |
L221āL272 | Vulnerable use of abi.encodePacked() with mixed dynamic types |
This issue occurs when abi.encodePacked()
is used with a combination of dynamic types (string
, bytes
) and static types in the same call.
It becomes exploitable when the resulting data is passed to a hash function such as keccak256
, especially for signing, commitment, or uniqueness guarantees.
Hash collisions may occur, causing different input values to produce the same hash output.
If the details
string is used in off-chain signing, commitment schemes, or message verification, an attacker could spoof valid messages or break integrity checks.
š” Status: Present but Could Be More Instructive
The PoC shows a basic hash collision:
While correct, it lacks context. This matters if the resulting string is hashed (e.g., keccak256(bytes(details))
) for signatures or commit-reveal logic. An attacker could craft different inputs that produce the same hash, bypassing integrity checks or forging valid-looking data.
š Note:
abi.encode()
produces non-UTF-8 padded bytes. If this string is intended purely for human-readable output, consider usingbytes.concat()
instead for proper formatting:
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.