Level 11 - Elevator ⏺⏺
Last updated
Last updated
top
must first return false
when called, then true
the next time. The interface for Building
is set to msg.sender
.
Create a contract that exploits this by implementing a function isLastFloor
that sets top
to true
.
Submit instance... 🥳
The function isLastFloor
is called twice, with the returned value changing for the same input as the state is changed.
You can use the view
function modifier on an interface in order to prevent state modifications. The pure
modifier also prevents functions from modifying the state. Make sure you read and learn its caveats.
If the isLastFloor
had been restricted to view, then this attack wouldn't be possible (unless it was calling a library, which to make sure it doesn't modify the state when it says it's view)