8

I know, the practical reasons behind it is just to add additional security layer.

But why does EVM even need it? Asm doesn't have it and works great.

1 Answer 1

4

The EVM doesn't need it. Like you said, it's just an additional security layer.

If there's ever a compiler bug where a program counter on the stack can be replaced by an arbitrary value, the JUMPDEST requirement may or may not protect against potential exploits.

I'm not convinced about its usefulness because if this ever happens, things would have already gone wrong while testing your contract, and you would never have used your code in public. Also, the exploiter can easily see where all the JUMPDEST's are and may still be able to jump to any arbitrary JUMPDEST.

Correction @2019-04-06:

The presence of JUMPDEST's makes it slightly easier to write a decompiler that turns EVM bytecode into Solidity code.

3
  • 1
    Yeah, ability to jump to any jumpdest makes me think like "hey, that doesn't help at all" Dec 21, 2017 at 18:37
  • source for that update?
    – Kyle Baker
    Mar 7, 2022 at 11:29
  • 1
    From a security angle, you would only be able to jump to JUMPDESTs, and not locations that were never meant to be jump targets. This can allow you to do stack validations immediately after a JUMPDEST and prevent exploits from jumping just after those validations. re: it being easier to write a decompiler, I don't know if that was the intent behind the opcode, but it certainly makes it easier to assess chunks of code that are going to be executed together because they will always be prefixed with a JUMPDEST. If you had to assess starting points from JUMPS that may be dynamic, this is harder.
    – AusIV
    Jun 9, 2022 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.