Docker container runs as root due to missing USER directive and COMPOSER_ALLOW_SUPERUSER=1 #11
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The production Dockerfile uses
php:8.2-apache-bullseyeas its base and installs all dependencies and application files as root. NoUSERdirective is present anywhere in the file.ENV COMPOSER_ALLOW_SUPERUSER 1explicitly suppresses Composer's own warning about running as root, masking the issue.Location
Dockerfile, line 15 (ENV COMPOSER_ALLOW_SUPERUSER 1) and line 35 (CMD ["apache2-foreground"]) — noUSERdirective present.Risk
If an attacker achieves remote code execution via any future Symfony, PHP, or application-level vulnerability, the process runs with root privileges inside the container. This maximises blast radius: writing to any path, installing tools, reading all secrets mounted as files, and potentially escaping container boundaries if the Docker socket or privileged capabilities are exposed.
Suggested fix direction
Add a
USER www-datadirective before theCMDinstruction. Apache already runs worker processes aswww-data; making the master process unprivileged limits the damage from RCE. Ensure application files are readable bywww-dataand removeCOMPOSER_ALLOW_SUPERUSER.Severity
minor
Found by
Automated audit by Claude Code