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

Add "fork" method to DenoPermissions #4779

Open
bartlomieju opened this issue Apr 16, 2020 · 10 comments
Open

Add "fork" method to DenoPermissions #4779

bartlomieju opened this issue Apr 16, 2020 · 10 comments

Comments

@bartlomieju
Copy link
Contributor

@bartlomieju bartlomieju commented Apr 16, 2020

To have Deno namespace in the worker, we'll want to provide a map of permissions worker should have. Worker's set of permissions mustn't escalate permissions of parent worker/Deno process.

To achieve that a method called fork should be added to DenoPermissions struct. fork would take as many parameters as there are fields on DenoPermissions and return new DenoPermissions instance after asserting that none of the permissions passed as arguments escalate parent permissions. If one tried to fork permissions with escalation then OpError::permission_denied should be returned with appropriate message indicating which permissions are being escalated.

Pseudo code:

impl DenoPermissions {
  fn fork(&self, allow_net: bool, net_whitelist: Vec<String>, ...) -> Result<DenoPermissions, OpError>;
}

This is an easy issue, only *_whitelist processing might be a bit complicated.

@bartlomieju
Copy link
Contributor Author

@bartlomieju bartlomieju commented Apr 16, 2020

Prerequisite for #3998

@humancalico
Copy link
Contributor

@humancalico humancalico commented Apr 16, 2020

@bartlomieju I'll work on this.

@jafern14
Copy link

@jafern14 jafern14 commented May 4, 2020

@bartlomieju is this task still necessary? #3998 is closed. trying to figure out the value of this given that closed dep

@bartlomieju
Copy link
Contributor Author

@bartlomieju bartlomieju commented May 4, 2020

@jefern14 yes it's needed. Currently in worker permissions are inherited from process and we want to make them configurable. See #4867

@jafern14
Copy link

@jafern14 jafern14 commented May 4, 2020

great thanks for the update. I'll be looking into this as well after work hours.

@jafern14
Copy link

@jafern14 jafern14 commented May 6, 2020

@bartlomieju do you mind explaining a bit more of what you mean when you say "permissions escalation"? The way I'm looking at this having almost no knowledge of how this works is that a forked worker would inherit all the same permissions of it's parent. Your description makes me doubt my assumption so I'd like to understand prior implementing anything.

@bartlomieju
Copy link
Contributor Author

@bartlomieju bartlomieju commented May 6, 2020

@bartlomieju do you mind explaining a bit more of what you mean when you say "permissions escalation"? The way I'm looking at this having almost no knowledge of how this works is that a forked worker would inherit all the same permissions of it's parent. Your description makes me doubt my assumption so I'd like to understand prior implementing anything.

That's the case right now, when you create worker with Deno namespace it inherits parent process permissions. We want to make this option configurable so you can explicitly specify permissions for worker (eg. { read: ["/tmp"], net: true }). Escalation means that requested permissions for worker cannot be more permissive than main process permissions - ie. if you run program with only --allow-read flag the workers created cannot request that net and write are available to them.

@Axighi
Copy link

@Axighi Axighi commented May 11, 2020

@bartlomieju I'm trying to work on this.

@humancalico
Copy link
Contributor

@humancalico humancalico commented May 11, 2020

@Axighi I already have an open PR. Although I do have to update it since DenoPermissions got renamed to Permissions

@ktfth
Copy link

@ktfth ktfth commented May 17, 2020

The fork process just can work on Workers or have other scenarios?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.