Update the DetectionBot of DoubleEntryPoint challenge and the validateInstance of the DoubleEntryPointFactory #745
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.
I will speak about the
DoubleEntryPointchallenge, the one which useForta.Currently, this is the solution of this challenge:
With this solution, the method
raiseAlertis called all the time which makes revert thedelegateTransfermethod at each call. In my opinion, it makes no sense to have a method which reverts always.According to me, the real exploit is to call the
delegateTransfermethod from theCryptoVaultcontract becauseDoubleEntryPointis an underlying token. It can happend if someone callsweepTokenmethod withLegacyTokenaddress in parameter. TheDetectionBotmust prevent of this case. So this is my proposition of solution:With this solution, the method
raiseAlertis called only when the vulnerability is exploited.Now, to prevent someone to solve this challenge with a
DetectionBotwhich raises an alert all the time. I also updated thevalidateInstancemethod of theDoubleEntryPointFactory. Before trying to sweep token, thevalidateInstancemethod will try to emulate a lambda transfer of a user, if the transfer reverts, thevalidateInstancefails.I updated unit tests to test my code. I also deployed the new
DoubleEntryPointFactoryin local environment to test it through ethernaut. Everything is working!Do I have to push the new build of the
DoubleEntryPointFactorycontract?Also,
DoubleEntryPointchallenge is the only one which reverts when thevalidateInstancefails. It doesn't come from of my code, it was already there. Do you want me to fix that? (It's 2 lines)