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

The SUID sandbox helper binary was found, but is not configured correctly #17972

Closed
3 tasks done
christianbundy opened this issue Apr 25, 2019 · 155 comments
Closed
3 tasks done

Comments

@christianbundy
Copy link

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

  • Electron Version:
    • 5.0.0
  • Operating System:
    • Arch Linux x64
  • Last Known Working Electron version::
    • 4.1.5

Expected Behavior

Running node_modules/.bin/electron --version should output v5.0.0.

To be clear, all commands create this error, but I'm using the --version flag for simplicity.

Actual Behavior

$ node_modules/.bin/electron --version
[2720:0425/142001.775056:FATAL:setuid_sandbox_host.cc(157)] The SUID sandbox helper binary was found, but is not configured correctly. Rather than run without sandboxing I'm aborting now. You need to make sure that /home/christianbundy/src/ssbc/patchwork/node_modules/electron/dist/chrome-sandbox is owned by root and has mode 4755.

Additional Information

$ stat /home/christianbundy/src/ssbc/patchwork/node_modules/electron/dist/chrome-sandbox
  Size: 5185424   	Blocks: 10128      IO Block: 4096   regular file
Device: 802h/2050d	Inode: 1465270     Links: 1
Access: (0755/-rwxr-xr-x)  Uid: ( 1000/christianbundy)   Gid: ( 1000/christianbundy)
Access: 2019-04-25 14:15:10.609279524 -0700
Modify: 2019-04-25 14:15:10.659278929 -0700
Change: 2019-04-25 14:15:10.659278929 -0700
 Birth: 2019-04-25 14:15:10.609279524 -0700

If I chown and chmod the file then it works fine, but my intuition is that npm install electron@latest should work without those commands. Is this expected behavior?

@nornagon
Copy link
Member

Unfortunately there's no way we can configure this correctly automatically, because setting the appropriate permissions requires root privileges and we don't want to ask for a root password during npm install.

Ideally, Arch would configure its kernel support unprivileged CLONE_NEWUSER and Chromium (and Electron) could use the namespace sandbox instead of relying on the old setuid sandbox. Apps that are distributed on Linux will need to incorporate this into their install process. See electron-userland/electron-installer-debian#184 and electron-userland/electron-installer-redhat#112 for example.

During development, we should probably print something out on npm install though with instructions if we detect that the namespace sandbox isn't available.

@christianbundy
Copy link
Author

Hey, thanks for the super quick response!

Does unprivileged CLONE_NEWUSER come from CONFIG_USER_NS=y? If so, that should be the current configuration.

Please let me know if there's anything I can do to help, or if this is expected output on Arch I'm happy to close -- I understand that there's some jankiness to be expected when running bleeding-edge distros and I don't mind resolving this in a PKGBUILD rather than expecting it to work perfectly straight out of npm. Cheers!

@nornagon
Copy link
Member

CONFIG_USER_NS=y enables the user namespaces feature, but they're still restricted to privileged users by default. This suggests sysctl kernel.unprivileged_userns_clone=1

@kitingChris
Copy link

Is there a possible workaround in the meantime until every linux distro enables those features?

@MarshallOfSound
Copy link
Member

@kitingChris The setuid sandbox IS the workaround. You just need to ensure that when developing / releasing an electron app your dev / packaging scripts set the permissions of the sandbox helper correctly as @nornagon linked above.

@vladimiry
Copy link

vladimiry commented Apr 28, 2019

Is there a possible workaround in the meantime until every linux distro enables those features?

See the original message:

If I chown and chmod the file then it works fine

Also see here #16631 (comment) So to make suid sandbox work you basically have to tweak the chrome-sandbox binary this way:

  • sudo chown root chrome-sandbox
  • chmod 4755 chrome-sandbox

The issue is more severe though if running appimage/snap packages, I have not yet revealed a decent workaround for these cases. It's working if appimage is executed with --no-sandbox arguemnt, but this is a hack.

