Unused Like Struct (Lack of Historical Like Data)
Description:
The contract defines a Like
struct:
However, this struct is never actually used or stored in the contract. While the likeUser
function records likes in the likes
mapping, it does not save timestamps. This means:
There is no way to track when a like occurred.
Future features relying on historical data (e.g., "Who liked me in the past week?", "Anniversay of the first like") will not work.
Potential auditing, analytics, or refund mechanisms become impossible.
Impact:
Loss of Time-Based Features:
Dating apps often use time-based algorithms (e.g., "Most liked users today").
Without timestamps, such features cannot be implemented.
Poor User Experience & Analytics:
Users cannot see a history of who liked them and when.
Admins cannot generate engagement reports.
Limits Future Expansions:
If the project later introduces like-based ranking (e.g., "Trending Profiles"), the missing timestamps will require a major contract upgrade.
Proof of Concept:
Consider the following scenario:
Alice likes Bob.
Bob wants to see who liked him in the past 24 hours, but there is no timestamp to filter recent likes.
A feature like getRecentLikes(address user, uint256 timeframe)
cannot be implemented.
Code Analysis:
The struct exists:
But likeUser
does not store it anywhere:
This means only a boolean is stored, losing critical information.
Recommended Mitigation:
1. Store the Like Struct in a Mapping
Instead of just using a bool
, modify likes
to store a Like
struct:
Update likeUser
to store the timestamp:
2. Add a Function to Retrieve Like History
Introduce a function to fetch like details:
3. Enable Time-Based Filtering for Future Features
Now, we can build functions like:
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.