In the GivingThanks
contract, the function _createTokenURI
uses abi.encodePacked()
to generate a JSON metadata string. While this usage does not currently introduce a vulnerability since it's used only for string
concatenation, using abi.encodePacked()
with dynamic types (e.g., string
or bytes
) can lead to potential hash collisions, especially if this data were to be hashed with keccak256()
. The concern arises because abi.encodePacked() lacks delimiter information for concatenated dynamic types, which can create ambiguity in the final encoded string
. This could lead to potential vulnerabilities in the future if further dynamic data is added or if the encoded result is used as a hash key.
If dynamic data were added or this approach were modified to use keccak256
for hashing the abi.encodePacked()
result, it could allow for hash collisions, leading to potential exploits or logic errors. This could affect metadata uniqueness, token ownership, or the integrity of the data stored.
Consider a hypothetical case where the JSON metadata format is extended to include a string description or other dynamic content. If multiple dynamic fields are concatenated and then hashed, it could be possible to produce the same hash for different data, causing potential data integrity issues.
Example:
Avoid abi.encodePacked()
for Concatenating Dynamic Types: Use abi.encode()
instead to provide type separation and avoid potential ambiguity in encoding.
Enforce String Encoding Standards: If additional dynamic types are added, consider adding explicit delimiters between fields or using structured data encoding formats such as abi.encode
to prevent concatenation ambiguities.
Hash Individual Fields Separately: If hashing is required, hash individual fields or use structured encoding functions.
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.