Eliminate dust when wrap ERC-20 token by retaining erc20 balance in their respective decimal places #135
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
edited-by-warden
insufficient quality report
This report is not of sufficient quality
primary issue
Highest quality submission among a set of duplicates
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/code-423n4/2023-11-shellprotocol/blob/main/src/ocean/Ocean.sol#L820-L842
https://github.com/code-423n4/2023-11-shellprotocol/blob/main/src/ocean/Ocean.sol#L622-L628
https://github.com/code-423n4/2023-11-shellprotocol/blob/main/src/ocean/Ocean.sol#L1068-L1109
Vulnerability details
Impact
The creation of token dust through decimal conversion poses two key issues:
Ownership - Dust gets sent to the contract owner rather than users, despite being their rightful property.
Restricted movement - Dust accumulates and cannot be withdrawn until reaching 1 WEI minimum, inconveniencing the owner of dust.
Proof of Concept
Dust gets created when:
Users wrap ERC20 tokens into Ocean via doInteraction() or doMultipleInteractions() with the WrapErc20 interaction type.
Here the token amount gets converted, with leftovers assigned as dust sent to the owner, as seen in this snippet:
Tools Used
Manual
Recommended Mitigation Steps
Dust needs to be removed. External tokens should be stored in the Ocean ERC-1155 contract at their original precision, avoiding any decimal conversion or normalization.
Suggest to change
The text was updated successfully, but these errors were encountered: