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
DoubleEntryPoint
challenge, the one which useForta
.Currently, this is the solution of this challenge:
With this solution, the method
raiseAlert
is called all the time which makes revert thedelegateTransfer
method 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
delegateTransfer
method from theCryptoVault
contract becauseDoubleEntryPoint
is an underlying token. It can happend if someone callsweepToken
method withLegacyToken
address in parameter. TheDetectionBot
must prevent of this case. So this is my proposition of solution:With this solution, the method
raiseAlert
is called only when the vulnerability is exploited.Now, to prevent someone to solve this challenge with a
DetectionBot
which raises an alert all the time. I also updated thevalidateInstance
method of theDoubleEntryPointFactory
. Before trying to sweep token, thevalidateInstance
method will try to emulate a lambda transfer of a user, if the transfer reverts, thevalidateInstance
fails.I updated unit tests to test my code. I also deployed the new
DoubleEntryPointFactory
in local environment to test it through ethernaut. Everything is working!Do I have to push the new build of the
DoubleEntryPointFactory
contract?Also,
DoubleEntryPoint
challenge is the only one which reverts when thevalidateInstance
fails. It doesn't come from of my code, it was already there. Do you want me to fix that? (It's 2 lines)