Chrome startup failure with --no-sandbox in non-root Puppeteer containers
0 reputation · 23 Oct 2020, 04:30 UTC
0 reputation · 23 Oct 2020, 04:30 UTC
A Puppeteer launch configuration that specifies --no-sandbox and --disable-setuid-sandbox succeeds when the process runs as root on a local development workstation. Deploying an identical puppeteer.launch() call to a production environment where the process operates as a non-root user inside a container triggers Chromium startup failure, with the browser exiting before any navigation occurs. The root cause involves container-runtime enforcement of user namespaces, seccomp profiles, and Chromium's sandbox integrity checks, but the exact conditions under which the flags transition from functional to ineffective are not standardized across base images. Furthermore, the presence or absence of a bundled Chromium binary, version mismatches handled by PUPPETEER_SKIP_CHROMIUM_DOWNLOAD, and container resource limits such as /dev/shm size may interact with the sandbox behavior, creating a configuration space that is difficult to validate without production-equivalent testing.
Under what container user and group identifier range does Puppeteer's default sandbox behavior succeed or fail? Does --disable-dev-shm-usage need to accompany --no-sandbox to prevent out-of-memory conditions in non-root containers, or does it address a separate subsystem? When PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 is set, what minimum Chromium version and binary structure must pre-exist in the production image to avoid a missing-binary error?
36775 reputation · 23 Oct 2020, 04:51 UTC
There is no fixed container UID or GID range where Puppeteer's default Chromium sandbox reliably succeeds or fails. Numeric identifiers alone do not determine the outcome. Default sandbox behavior depends on whether the image ships a root-owned, setuid chrome-sandbox helper, whether the kernel and container runtime permit unprivileged user namespaces, and whether required capabilities are present. Non-root users (UID != 0) commonly fail when the helper is missing, not setuid, or when user namespaces are restricted by the runtime.
--no-sandbox disables Chromium's process sandbox. It does not touch shared memory.--disable-dev-shm-usage addresses a separate subsystem: it moves Chromium shared memory from /dev/shm to disk. It is not required by --no-sandbox and is not a sandbox substitute./dev/shm can cause out-of-memory or crashes independent of sandbox flags.PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 stops Puppeteer from fetching Chromium. The image must pre-install a Chromium/Chrome binary at the path Puppeteer resolves, with matching DevTools Protocol compatibility and all dynamic libraries present. Puppeteer does not publish a universal minimum Chromium version for this mode.Root on your workstation can launch with --no-sandbox because the flag bypasses the normal user restriction. In a non-root container, Chromium attempts its default sandbox path. If chrome-sandbox is absent or not executable with the setuid bit, or if the runtime blocks user namespaces or relevant seccomp syscalls, the browser exits before navigation. /dev/shm exhaustion can produce a similar early exit, so the two causes must be isolated.
id inside the container as the application user to confirm the UID and GID.ls -l on chrome-sandbox and chrome to confirm ownership and the setuid bit.df -h /dev/shm. If it is small, test with --disable-dev-shm-usage to see whether the failure is memory-related rather than sandbox-related.chrome --version and chrome --headless --no-sandbox --dump-dom about:blank. If this fails, the image or runtime is the problem, not Puppeteer launch options.PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 is set, verify the binary exists at Puppeteer's resolved executablePath and run ldd against it to check for missing shared libraries.Confirm whether the production image contains a root-owned, setuid chrome-sandbox helper at Puppeteer's expected path. That detail changes the recommendation: if present, default sandbox may work for non-root users; if absent, you need --no-sandbox in a trusted isolated container or runtime changes to permit user namespaces.
--no-sandbox as the non-root application user; record exit code and stderr./proc/sys/kernel/unprivileged_userns_clone if available, and review the container runtime user-namespace and seccomp configuration.--no-sandbox; it removes a major Chromium security boundary.This assumes a Linux container running Puppeteer against Chromium as a non-root application user. It does not assume a specific Puppeteer or Chromium version, because Puppeteer publishes no universal minimum version for skipped downloads and protocol drift can cause failures. This is a conservative draft; verify runtime user-namespace and seccomp behavior in your environment before relying on --no-sandbox in production.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.