Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Albort - Incorrect Updating of Listing Data in _mapListings Function #794

Open
sherlock-admin4 opened this issue Sep 15, 2024 · 0 comments

Comments

@sherlock-admin4
Copy link
Contributor

sherlock-admin4 commented Sep 15, 2024

Albort

Medium

Incorrect Updating of Listing Data in _mapListings Function

Summary

The function attempts to modify _createListing.listing.checkpoint where _createListing is a memory variable derived from calldata. In Solidity, modifying memory variables does not affect the original calldata, and depending on the struct definitions, this may not correctly update the storage ProtectedListing.

Vulnerability Detail

If the checkpoint is not correctly updated in the storage _protectedListings, subsequent functions relying on accurate checkpoint data (e.g., unlockPrice, getProtectedListingHealth) may produce incorrect results, leading to vulnerabilities like improper debt calculations or incorrect collateral assessments.

Impact

Code Snippet

function _mapListings(CreateListing memory _createListing, uint _tokenIds, uint checkpointIndex) internal returns (uint tokensReceived) {
for (uint i; i < _tokenIds; ++i) {
// 使用当前检查点更新请求并存储 listing
_createListing.listing.checkpoint = _checkpointIndex;
_protectedListings[_createListing.collection][_createListing.tokenIds[i]] = _createListing.listing;

    tokensReceived_ += _createListing.listing.tokenTaken;

    emit ListingDebtAdjusted(_createListing.collection, _createListing.tokenIds[i], int(uint(_createListing.listing.tokenTaken)));
}

}

https://github.com/sherlock-audit/2024-08-flayer/blob/main/flayer/src/contracts/ProtectedListings.sol#L198

Tool used

Manual Review

Recommendation

Directly update the storage struct without attempting to modify a memory copy. Ensure that all necessary fields are correctly set in storage.

@sherlock-admin2 sherlock-admin2 changed the title Daring Strawberry Eel - Incorrect Updating of Listing Data in _mapListings Function Albort - Incorrect Updating of Listing Data in _mapListings Function Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant