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

ATokenYieldSource mixes aTokens and underlying when redeeming #86

Open
code423n4 opened this issue Jun 23, 2021 · 2 comments
Open

ATokenYieldSource mixes aTokens and underlying when redeeming #86

code423n4 opened this issue Jun 23, 2021 · 2 comments

Comments

@code423n4
Copy link
Contributor

Handle

cmichel

Vulnerability details

The ATokenYieldSource.redeemToken function burns aTokens and sends out underlying, however, it's used in a reverse way in the code:
The balanceDiff is used as the depositToken that is transferred out but it's computed on the aTokens that were burned instead of on the depositToken received.

Impact

It should not directly lead to issues as aTokens are 1-to-1 with their underlying but we still recommend doing it correctly to make the code more robust against any possible rounding issues.

Recommended Mitigation Steps

Compute balanceDiff on the underyling balance (depositToken), not on the aToken.
Subtract the actual burned aTokens from the user shares.

@code423n4 code423n4 added 1 (Low Risk) bug Something isn't working labels Jun 23, 2021
code423n4 added a commit that referenced this issue Jun 23, 2021
@PierrickGT
Copy link
Member

I agree that we should compute balanceDiff on the underlying balance.
Regarding the burn of the user's shares, we should keep it as is to verify first that the user has enough shares. This way if he doesn't, the code execution will revert before funds are withdrawn from Aave.

@PierrickGT
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants