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
DepositTradeHelper.depositAndTrade will not work normally with ERC20 that need to clear allowance #198
Labels
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
grade-a
Q-20
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
Comments
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
Dec 12, 2022
c4-judge
added
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
downgraded by judge
Judge downgraded the risk level of this issue
and removed
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
labels
Dec 17, 2022
Picodes changed the severity to QA (Quality Assurance) |
c4-judge
added a commit
that referenced
this issue
Dec 17, 2022
This was referenced Dec 19, 2022
Closed
c4-judge
added
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
grade-c
labels
Dec 19, 2022
Picodes marked the issue as grade-c |
c4-judge
added
grade-b
and removed
grade-c
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
labels
Dec 19, 2022
Picodes marked the issue as grade-b |
Picodes marked the issue as grade-a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
grade-a
Q-20
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
Lines of code
https://github.com/prepo-io/prepo-monorepo/blob/feat/2022-12-prepo/apps/smart-contracts/core/contracts/DepositTradeHelper.sol#L24
Vulnerability details
Impact
DepositTradeHelper.depositAndTrade will not work normally with ERC20 that need to clear allowance as it sets allowance to uint256.max and do not set it to 0 after. As result next time when user calls depositAndTrade function it will fail as allowance should be set to 0 before.
Proof of Concept
DepositTradeHelper.depositAndTrade function allows user to deposit base tokens into Collateral token and then swap it using Uniswap.
https://github.com/prepo-io/prepo-monorepo/blob/feat/2022-12-prepo/apps/smart-contracts/core/contracts/DepositTradeHelper.sol#L22-L34
It uses permit function to provide allowance to himself and it sets allowance to type(uint256).max. After the transfer it doesn't set allowance to 0.
And next time when user will call this function it will revert if _baseToken doesn't support providing allowance when current allowance is not set to 0(like USDT).
Tools Used
VsCode
Recommended Mitigation Steps
Do not set allowance to type(uint256).max, set it to baseTokenAmount value.
The text was updated successfully, but these errors were encountered: