Fix QuantStamp Audit S1: Missing Input Validation #30
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.
From QS Audit Report:
The following is a list of places that can potentially benefit from stricter input validation:
SwapStableInvestStrategy.sol:
a. the decimal asset_ of the constructor() function should be less than 18 .
b. the decimal investAsset_ of the constructor() function should be less than 18 .
c. the swapConfig.maxSlippage of the _setSwapConfig should be less than WAD .
AccessManagedMSV.sol:
a. the asset_ of initialize() should not be zero address.
CompoundV3InvestStrategy.sol:
a. the inputs of constructor() should not be zero addresses.
Validations 1.a and 1.b implemented. Also, I added a validation to check that
asset_ != investAsset_.I decided not to implement the maxSlippage validation, because I don't think is needed and also I don't wan't to break the abstraction of the SwapLibrary with the swap config. In any case, the setSwapConfig must be used wisely, adding a
<WADvalidation doesn't add much protection.Regarding point 2, I decided not to apply the validation, since the parameter is sent to OZ's ERC4626 contract and they decided not to add that validation. Also, other validations of the initialization will forbid deploying a vault with asset = address(0).
Regarding point 3, I implemented a validation around the rewardManager parameter. If
cToken_parameter is zero, the constructor will fail anyway.