@vladimiry
Copy link

@nornagon

because setting the appropriate permissions requires root privileges and we don't want to ask for a root password during npm install.

Executing chmod 4755 node_modules/electron/dist/chrome-sandbox doesn't require root permission and that should be enough to run such command for wrapping the app to deb/pacman/etc packages as when such packages get installed all the files including chrome-sandbox normally owned by root. So it would be great electron does chmod 4755 node_modules/electron/dist/chrome-sandbox automatically during installation process as then there would be no need to handle this case manually like mentioned here.

@vladimiry
Copy link

vladimiry commented Apr 28, 2019

CONFIG_USER_NS=y enables the user namespaces feature, but they're still restricted to privileged users by default. This suggests sysctl kernel.unprivileged_userns_clone=1

I confirm executing sudo sysctl kernel.unprivileged_userns_clone=1 is another workaround, related comment.

@burningTyger
Copy link

@vladimiry I needed to first chown and then chmod. The other way round it didn't work.

@vladimiry
Copy link

vladimiry commented Apr 28, 2019

@burningTyger you are right, I just have changed the original message.

@MarshallOfSound
Copy link
Member

@nornagon If we chmod 4755 out/Release/chrome-sandbox on CI will that permission be persisted once we zip it up or do we have to make this change in electron-download to fix the permission on DL?

@liberodark
Copy link

