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

What is the purpose of allowImplementations HostAccess.Builder.allowImplementations ? #294

Closed
tporeba opened this issue May 29, 2020 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@tporeba
Copy link

tporeba commented May 29, 2020

I don't understand how does HostAccess.Builder#allowImplementations (and similar allowAllImplementations) work.

I have following context configuration:

Context.newBuilder("js")
.allowHostAccess(
   HostAccess.newBuilder()
      .allowAllImplementations(false)
      .allowArrayAccess(true)
      .allowListAccess(true)
      .allowPublicAccess(true)
      .build())
.build()

and still I can do this:

var R = Java.extend(Java.type("java.lang.Runnable"));
var r = new R(function(){print("hello");});
r.run();

This prints "hello".

I thought implementing java.lang.Runnable interface would be prohibited because of allowAllImplementations(false), shouldn't it?

@tporeba
Copy link
Author

tporeba commented May 29, 2020

This permission doesn't seem to have any effect on passing JS function as an argument to a Java method:

Packages.com.example.Util.runIt(function(){
    print("hello runnable");
});

with

public class Util {
    public static void runIt(java.lang.Runnable x){
        x.run();
    }

This also works despite allowAllImplementations(false).

@woess
Copy link
Member

woess commented Jun 16, 2020

Thanks for the report. Java.extend currently does not respect allowImplementations. This is a known issue that we want to address in the future. The second example looks like a bug. We'll investigate.

@wirthi wirthi added security enhancement New feature or request and removed security labels Jun 18, 2020
@wirthi
Copy link
Member

wirthi commented Nov 17, 2020

This was implemented in 60cb438 and will be shipped as part of GraalVM 20.3.

@wirthi wirthi closed this as completed Nov 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants