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

Incorrect check in ZcToken.withdraw and ZcToken.redeem leads to underlying tokens not being able to be transferred #180

Closed
code423n4 opened this issue Jul 15, 2022 · 2 comments
Labels
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 duplicate This issue or pull request already exists resolved Finding has been patched by sponsor (sponsor pls link to PR containing fix)

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-07-swivel/blob/daf72892d8a8d6eaa43b9e7d1924ccb0e612ee3c/Creator/ZcToken.sol#L112-L115
https://github.com/code-423n4/2022-07-swivel/blob/daf72892d8a8d6eaa43b9e7d1924ccb0e612ee3c/Creator/ZcToken.sol#L133-L134

Vulnerability details

Incorrect check in ZcToken.withdraw and ZcToken.redeem leads to underlying tokens not being able to be transferred

In both ZcToken.withdraw and ZcToken.redeem, in the case where holder != msg.sender, a check of the msg.sender's ZcToken allowance is performed.
But the functions revert if the allowance is larger than the amount of tokens being redeemed.
So the call only goes to the next step if allowance[holder][msg.sender] < principalAmount, which would then make the following line revert.
In conclusion, the functions will always revert in this case, meaning an approved caller will never be able to redeem the desired amount of underlying tokens.

Impact

High

Mitigation

Change the allowance checks:

-112:             if (allowed >= previewAmount) {
+112:             if (allowed < previewAmount) {
113:                 revert Approvals(allowed, previewAmount);
114:             }
-133:             if (allowed >= principalAmount) { revert Approvals(allowed, principalAmount); }
+133:             if (allowed < principalAmount) { revert Approvals(allowed, principalAmount); } 
@code423n4 code423n4 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels Jul 15, 2022
code423n4 added a commit that referenced this issue Jul 15, 2022
@ghost ghost mentioned this issue Jul 16, 2022
@JTraversa
Copy link
Collaborator

Duplicate of #129

@JTraversa JTraversa marked this as a duplicate of #129 Jul 20, 2022
@JTraversa JTraversa added the duplicate This issue or pull request already exists label Jul 20, 2022
@robrobbins
Copy link
Collaborator

addressed here: Swivel-Finance/gost#409

@robrobbins robrobbins added the resolved Finding has been patched by sponsor (sponsor pls link to PR containing fix) label Aug 1, 2022
@JeeberC4 JeeberC4 added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value and removed 3 (High Risk) Assets can be stolen/lost/compromised directly labels Aug 5, 2022
@JeeberC4 JeeberC4 closed this as completed Aug 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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 duplicate This issue or pull request already exists resolved Finding has been patched by sponsor (sponsor pls link to PR containing fix)
Projects
None yet
Development

No branches or pull requests

4 participants