Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle unverifiable jumps into the middle of instructions. #75

Closed
leibnitz27 opened this issue Jan 9, 2020 · 5 comments
Closed

Handle unverifiable jumps into the middle of instructions. #75

leibnitz27 opened this issue Jan 9, 2020 · 5 comments

Comments

@leibnitz27
Copy link
Owner

https://anthony.som.codes/blog/2019-12-30-jvm-hackery-noverify/ (
@half-cambodian-hacker-man ) points out some fun stuff allowing jumps to vector into the middle of other byte code.

@leibnitz27
Copy link
Owner Author

  public static int foo();
    Code:
       0: nop
       1: nop
       2: goto          6
       5: sipush        8
       8: istore        0
      10: getstatic     #14                 // Field java/lang/System.out:Ljava/io/PrintStream;
      13: iload         0
      15: invokevirtual #8                  // Method java/io/PrintStream.println:(I)V
      18: sipush        1
      21: ireturn

Now gives

/*
 * Handled unverifiable bytecode (illegal jump).
 */
public static int foo() {
    int n = 5;
    System.out.println(n);
    return 1;
}

@leibnitz27
Copy link
Owner Author

leibnitz27 commented Jan 9, 2020

And here are a couple of examples.

NoVerify.class.zip
NoVerify2.class.zip

(classes renamed as zip to make github happy)

@char
Copy link

char commented Jan 9, 2020

Does this work for conditional branches?

@leibnitz27
Copy link
Owner Author

leibnitz27 commented Jan 9, 2020

Should do (there's nothing jump specific in here, just handling instructions whose successor isn't a legitimate index). Feel free to try to break it ;)

@leibnitz27
Copy link
Owner Author

(And if you do, pls provide class file ;) )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants