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

Don't use a separate Project.toml #928

Open
dpsanders opened this issue May 20, 2020 · 7 comments
Open

Don't use a separate Project.toml #928

dpsanders opened this issue May 20, 2020 · 7 comments

Comments

@dpsanders
Copy link

I have been caught out several days times by IJulia automatically using a Project.toml from the directory in which it is started.

I feel strongly that this is a gotcha -- it should use the same standard Project.toml as the standard Julia REPL, unless I explicitly say otherwise.

@twavv
Copy link
Contributor

twavv commented May 20, 2020

I also pointed out on slack a while ago that this has security implications as well (as @StefanKarpinski frequently points out, there is a reason that projects aren't activated by default).

@stevengj
Copy link
Member

I'm fine with disabling this.

@fredrikekre
Copy link
Member

See lengthy discussion in #820. Also #925.

Personally I am in favor of the current behavior.

@twavv
Copy link
Contributor

twavv commented May 27, 2020

I'd like to elaborate on the security implications.

@StefanKarpinski wrote (in #820)

This seems sensible since starting a notebook in a directory already implicitly works in that directory. The reason that julia itself doesn't do this by default is that merely starting julia in a directory is not a sufficiently strong signal from the user that they trust the content of that directory and want to let it control what code they run, but it seems like starting a notebook server in a given directory is probably a strong enough indication from the user that they want to do just that.

Essentially, Stefan is saying that starting a notebook server is a sufficiently strong signal from the user that they trust the content of that directory. That statement is subjective so I'm not going to argue that it's wrong (in probably 99% of cases, it is true that the user completely trusts the contents of the notebook).

However that's not consistent with Jupyter's own security system which essentially boils down to the question Did the current user do this?. Simply opening a notebook is not meant to be license to execute arbitrary code. That is why HTML is sanitized and JavaScript is stripped out if that HTML/JS was produced by someone other than the current user. Yes, Jupyter is meant to allow execution of arbitrary code, but only the arbitrary code that the user explicitly runs.

Currently, simply opening a Notebook (e.g., to view what a colleague sent you) is capable of executing arbitrary code (using the "manifest poisoning" attack that is prevented against by not using --project=@. by default).


I don't think adding

using Pkg
Pkg.activate(".")

to the top of a notebook is such a burden (that tends to be where all of the using ... statements are anyway). We're already miles ahead of Python here. Additionally, one usually has to instantiate the project anyway (all of my notebooks also include Pkg.instantiate() at the top).

@stevengj
Copy link
Member

(Note that, even if this feature is disabled, you can install a custom IJulia kernel to use with a particular project.)

@goerz
Copy link

goerz commented Oct 9, 2024

I'm not sure that I follow the security implications. @twavv Can you elaborate on the "manifest poisoning attack"?

As far as I can tell, simply running a Jupyter notebook server in a specific directory and opening a Julia notebook does not run any code. Running the notebook would, but the user still has to instantiate the project, in any case.

So I lack the imagination how IJulia picking up project environments automatically is a serious security concern. If the notebook contains

using Pkg
Pkg.activate(".")

at the top, does that change anything? Running the notebook without inspection still executes arbitrary code. And of course, in general, if I download untrusted code (notebooks) from somewhere and then run it, of course I'm exposing myself to security issues.

@twavv
Copy link
Contributor

twavv commented Oct 23, 2024

I am no longer using Julia in my day-to-day life, so take this with a grain of salt, but opening a notebook can allow arbitrary code execution because the Manifest.toml can "redirect" IJulia to a malicious package. The notebook will load IJulia (the malicious version) as soon as its opened without the user having to run any code blocks.

I remember creating a proof-of-concept for this at some point but it's been a while.

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

5 participants