Closed just-boris closed 8 years ago
I think it should be the default option, since most packages do not need life-cycle scripts.
The ones that have life-cycle scripts need to be added to a whitelist based on hash of the package that ied
computes anyway. The whitelist should probably be user-wide or system-wide.
There also need to be a warning from the ied
that scripts need to be run. Install needs to fail without the package being present in the whitelist or having specifically been installed with --ignore-scripts
.
Definitely agree with @just-boris here. lifecycle scripts are always kinda dangerous... we should at least offer the option to disable them...
@vladwing Disabling all of them by default is going to be an unpopular opinion until we have the first npm
worm that takes over half the internet.
@alexanderGugel you are right. Maybe have a --secure
option that can be saved user/system-wide and which disables lifecycle scripts unless the hash of the module is whitelisted. It will be easy to make that option the default later on.
I agree with this.
Let's enumerate the risk here so we know how to best address it:
The baseline risk is that a malicious package will spawn some processes, read/delete files, etc. All of this can be done upon an initial require()
, but difference is in which user context it can do so.
It's (somewhat) common for some users to install packages as root but run the node process as a restricted user. It's very common to install global packages as root.
So we can do two things:
ied
as root without the --global
flagpackage.json
, and an attribute in ied-shrinkwrap.json
(when that comes, and when it does, it should specify @author:package@version::hash
).The rebirth branch has a --build
flag that enables lifecycle scripts. I think making it opt-in is better due to the reasons mentioned above. https://github.com/alexanderGugel/ied/tree/rebirth
I will close this once rebirth
is merged into master
.
I think this is a good idea. Perhaps at the end of an install, we could list the packages with hooks that weren't run. Would simplify the process for the security-conscious. On Apr 13, 2016 7:36 AM, "Alexander Gugel" notifications@github.com wrote:
The rebirth branch has a --build flag that enables lifecycle scripts. I think making it opt-in is better due to the reasons mentioned above. https://github.com/alexanderGugel/ied/tree/rebirth
I will close this once rebirth is merged into master.
— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/alexanderGugel/ied/issues/99#issuecomment-209409137
Another option is to actually let the user select the hooks to be executed: https://www.npmjs.com/package/inquirer#checkbox---type-checkbox
I have two issues with this approach:
One additional thing: we should allow running, on a different switch, the life-cycle scripts for the root module. The reason is that maybe we disabled the scripts for its children, but the root module has some initialization for those to make them able to run.
Thanks everyone for this discussion. The current solution looks as follows:
--build flag
ied install --build
, which will as of 2.0.0 traverse the entire dependency graph (even for already installed dependencies) - I think that's what @vladwing meant, correct?
The thing that any package can execute arbitrary code during installation can be considered as a vulnerability. So it would be good to have the option to disable it. Even better, if it will be possible to configure white/black lists with packages.
NPM has a flag for it
npm install --ignore-scripts
. I think we should have the same.Original source here: https://github.com/alexanderGugel/ied/pull/87#issuecomment-200490345