Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

Latest commit

 

History

History
23 lines (17 loc) · 2.02 KB

206.md

File metadata and controls

23 lines (17 loc) · 2.02 KB

seerether

high

Corrupted or inconsistent price data due to full slot or incorrect addition of new data to slot

Summary

In the setNewToken function, when a new token is added, the code determines whether the token is stable or not and then appends the new price to the corresponding price slot (tokenPriceStable or tokenPriceNS). However, there are no checks to ensure that the new price is inserted at the correct position within the slot or that the slot has enough capacity to accommodate the new price.

Vulnerability Detail

In the setNewToken function, the new token's price information is stored in the state.tokenMMInfoMap[token] mapping, and the token's index is recorded in the state.priceListInfo.tokenIndexMap[token] mapping. The token's price is then added to the appropriate price slot based on its stability (stableOrNot) in the state.priceListInfo.tokenPriceNS or state.priceListInfo.tokenPriceStable arrays. The vulnerability arises when multiple tokens are added in succession using the setNewToken function. The function through the stickerprice does not check if the slot has enough capacity to accommodate the new price, nor does it ensure that the new price is appended correctly to the existing price slot. As a result, if the slot is full or if the new price is not correctly added to the slot, the price data will be corrupted or inconsistent.

Impact

This will lead to overwriting or corrupting existing price data, potentially causing incorrect price calculations or loss of funds.

Code Snippet

https://github.com/sherlock-audit/2023-06-dodo/blob/main/new-dodo-v3/contracts/DODOV3MM/D3Pool/D3Maker.sol#L158-L213

Tool used

Manual Review

Recommendation

Use a modified function which checks the capacity of the price slot for stable or non-stable tokens before adding a new token. If the maximum number of stable or non-stable tokens has been reached, it will revert the transaction with an appropriate error message. https://github.com/seerether/Dodo/blob/b22d985b7ef469757ff9793281e347de6b0073f1/Dodomitigate1#L15-L20C3