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

SemiFungibleVault's previewWithdraw/previewRedeem implementation is not ERC-4626 compliant #42

Closed
code423n4 opened this issue Sep 16, 2022 · 1 comment
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working duplicate This issue or pull request already exists sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/SemiFungibleVault.sol#L205-L214
https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/SemiFungibleVault.sol#L221-L228

Vulnerability details

Impact

ERC-4626 defines the previewWithdraw() and previewRedeem() functions with the intention of being used as a way to "simulate" a withdraw. Thus, the previewWithdraw() and previewRedeem() functions should revert when passed a set of parameters that would cause withdraw() to revert.

In addition, previewWithdraw() and previewRedeem() must be inclusive of withdraw/redemption fees, as defined in the ERC-4626 spec. SemiFungibleVault's implementation of previewWithdraw() and previewRedeem() do not factor in fees, making the contract non-compliant with ERC-4626.

Proof of Concept

previewWithdraw() implementation
previewRedeem() implementation

previewWithdraw() and previewMint() fail to revert under the following conditions:

previewWithdraw() and previewMint() fail to include fee calculations that are performed by withdraw() here.

Tools Used

Manual Review

Recommended Mitigation Steps

The previewWithdraw() and previewMint() functions should be modified so they revert whenever the withdraw() function would revert.

In addition, the previewWithdraw() and previewMint() functions must be modified so their calculations are inclusive of protocol fees.

@code423n4 code423n4 added 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 labels Sep 16, 2022
code423n4 added a commit that referenced this issue Sep 16, 2022
@MiguelBits MiguelBits added the duplicate This issue or pull request already exists label Sep 30, 2022
@MiguelBits MiguelBits added sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue and removed duplicate This issue or pull request already exists labels Oct 3, 2022
@HickupHH3
Copy link
Collaborator

HickupHH3 commented Oct 29, 2022

dup #47, considered to be part of #41

@HickupHH3 HickupHH3 added duplicate This issue or pull request already exists 3 (High Risk) Assets can be stolen/lost/compromised directly and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Oct 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working duplicate This issue or pull request already exists sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue
Projects
None yet
Development

No branches or pull requests

3 participants