puppeteer: [Bug]: "No usable sandbox!" with user namespace cloning enabled

Minimal, reproducible example

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch(); // Fails

const page = await browser.newPage();
await page.setContent('<div>test</div>');

Background

The troubleshoot page discourages --no-sandbox in favor of user namespace cloning, but I’m having trouble getting it to work.

I’m using Ubuntu 24.04 (kernel 6.8.0-38-generic).

As far as I can tell namespace cloning is enabled: sudo sysctl kernel.unprivileged_userns_clone outputs kernel.unprivileged_userns_clone = 1.

(From what I understand, Ubuntu 24.04 has implemented stronger restrictions around unprivileged user namespaces, but I can only guess at if this issue is a side-effect effect of those changes.)

Expectation

Browser launches

Reality

Am getting the following error:

file:///home/dev/puppeteer-test/node_modules/@puppeteer/browsers/lib/esm/launch.js:301
                reject(new Error([
                       ^

Error: Failed to launch the browser process!
[421602:421602:0723/183305.941550:FATAL:zygote_host_impl_linux.cc(126)] No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/+/main/docs/linux/suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox.


TROUBLESHOOTING: https://pptr.dev/troubleshooting

    at ChildProcess.onClose (file:///home/dev/puppeteer-test/node_modules/@puppeteer/browsers/lib/esm/launch.js:301:24)
    at ChildProcess.emit (node:events:529:35)
    at ChildProcess._handle.onexit (node:internal/child_process:292:12)

Node.js v18.19.1

Puppeteer configuration file (if used)

No response

Puppeteer version

22.13.1

Node version

18.19.1

Package manager

yarn

Package manager version

1.15.2

Operating system

Linux

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 17 (2 by maintainers)

Commits related to this issue

Most upvoted comments

For GitHub Actions, I can confirm (after testing on some hobby projects) that the temporary workaround to replace runs-on: ubuntu-latest with runs-on: ubuntu-22.04 works.

ubuntu-latest was pointing to 22.04 but as of today (10/15/2024) it is pointing to 24.04. I am running puppeteer in a GitHub Action and was able to see the version change in the logs.

I downgraded my action to run against 22.04 (ubuntu-latest -> ubuntu-22.04). That seems to have ‘fixed’ the error for now or at least buys some time for me to investigate and decide how to work with the changes in ubuntu.

For GitHub Actions, I can confirm (after testing on some hobby projects) that the temporary workaround to replace runs-on: ubuntu-latest with runs-on: ubuntu-22.04 works.

Yes, this works, I confirm in 2025.

@lewistg I’m pretty sure you need to either install the browser to the path whitelisted in /etc/apparmor.d/chrome, or create a new AppArmor profile with the actual install path. See also this article about the same issue regarding Firefox: https://support.mozilla.org/en-US/kb/install-firefox-linux#w_security-features-warning (the formatting of the file quoted there is broken; refer to the format of the files on your machine and described in the man page)

This is how /etc/apparmor.d/chrome looks on my Ubuntu 24.04 installation:

# This profile allows everything and only exists to give the
# application a name instead of having the label "unconfined"

abi <abi/4.0>,
include <tunables/global>

profile chrome /opt/google/chrome/chrome flags=(unconfined) {
  userns,

  # Site-specific additions and overrides. See local/README for details.
  include if exists <local/chrome>
}

Note that the path also allows globbing (see the linked man page).

It fails as well. The error message seems to include instructions for Ubuntu:

[2423:2423:1016/062159.567901:FATAL:zygote_host_impl_linux.cc(128)] No usable sandbox! If you are running on Ubuntu 23.10+ or another Linux distro that has disabled unprivileged user namespaces with AppArmor, see https://chromium.googlesource.com/chromium/src/+/main/docs/security/apparmor-userns-restrictions.md. Otherwise seehttps://chromium.googlesource.com/chromium/src/+/main/docs/linux/suid_sandbox_development.md for more information on developing with the (older) SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox.

The issue is on the Ubuntu side. We now documented it here https://pptr.dev/troubleshooting#issues-with-apparmor-on-ubuntu You would need to configure Ubuntu to allow user namespace cloning to make it work with Ubuntu versions that have this restriction.

Re-opening as requested. I’ll let the puppeteer maintainers re-close as they see fit

@lewistg can you reopen this issue while sandbox-problem won’t be fixed on ubuntu-latest/Ubuntu 24.04?

I solved this editing file etc/apparmor.d/unprivileged_userns

profile unprivileged_userns { #audit deny capability, <-- commented

and adding capability sys_admin, capability sys_chroot, capability sys_ptrace, capability ipc_lock, capability sys_resource,