abi.encodePacked()
Can Cause Hash CollisionsThe contract uses abi.encodePacked()
inside the tokenURI
function when constructing the JSON metadata. While this is not directly used for hashing, using abi.encodePacked()
with multiple dynamic arguments can lead to ambiguous encoding issues if ever used in hashing or comparisons in future contract updates.
Hash collisions: If abi.encodePacked()
is used with multiple dynamic parameters and then hashed (e.g., with keccak256()
), different inputs can lead to the same hash.
Potential misinterpretation: While this doesn't directly introduce a security issue in tokenURI
, it's best practice to use abi.encode()
instead when working with multiple dynamic types.
This results in the same bytes output due to lack of padding, which can be exploited in scenarios involving hashed data verification.
Since abi.encodePacked()
is used only for string concatenation here, a safer approach is to use bytes.concat()
instead of abi.encodePacked()
.
bytes.concat()
explicitly handles dynamic types safely, reducing the risk of unexpected encoding issues.
It preserves clarity by handling individual strings as bytes
, avoiding encoding inconsistencies.
Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelyhood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.
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.