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 previewDeposit/previewMint implementation is not ERC-4626 compliant #43

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#L175-L182
https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/SemiFungibleVault.sol#L189-L197

Vulnerability details

Impact

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

SemiFungibleVault's previewDeposit and previewMint functions are borrowed from the Solmate reference implementation and fail to detect conditions that cause deposit() to revert, making the contract non-ERC-4626 compliant.

Proof of Concept

previewDeposit() implementation
previewMint() implementation

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

Tools Used

Manual Review

Recommended Mitigation Steps

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

@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 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
@HickupHH3
Copy link
Collaborator

HickupHH3 commented Oct 29, 2022

dup of #47, considered to be part of #41

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