Liquid Staking

Stakelink
DeFiHardhatOracle
50,000 USDC
View results
Submission Details
Severity: medium
Invalid

Non-Deterministic Behavior: The resulting hash may not always be consistent across different runs or environments due to the ambiguous nature of ` abi.encodePacked() `

Summary

**abi.encodePacked() **removes padding between elements, which can lead to ambiguity in the encoded data. When combining two identical arrays, the order becomes significant, potentially causing unexpected results.

Due to the lack of padding, there's a possibility of hash collisions. Different inputs could potentially produce the same hash output

Vulnerability Details

Hash Collision Vulnerability: This approach can create vulnerabilities that malicious actors might exploit, especially if the contract interacts with off-chain systems expecting unique hashes

Impact

**abi.encodePacked() **doesn't add padding between elements, which can cause ambiguity in the encoded data

Tools Used

none

Recommendations

To avoid potential duplicate hashes, consider using abi.encode() instead of abi.encodePacked()

for (uint height = 0; height < DEPOSIT_CONTRACT_TREE_DEPTH - 1; height++)
zero_hashes[height + 1] = sha256(
abi.encode(zero_hashes[height], zero_hashes[height])
);
Updates

Lead Judging Commences

inallhonesty Lead Judge 8 months ago
Submission Judgement Published
Invalidated
Reason: Out of scope

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.