sherlock-audit / 2022-09-knox-judging

0 stars 0 forks source link

hansfriese - `Auction.getEpochsByBuyer()` might omit some valid epochs. #143

Closed sherlock-admin closed 1 year ago

sherlock-admin commented 1 year ago

hansfriese

medium

Auction.getEpochsByBuyer() might omit some valid epochs.

Summary

Auction.getEpochsByBuyer() might omit some valid epochs.

Vulnerability Detail

Auction.getEpochsByBuyer() might omit some valid epochs.

Currently, epochsByBuyer is saved using UintSet here, and the epoch will be saved only once even if the buyer added several orders on the same epoch.

So the below scenario would be possible.

Impact

Auction.getEpochsByBuyer() might output less epochs than it should.

Code Snippet

Tool used

Manual Review

Recommendation

I think we should use mapping instead of UintSet here to track the total number of active orders for each buyer.

Then Auction.getEpochsByBuyer() can output the epochs that contain at least one active order.

Duplicate of #86