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

[V-PHX-VUL-014] Pools are vulnerable to tokens with hooks #214

Open
gangov opened this issue Feb 6, 2024 · 3 comments
Open

[V-PHX-VUL-014] Pools are vulnerable to tokens with hooks #214

gangov opened this issue Feb 6, 2024 · 3 comments
Assignees
Labels
audit wontfix This will not be worked on

Comments

@gangov
Copy link
Collaborator

gangov commented Feb 6, 2024

file: contracts/pool/src/contract.rs
location: do_swap, provide_liquidity, withdraw_liquidity

The do_swap, provide_liquidity and withdraw_liquidity functions transfer the funds to the recipient before updating the pool reserves. If one of the tokens involved includes a callback in its transfer function, then it can be used to reenter the pool and perform an operation with the pool reserves yet to be updated.
Reference: https://uniswap.org/whitepaper.pdf —> go to section 3.3

Impact: As the update of pool reserves occurs subsequent to the token transfer, tokens equipped with a callback in their transfer function can potentially be used to reenter the pool before its reserves are updated. For example, they can swap again using the previous price.

Recommendation: Add reentrancy locks to the swap, provide_liquidity and withdraw_liquidity operations.

Reference: https://github.com/Uniswap/v2-core/blob/master/contracts/UniswapV2Pair. sol
archive

@gangov gangov added the audit label Feb 6, 2024
@gangov gangov self-assigned this Feb 8, 2024
@gangov
Copy link
Collaborator Author

gangov commented Feb 15, 2024

from Stellar's Discord:

Reentrancy isn't implemented yet. At the moment it is disallowed. Once it is implemented, it'll be an explicit flag you have to specify to allow.

05/30/2023 7:19 PM

last question on the topic was from two months later

@gangov gangov linked a pull request Feb 15, 2024 that will close this issue
@gangov
Copy link
Collaborator Author

gangov commented Feb 15, 2024

found some extra on the topic

@gangov
Copy link
Collaborator Author

gangov commented Mar 26, 2024

as per Discord discussion:

02/15/2024 3:04 PM
hey, how are you all handling the protection against reentrancy attacks? There's a post about since last year, but nothing comes up after that

02/15/2024 6:32 PM
contract reentrancy is (currently, but I think it'll remain like this) disabled in soroban's host environment

02/15/2024 7:01 PM
thanks! So basically devs should not implement any additional checks for that type of attacks, is that correct?

02/15/2024 7:09 PM
yes should always assume that any contract you're calling won't be able to call yours back within the same operation.

given all that information, should we put efforts trying to additionally protect against such attack?

@gangov gangov added the wontfix This will not be worked on label Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
audit wontfix This will not be worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
@gangov and others