-
Notifications
You must be signed in to change notification settings - Fork 13
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
[VEN-1798]: Fix Certik 2023-08 findings for PSR/RiskFund/Shortfall contracts #287
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Problem: The code used safeTransfer when closing an auction, which may fail due to token restrictions. Failure to close an auction is a DoS vector. Solution: If transferring out is not possible, track debt and allow the auction winner to withdraw funds later.
Problem: There's a potential for cross-function reentrancy in RiskFund, ProtocolShareReserve, Shortfall contracts arising from the fact that nonReentrant modifier is not present in all external functions open to anyone. Solution: Use nonReentrant where applicable. Follow checks-effects- -interactions when emitting events.
Problem: We have a view function getPoolAssetReserve that checks whether the supplied arguments are valid. Compiler-generated function duplicates the functionality and adds some gas overhead to function dispatching. Solution: Make poolsAssetsReserves internal so that we don't have a compiler-generated version anymore.
chechu
changed the title
Fix Certik 2023-08 findings for PSR/RiskFund/Shortfall contracts
[VEN-1798]: Fix Certik 2023-08 findings for PSR/RiskFund/Shortfall contracts
Aug 9, 2023
chechu
reviewed
Aug 10, 2023
chechu
reviewed
Aug 10, 2023
0xlucian
previously approved these changes
Aug 10, 2023
GitGuru7
previously approved these changes
Aug 11, 2023
web3rover
previously approved these changes
Aug 11, 2023
chechu
previously approved these changes
Aug 11, 2023
Problem: With the evolution of the code, the meaning of the conversion threshold started to change. As a result, we ended up comparing the amount out (in tokens), balance of underlying * oracle price (in dollars), with minAmountToConvert. While in most cases these values would be close to each other as long as some stablecoin is used for the threshold, it might be problematic to set this threshold correctly, considering the potential slippage. Solution: Expect amountOutMin * base price to be greater than minAmountToConvert. Adjust the failing test accordingly.
kkirka
force-pushed
the
fix/funds-certik-2023-08
branch
from
August 14, 2023 08:42
9930fd5
to
db0e468
Compare
chechu
previously approved these changes
Aug 14, 2023
kkirka
force-pushed
the
fix/funds-certik-2023-08
branch
from
August 14, 2023 09:18
433e214
to
e4820ff
Compare
Problem: OpenZeppelin safeApprove implementation is deprecated, so its usage was removed from the RiskFund contract in favor of plain approve call. However, this is not the correct way to fix the issue since the updated version of the code doesn't handle the case when tokens return false to indicate an error. Solution: Use a custom library similar to Uniswap's TransferHelpers to make an approve call supporting: * false to indicate failure * revert to indicate failure * non-compliant tokens that don't return any value
kkirka
force-pushed
the
fix/funds-certik-2023-08
branch
from
August 14, 2023 12:20
474a957
to
6c559f1
Compare
0xlucian
approved these changes
Aug 14, 2023
web3rover
approved these changes
Aug 14, 2023
chechu
approved these changes
Aug 14, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes the findings identified by Certik in their 2023-08 audit of PSR, RiskFund and Shortfall contracts.
marketDebt
in_startAuction()
amountOutMin
_swapAsset()
Depending OnconvertibleBaseAsset
Price_transferOutOrTrackDebt()
Is Not Used When Closing Auction