Auctioneer#auction stores routing data incorrectly which leads to loss of funds for sellers and bidders
Summary
The Auctioneer#auction function accepts routing data and stores it in the wrong storage slot, overwrites past data and results in loss of funds for all participants.
Vulnerability Detail
The Auctioneer#auction function is for starting a new auction, and accepts parameters from a seller. The routing parameters are fetched and then stored in the contract, in the variable lotRouting[lotId], where lotId is the new lot or auction's Id. This is iterated in the contract in Auctioneer#L194 (Link). However, the storage pointer to the variable is initialized much earlier in Auctioneer#L174 (Link).
This means that the routing parameters, including seller details and other inputted parameters are stored in lotRouting[0] at all times.
Impact
This results in a new auction always wiping out the routing data of the previous auction, and mismatch between the auction details stored in modules and the one stored in the Auctioneer/AuctionHouse contract. Therefore, funds are lost from all participants including the seller. Funds from older auctions get locked in the contract and can never be recovered.
devblixt
high
Auctioneer#auction stores routing data incorrectly which leads to loss of funds for sellers and bidders
Summary
The Auctioneer#auction function accepts routing data and stores it in the wrong storage slot, overwrites past data and results in loss of funds for all participants.
Vulnerability Detail
The Auctioneer#auction function is for starting a new auction, and accepts parameters from a seller. The routing parameters are fetched and then stored in the contract, in the variable lotRouting[lotId], where lotId is the new lot or auction's Id. This is iterated in the contract in Auctioneer#L194 (Link). However, the storage pointer to the variable is initialized much earlier in Auctioneer#L174 (Link).
This means that the routing parameters, including seller details and other inputted parameters are stored in lotRouting[0] at all times.
Impact
This results in a new auction always wiping out the routing data of the previous auction, and mismatch between the auction details stored in modules and the one stored in the Auctioneer/AuctionHouse contract. Therefore, funds are lost from all participants including the seller. Funds from older auctions get locked in the contract and can never be recovered.
Code Snippet
The affected code snippets are as follows :
The PoC to prove this vulnerability is as follows :
Please note that you will have to import console from the forge standard library to get console logs.
To test this, you can run
forge test --mt test_RoutingIncorectStorageSet -vv
Tool used
Manual Review
Recommendation
Iterate the lotCounter before the storage variable is initialized.
Duplicate of #12