Skip to content
Business logic Disclosed report Intermediate

In Dockerized Environments, Failing to Read config.php Grants Any Anonymous User Full Admin Access

When a Dockerised Nextcloud container temporarily cannot read its config file, it treats the instance as uninstalled and serves the setup installer, writing a new config that marks it as not installed. Any anonymous user who then reaches the installer can create a new admin account and take full control of the existing installation.

theguynamedguy86 Follow

Originally disclosed on HackerOne

High 8.7 View original
  • Triaged in 9 days
  • Fixed in 3 months
  • Disclosed after 4 months

Consider this deployment:

  • Nextcloud is already installed in a Dockerized environment.
  • There are two Nextcloud containers running in the environment.
  • Both containers share the same MySQL database.
  • Both containers share the same data (/var/www/html/data) and config (/var/www/html/config) via NFS-mounted or SMB-mounted Docker volumes.
  • All of the values Nextcloud needs to complete first-run setup (database name and credentials, admin credentials, etc) are provided to both containers via environment variables (NEXTCLOUD_ADMIN_USER, NEXTCLOUD_ADMIN_PASSWORD, MYSQL_HOST, MYSQL_DATABASE, MYSQL_USER, MYSQL_PASSWORD).

Now, consider that one or both of the containers encounter an issue reading /var/www/html/config/config.php. This could be caused by an of the following:

  • Transient failure connecting to the NFS/SMB server at the time either container is launching or restarting (especially in response to a failed Liveness check).
  • Timeout or other transient failure in communication with the NFS/SMB server while the container is already running.
  • One container attempting to read config.php while the other container is writing to the file, causing an incomplete read (possibly making the file look empty).

In this situation, Nextcloud will assume that it is NOT installed (since the config seems empty). As a result, Nextcloud will launch the installer the next time ANY user requests a page from the container that temporarily cannot read the config.php file. This causes that instance of Nextcloud to overwrite the config.php with a new file that has the same database credentials as the old file (populating the credentials from the environment variables), but the new config flags Nextcloud as not yet being installed (i.e. installed is set to FALSE). Some time later, assuming that NFS/SMB services have been restored to normal (e.g. the transient issue has disappeared), ALL containers will now happily serve up the Nextcloud installer to ANY user because the container that failed to read the configuration file wrote a new one with a newer timestamp that indicates Nextcloud is not installed.

From here, ANY user who stumbles upon the installer page can provide ANY username and password and end up with a new admin account with full access to the existing Nextcloud installation.

Nextcloud should NOT allow the installer to be run if ANY database tables already exist in the target database. If this is not possible, Nextcloud should at least not allow the installer to be run if any admin users exist in the target database.

Impact

An attacker interested in taking over an existing installation of Nextcloud could write a script to frequently monitor that installation until such a time as that installation suffers a temporary issue reading config.php and starts serving up the installer. At that point, the attacker can hop over to the installation, finish the setup process, and create a username and password of their choice to gain full admin access to the entire Nextcloud installation.

With admin access, the attacker can lock out all of the existing users of the system, change system settings, and download or erase all of the files on the Nextcloud installation.

The original report as published on HackerOne, by theguynamedguy86. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the installer does not check whether the target database already contains tables or admin users before allowing setup to run again.

Impact

An attacker could monitor the installation and, once the installer appears, create an admin account to lock out users, change settings, and download or erase all files.

What the attacker needed

Dockerised Nextcloud with shared config volume; Transient failure reading config.php; Attacker reaches installer page

The fix

The installer should refuse to run when the target database already contains tables, or at least when admin users already exist.

How it was found

  1. Run two Nextcloud containers sharing one database and shared config and data volumes.
  2. Cause a transient failure reading the config file, such as an NFS or SMB timeout or a partial read during a concurrent write.
  3. Request a page from the affected container so it launches the installer and rewrites the config as not installed.
  4. Wait for storage to recover so all containers serve the installer to any visitor.
  5. Complete the installer with a chosen username and password to obtain a new admin account.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

Nextcloud is a file-sharing server. Its setup wizard is meant to run only once, on a fresh install. Here, a temporary storage glitch makes the server forget it was already set up, so it shows the wizard again to anyone, and whoever finishes it becomes an administrator.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More from Nextcloud

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.