same here is bad new fonction for what need to change that... :(

vladimiry added a commit to vladimiry/ElectronMail that referenced this issue Apr 29, 2019
@nornagon
Copy link
Member

@MarshallOfSound zip does not support permissions, but ultimately the issue is not the chmod permission, but rather the owner. The setuid sandbox helper is suid to root, because it needs to perform functions that are only available to root. If it were possible to set the appropriate permissions without first gaining root privileges, that would be a very serious vulnerability in Linux. Fortunately for Linux, and unfortunately for us, that is not the case.

Here are the options as I see them:

  1. Change nothing in Electron. Recommend that developers enable unprivileged CLONE_USERNS on their kernel to allow the namespace sandbox to run instead of the setuid sandbox.
  2. Boot without sandbox if no sandboxing method is available only when booting an unpackaged app. If Electron is booting a packaged app, refuse to boot without sandbox.
  3. In all cases, if no sandboxing method is available, boot without sandboxing and print a warning.
  4. Disable sandboxing by default on Linux.

I'm leaning towards (2). It would ease development without compromising the security of the deployed app.

I'm not yet sure what to do about snap/flatpak, as I'm not familiar with their workings. It's possible that they already sandbox the app sufficiently that we can disable sandboxing altogether in that situation, as we do when building the Mac App Store version of Electron.

@nornagon nornagon self-assigned this Apr 29, 2019
@vladimiry
Copy link

As for now, I like more the first option.

  1. Boot without sandbox if no sandboxing method is available only when booting an unpackaged app. If Electron is booting a packaged app, refuse to boot without sandbox.

Such scenario would be somehow misleading. One might be successfully running unpackaged app without sandboxing, but there is a chance that the packaged app won't work the same way with enabled sandboxing. Like, for example, the case when you access the main process from the renderer process not through the remote interface. Or the case of wrapping the app to AppImage / Snap / Flatpak packages.

  1. In all cases, if no sandboxing method is available, boot without sandboxing and print a warning.

So a packaged app that was designed and developed as sandboxed might be executed without sandbox if no sandbox available. This doesn't sound good to me.

  1. Disable sandboxing by default on Linux.

What does it mean exactly? What would be the way to enable sandboxing on Linux in the way the app either starts or fails if no sandboxing available (the current situation, forced sandboxing).

@nornagon
Copy link
Member

I also like (1), but to defend (2) a little, the API exposed to the app wouldn't change when disabling the sandbox. The only thing we would disable is the OS-level sandbox. We would still load the app the same way, it just wouldn't be protected by the OS.

@vladimiry
Copy link

We would still load the app the same way, it just wouldn't be protected by the OS.

Then it sounds good to me too. Thanks for the explanation.

@Jelmerovereem
Copy link

For me sudo chown root chrome-sandbox & chmod 4755 chrome-sandbox didn't work.

The issue was that I did npm install electron --save-dev on my WSL(Windows Subsystem for Linux).

To install electron on Windows and run from WSL:

  • Uninstall electron npm uninstall electron
  • Change npm config platform export npm_config_platform=win32
  • Install electron npm install electron
  • Unset the environment variable unset npm_config_platform

Source: mayeaux/videodownloader#4 (comment)

@gerroon
Copy link

gerroon commented Nov 8, 2021

Please stop recommending sudo as the solution. Not every user on a system has sudo permissions. I do not get why a non system app needs sudo permissions. This issue makes pretty much all Electron apps being crippled on Debian and Arch which are the most installed and used Linux distributions.

Also --no-sandbox does not work

 ./tabby --no-sandbox

innerError Error: Cannot find module '../build/Debug/pty.node'
Require stack:
- /home/USER/apps/tabby/resources/app.asar/node_modules/@tabby-gang/node-pty/lib/unixTerminal.js
- /home/USER/apps/tabby/resources/app.asar/node_modules/@tabby-gang/node-pty/lib/index.js
- /home/USER/apps/tabby/resources/app.asar/dist/main.js
-
    at Module._resolveFilename (internal/modules/cjs/loader.js:887:15)
    at Function.n._resolveFilename (electron/js2c/browser_init.js:257:1128)
    at Module._load (internal/modules/cjs/loader.js:732:27)
    at Function.f._load (electron/js2c/asar_bundle.js:5:12913)
    at Module.require (internal/modules/cjs/loader.js:959:19)
    at require (/home/USER/apps/tabby/resources/app.asar/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at Object.<anonymous> (/home/USER/apps/tabby/resources/app.asar/node_modules/@tabby-gang/node-pty/lib/unixTerminal.js:33:15)
    at Module._compile (/home/USER/apps/tabby/resources/app.asar/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1108:10)
    at Module.load (internal/modules/cjs/loader.js:935:32) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/USER/apps/tabby/resources/app.asar/node_modules/@tabby-gang/node-pty/lib/unixTerminal.js',
    '/home/USER/apps/tabby/resources/app.asar/node_modules/@tabby-gang/node-pty/lib/index.js',
    '/home/USER/apps/tabby/resources/app.asar/dist/main.js',
    undefined
  ]
}



devDefiWeb added a commit to devDefiWeb/electron-mail-app that referenced this issue May 28, 2022
devDefiWeb added a commit to devDefiWeb/electron-mail-app that referenced this issue May 28, 2022
* The change disables the internal OS-level sandbox. So the app relies only on "strict" confinement for Snap and built-in isolation for AppImage.
* See electron/electron#17972
* TODO Snap: explore "allow-sandbox: true" plug, see:
  - https://forum.snapcraft.io/t/the-browser-support-interface/7775
  - https://docs.snapcraft.io/browser-support-interface
  - electron-userland/electron-builder#2100
mnvr added a commit to ente-io/ente that referenced this issue May 12, 2024
mnvr added a commit to ente-io/ente that referenced this issue May 12, 2024
mnvr added a commit to ente-io/ente that referenced this issue May 13, 2024
From toeverything/AFFiNE#6722 (comment)

> Disable sandboxing entirely by launching with --no-sandbox. Adding this
  argument from JS is unfortunately insufficient, as the GPU process is launched
  before the main process JS is run.

Ref:
* electron/electron#17972
jurgelenas added a commit to ExpressLRS/ExpressLRS-Configurator that referenced this issue May 28, 2024
Schneegans added a commit to kando-menu/kando that referenced this issue Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
5.0.x
Unsorted Issues
Development

No branches or pull requests