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

b0g0_ctf - deposit function always sets user deposit to the current deposit #27

Open
Viktor-Andreev4 opened this issue Aug 12, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Viktor-Andreev4
Copy link

Viktor-Andreev4 commented Aug 12, 2024

Bug in deposit() function

Description of bug:

In the deposit() function, if a user deposits multiple times, only the first deposit is correctly recorded. Subsequent deposits are not properly accumulated, resulting in only the first deposit being withdrawable. This oversight causes issues when users attempt to withdraw their additional deposits, leading to reversion errors and locked funds.

Impact

Due to this bug, users who make multiple deposits will experience issues withdrawing their funds beyond the initial deposit. The failure to properly accumulate the deposit values causes the contract to lock the additional funds, making them inaccessible and resulting in a poor user experience.

Solution

To resolve this issue, modify the deposit handling logic from deposits[msg.sender] = msg.value to deposits[msg.sender] += msg.value. This adjustment ensures that each new deposit is added to the existing balance, allowing users to withdraw their total deposited amount accurately.

@BogoCvetkov
Copy link
Collaborator

This is an issue from the incorrect initial version of the CTF(technical error on my side) . I decided those would also get awarded, since it's fair to do so.

Your submission is valid and you're the first one to submit it, so you'll get a reward

@BogoCvetkov BogoCvetkov added the bug Something isn't working label Aug 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants