The PreMarkets
contract in the Tadle protocol lacks mechanisms to manage long-term data accumulation in its storage mappings. This design could lead to gradually increasing gas costs and reduced contract efficiency over time, potentially impacting the protocol's long-term viability and user experience.
The vulnerability stems from the continuous addition of data to storage mappings without any mechanism for data removal or archiving. Specifically, the issue is present in the createOffer
function of the PreMarkets contract:
This function creates new entries in makerInfoMap
, offerInfoMap
, and stockInfoMap
for each new offer. The offerId
is incremented with each new offer, ensuring unique addresses for each entry. However, there is no mechanism to remove or archive old data from these mappings.
The storage for these mappings is defined in the PerMarketsStorage
contract:
While this accumulation is unlikely to cause immediate issues or reach block gas limits in the short term, it could have the following long-term impacts:
Gradually increasing gas costs: As the mappings grow, operations that involve reading from or writing to these mappings will consume more gas, making transactions more expensive for users over time.
Reduced contract efficiency: Large data structures can lead to slower execution times and higher computational costs for contract operations.
Potential for reached gas limits: In an extreme scenario, after a very long period of continuous use, certain operations might become too gas-intensive to execute within a single block.
Manual Review
To address this vulnerability, consider implementing the following measures:
Data Archiving Mechanism: Implement a function to move old, settled, or cancelled offers to a separate archival storage after a certain period. This could be triggered periodically or when certain conditions are met.
Implement Pagination: For functions that might need to iterate over large datasets, implement pagination to limit gas consumption per transaction.
Data Cleanup: Implement a function to remove completely settled or long-cancelled offers that are no longer needed.
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.