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

Silvermist - Zero-amount deposits will cause an underflow on withdrawal #163

Open
sherlock-admin2 opened this issue Oct 27, 2024 · 0 comments
Labels
Sponsor Disputed The sponsor disputed this issue's validity

Comments

@sherlock-admin2
Copy link
Contributor

sherlock-admin2 commented Oct 27, 2024

Silvermist

High

Zero-amount deposits will cause an underflow on withdrawal

Summary

Users can make zero-amount deposits, leading to an arithmetic underflow in the withdrawal logic. When a withdrawal is attempted, the function calculates amount_to_transfer by subtracting withdraw_params.fee from withdraw_params.token_amount. With token_amount set to zero, this results in a negative outcome, which causes an underflow.

Root Cause

There is no validation to ensure that the deposit amount is greater than zero, nor is there a check to prevent withdrawal if the amount is insufficient to cover fees, which can cause an underflow. When the amount_to_transfer is calculated, withdraw_params.token_amount (which may be zero) has withdraw_params.fee subtracted from it. This subtraction leads to an underflow if token_amount is zero.

Internal pre-conditions

No response

External pre-conditions

No response

Attack Path

No response

Impact

Due to the underflow, an attacker can get more tokens than they deposited.

PoC

No response

Mitigation

No response

@sherlock-admin3 sherlock-admin3 added the Sponsor Disputed The sponsor disputed this issue's validity label Oct 31, 2024
@sherlock-admin4 sherlock-admin4 changed the title Orbiting Tweed Shell - Zero-amount deposits will cause an underflow on withdrawal Silvermist - Zero-amount deposits will cause an underflow on withdrawal Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Sponsor Disputed The sponsor disputed this issue's validity
Projects
None yet
Development

No branches or pull requests

2 participants