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

Vault reentrancy guard #17487

Merged
merged 2 commits into from
May 14, 2024
Merged

Vault reentrancy guard #17487

merged 2 commits into from
May 14, 2024

Conversation

Bridgerz
Copy link
Contributor

@Bridgerz Bridgerz commented May 3, 2024

No description provided.

Copy link

vercel bot commented May 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 14, 2024 1:03am
3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview May 14, 2024 1:03am
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview May 14, 2024 1:03am
sui-typescript-docs ⬜️ Ignored (Inspect) Visit Preview May 14, 2024 1:03am

@Bridgerz Bridgerz merged commit 3a11153 into main May 14, 2024
51 checks passed
@Bridgerz Bridgerz deleted the vault-reentrancy-gaurd branch May 14, 2024 22:22
Comment on lines +892 to +902
receive() external payable {
if (!attackInitiated) {
attackInitiated = true;
vault.transferETH(payable(address(this)), 100);
}
}

function attack() external payable {
attackInitiated = false;
vault.transferETH(payable(address(this)), 100);
}
Copy link
Contributor

@longbowlu longbowlu May 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not

    receive() external payable {
        vault.transferETH(payable(address(this)), 100);
    }

    function attack() external payable {
        vault.transferETH(payable(address(this)), 100);
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would cause an Infinite loop / any call to the attack() function would run out of gas.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't the reentrancy guard catch this in the 2nd loop?

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

Successfully merging this pull request may close these issues.

4 participants