electron: The SUID sandbox helper binary was found, but is not configured correctly
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?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 42
- Comments: 155 (24 by maintainers)
Links to this issue
Commits related to this issue
- ci: enable "chrome-sandbox" binary permissions check on linux * SUID sandbox related, see https://github.com/electron/electron/issues/17972 — committed to vladimiry/ElectronMail by vladimiry 5 years ago
- ci: enable "chrome-sandbox" binary permissions check on linux * SUID sandbox related, see https://github.com/electron/electron/issues/17972 — committed to vladimiry/ElectronMail by vladimiry 5 years ago
- preload appimage/snap-packaged build app with "--no-sandbox" argument * The change disables the internal OS-level sandbox. So the app relies only on "strict" confinement for Snap and built-in isolati... — committed to vladimiry/ElectronMail by vladimiry 5 years ago
- sudo sysctl kernel.unprivileged_userns_clone=1 https://github.com/AppImage/appimage.github.io/pull/1564#issuecomment-491591127 https://github.com/electron/electron/issues/17972 [ci skip] — committed to AppImage/appimage.github.io by probonopd 5 years ago
- fix(snap): installation issue "The SUID sandbox helper binary was found, but is not configured correctly." https://github.com/electron/electron/issues/17972 — committed to unofficial-protonmail-desktop/application by kontrollanten 5 years ago
- fix(snap): installation issue "The SUID sandbox helper binary was found, but is not configured correctly." https://github.com/electron/electron/issues/17972 — committed to unofficial-protonmail-desktop/application by kontrollanten 5 years ago
- Downgrade electron to 4.2.5 we can't use version 5 before bug electron/electron#17972 is fixed — committed to deltachat/deltachat-desktop by nicodh 5 years ago
- Fix electro sandboxing issue Related to https://github.com/electron/electron/issues/17972 — committed to kepalas/com.meetfranz.Franz by kepalas 4 years ago
- Fix electro sandboxing issue Related to https://github.com/electron/electron/issues/17972 — committed to kepalas/com.meetfranz.Franz by kepalas 4 years ago
- Fix electron sandboxing issue Related to https://github.com/electron/electron/issues/17972, https://github.com/flatpak/flatpak/issues/3044 — committed to kepalas/com.meetfranz.Franz by kepalas 4 years ago
- Upgrade to Electron 6: New version of Electron has enable by default sandbox http://www.atom.pe/docs/api/sandbox-option/ There was some issues to migrate a new version of Electron for MagicMirror. U... — committed to roramirez/MagicMirror by roramirez 4 years ago
- linux desktop: need to add --no-sandbox, otherwise electron install needs root -- see https://github.com/electron/electron/issues/17972 — committed to ericmandel/js9 by ericmandel 4 years ago
- Fix electron sandboxing issue Related to electron/electron#17972, flatpak/flatpak#3044 — committed to flathub/com.discordapp.Discord by njallam 4 years ago
- Fix electron sanboxing issue Related to https://github.com/electron/electron/issues/17972, https://github.com/flatpak/flatpak/issues/3044 — committed to flathub/com.beakerbrowser.Beaker by G-Ray 4 years ago
- electron:serve task: add --no-sandbox option to UI On some Linux distributions the `electron:serve` task won't work without the `--no-sandbox` flag. see: https://github.com/electron/electron/is... — committed to yojoe/vue-cli-plugin-electron-builder by yojoe 4 years ago
- update the chrome-sandbox https://github.com/electron/electron/issues/17972 — committed to electron/electron by deleted user 4 years ago
- - Fixed mirrors dialog. - Fixed: https://github.com/electron/electron/issues/17972 — committed to sukebenet/dreamtime by kolessios 3 years ago
- ci: enable "chrome-sandbox" binary permissions check on linux * SUID sandbox related, see https://github.com/electron/electron/issues/17972 — committed to devDefiWeb/electron-mail-app by devDefiWeb 5 years ago
- preload appimage/snap-packaged build app with "--no-sandbox" argument * The change disables the internal OS-level sandbox. So the app relies only on "strict" confinement for Snap and built-in isolati... — committed to devDefiWeb/electron-mail-app by devDefiWeb 5 years ago
CONFIG_USER_NS=yenables the user namespaces feature, but they’re still restricted to privileged users by default. This suggestssysctl kernel.unprivileged_userns_clone=1I confirm executing
sudo sysctl kernel.unprivileged_userns_clone=1is another workaround, related comment.See the original message:
Also see here https://github.com/electron/electron/issues/16631#issuecomment-476082063 So to make suid sandbox work you basically have to tweak the
chrome-sandboxbinary this way:sudo chown root chrome-sandboxchmod 4755 chrome-sandboxThe 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-sandboxarguemnt, but this is a hack.I ran into this issue while trying to use
electronon WSL (WSL2 on my case). Even by using an X11 server, electron was not able to run over X11.I had to build electron for Windows, even if I run it inside WSL. After that, everything work as excepted The simplest way to do that:
npm uninstall electronexport npm_config_platform=win32npm install electronunset npm_config_platform@nornagon
Executing
chmod 4755 node_modules/electron/dist/chrome-sandboxdoesn’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 includingchrome-sandboxnormally owned by root. So it would be great electron doeschmod 4755 node_modules/electron/dist/chrome-sandboxautomatically during installation process as then there would be no need to handle this case manually like mentioned here.For me
sudo chown root chrome-sandbox&chmod 4755 chrome-sandboxdidn’t work.The issue was that I did
npm install electron --save-devon my WSL(Windows Subsystem for Linux).To install electron on Windows and run from WSL:
npm uninstall electronexport npm_config_platform=win32npm install electronunset npm_config_platformSource: https://github.com/mayeaux/videodownloader/issues/4#issuecomment-578429939
@vladimiry I needed to first chown and then chmod. The other way round it didn’t work.
Here’s the situation:
CLONE_NEWUSER. Some kernels are built with this feature restricted to privileged users out of an abundance of caution. You can read more about it here [lwn, 2016].CLONE_NEWUSERis unavailable, Chromium falls back to using a different sandboxing mechanism that requires a helper binary that is setuid to root. If this binary is not present or doesn’t have the right permissions (4755and owned by root), the sandbox will fail to boot.npm install, because we don’t want to ask for root access duringnpm install.There are two workarounds:
CLONE_NEWUSERin your kernel. Some kernels support changing this withsysctl kernel.unprivileged_userns_clone=1.--no-sandbox. Adding this argument from JS is unfortunately insufficient, as the GPU process is launched before the main process JS is run.We will not support automatically disabling the sandbox in Electron when these conditions are detected. You must ensure that your distributed packages to set the appropriate permissions. Most tools (at least electron-builder, electron-installer-snap, electron-installer-debian, and electron-installer-redhat) support this automatically and require no configuration from the developer. If you’re using a different tool that does not support this, please raise an issue on that tool and link to this comment.
I’m closing this issue because, as mentioned in the previous paragraph, we will not be changing the requirement that Electron in production requires access to a functioning sandbox unless explicitly instructed otherwise. However, to ease development, I have opened #19550 to track the option of automatically degrading to non-sandboxed mode when Electron is installed via
npm install, rather than via a distributed package.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
Yes, there is a way, it has been discussed before.
@nornagon so we can’t even run Electron 6 on Debian and there is no way we’re giving a chrome process root perms. The workarounds given are not sufficient from the user perspective.
There is absolutely no way messing with the customers computer is the way to go about this.
How about adding a
--sandboxflag and turn off the sandbox feature by default? This has a benefit of not screwing 99% of folks using Electron.I see this issue with WSL (Windows 10), Ubuntu 18.04 installed into WSL.
sudo sysctl kernel.unprivileged_userns_clone=1does not work.Using chown and chmod is also not an option.
For a better developer experience. We can set up a command as bellow within electron cli tool.
A command like electron --ConfigSandbox. The user will be aware and the sandbox can be easily configured. And even when it’s first run. We can ask them if they want to take the actions. y or n. And then all they need to do is enter the password. That way it will be done in a glance. And it will lead to a big user experience and win in time. Cause you’ll trust the vendor or the community. And go with it. In place of searching all over the net. And that’s even more valuable for the more beginners of us. And it’s nice in all cases.
@black-puppydog As I recall, the installer prompts you for a root password when you first install Debian on your machine. But yes, on Debian (or any other system that uses Debian’s kernel patch), you need to either have root access (via
sudoor otherwise), or run Electron apps with--no-sandbox.@ndorf In mainline Linux, user namespaces can be disabled by not compiling in the feature, but they cannot be enabled/disabled at run time or restricted to privileged processes only. Debian patches its kernels such that user namespaces are restricted to privileged processes by default, but can be enabled for all processes with a setting under
/proc/sys.The reason Debian restricts it is that unprivileged user namespaces are a serious security risk with a long history of vulnerabilities. Unprivileged user namespaces allow unprivileged processes access to a lot of kernel functionality (UID 0, capabilities, mount a file system, create a device inode, etc) that was restricted to privileged processes only for a very long time. Any kernel code relying on the assumption that unprivileged processes will never be able to do these things is vulnerable now that unprivileged processes suddenly are able to do these things.
@cuixiping it works 👍
I did
@p3x-robot I still tend to think that you have to admit that there is nothing to fix.
As for now, I like more the first option.
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
remoteinterface. Or the case of wrapping the app to AppImage / Snap / Flatpak packages.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.
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).
@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:
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.
This works well.
Pardon my boldness, but this is absolutely insane. Electron exposes the Node.js API even in renderer processes. Using/enabling Chromium’s sandbox in an Electron app is completely pointless, and as you all can see from the bug reports around GitHub pointing to this issue, it’s also highly counterproductive. Please disable it if possible.
Yeah, passing
--no-sandboxargument to the electron app binary in general is supposed to work around the issue.Depending on the installation package you could set the SUID permission bit (4755) to
chrome-sandboxbinary (for packages like deb, pacman, etc) or hardcode the--no-sandboxargument to the loader sh/bash script (for packages like Snap and AppImage). This is what I currently do and so there is no need to do anything for the app users (no sudo access required).The recent electron-builder release already comes with hardcoding the
--no-sandboxargument but only for the Snap package.@burningTyger you are right, I just have changed the original message.
@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.
If I remember things correctly, settings 4755 to appimage won’t solve the issue. You need to (one of):
--no-sandboxcommand line arg--no-sandboxembedded into the./AppRunscript located in your appimage file (so repackaging needed).I doubt you will find detailed information about the issue in any documentation. I’m not aware of any relevant docs.
--no-sandboxCLI argument.@shrinidhi111 4755 can be preserved when packaged, at least in the case of pacman/deb packages. The packages can also be tweaked on the specific-dist level, eg. As for the root owner, normally when the package installed from the repo on Linux the related files get root owner. In the case of AppImage build I repackage it and hardcode
--no-sandboxarg in the inner AppRun script as electron-builder doesn’t do that yet out from the box. Snap package is formed by electron-builder with hardcoded--no-sandboxarg (related fix added ~6 months ago).Yeap I use manjaro and i3wm, I took the same error but with this it’s working.
@pronebird chrome-sandbox binary definitely shouldn’t be 5MB, that’s a bug. Opened #20049 to fix it, thanks for pointing it out.
You’re certainly welcome to choose to disable sandboxing for your use case. It’s unfortunate that Chromium’s architecture makes it so that you have to pass
--no-sandboxon the command line directly rather than callingapp.commandLine.appendSwitch; ideally disabling the sandbox would be possible without necessitating a wrapper script. Hopefully with #20049 the concern of removing the binary will be ameliorated, since 200KB extra is much more reasonable to live with than 5MB.Using loader-like script/program which will add
--no-sandboxarg can also be considered as a workaround, so no end-user actions needed. Besides such loader could testuser namespacesupport first and add--no-sandboxonly if required.If anyone is looking for a solution to this check out @thomasnordquist’s solution or my adaptation of it, they work by disabling the sandbox under Linux.
@JCMais it sounds like Electron is incorrectly attempting to use the namespace sandbox within docker, even though it should be trying to use the suid sandbox. I’m not sure why that would be, but you can force the suid sandbox with
--disable-namespace-sandbox. If you launch docker with--privileged(or--cap-add SYS_ADMIN, or a custom seccomp profile that allows CLONE_NEWUSER), then namespaces will be available inside the sandbox and there’s no need for the setuid sandbox or its helper executable.Just to be clear, for Snaps there was more to it (namely, adding browser sandbox support as noted above). See the associated PR’s changes for details.
I agree that doing anything that would require root privileges during npm install is a non-starter. Which is why I did not list it as one of the options.
This is not considered as an option as far as I understand.
Of course, it does. But you can enable User Namespace sandboxing as an alternative
sudo sysctl kernel.unprivileged_userns_clone=1(enabled by default on Ubuntu but not on Arch).❌
chown root:root chrome-sandbox && chmod 4755 chrome-sandboxraises some red flags for me.Just to be very clear on what it does: It sets the SUID bit on
chrome-sandbox, which makes any user able to execute the file as root. This means that if there is any way to usechrome-sandboxmaliciously, or if the contents ever gets malicious, any user could become root.chrome-sandboxwould be a very interesting target for attack.I strongly recommend against doing this workaround on
npm install, because it would requiresudo(user needs to write password), it’s invasive and we might not understand the security consequences of doing so.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.