Skip to content

Support trustedDependencies in package.json #2073

@Electroid

Description

@Electroid
Contributor

There are npm packages, like esbuild, that need postinstall support to install binaries or run other scripts. While we could allow any package to run scripts, that wouldn't be the safest thing to do. We also can't not support it at all, because these packages would simply not work.

We're thinking of adding a new trustedDependencies property to the package.json, which would require developers to explicitly define an allowlist of packages that are allowed to run scripts.

{
  "private": true,
  "dependencies": {
    "esbuild": "^0.17.8"
  },
  "trustedDependencies": [
    "esbuild"
  ]
}

This would not extend to child dependencies, so if package foo depends on bar, and foo is on the allowlist, bar is not on the allowlist, unless it is explicitly added.

Activity

added
enhancementNew feature or request
bun installSomething that relates to the npm-compatible client
on Feb 15, 2023
added a commit that references this issue on Jun 13, 2023
be652d7
added 2 commits that reference this issue on Jun 13, 2023
4bc0c24
3cbe186
changed the title [-]Support `privilegedDependencies` in `package.json`[/-] [+]Support `trustedDependencies` in `package.json`[/+] on Jun 13, 2023
added 6 commits that reference this issue on Jun 14, 2023
4706f2a
66444b4
3732dcc
2fc4bc0
d07e822
2ab60d8
added a commit that references this issue on Jun 27, 2023
318879d
added a commit that references this issue on Sep 10, 2023
Bessonov

Bessonov commented on Sep 24, 2023

@Bessonov

@Electroid I'm not sure if I'm missing something. From a security point of view, what's the difference between using the postinstall lifecycle hook and executing/spawning inside the dependency?

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bun installSomething that relates to the npm-compatible clientenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @Bessonov@Electroid

      Issue actions