Dev.to Security 🔐 Cybersecurity 👁 2 📖 11 min read

[CVE-2026-132165] (Fail2Install): How "Just a Resource Shortage

CVSS 9.8 (Critical) · CWE-636 (Not Failing Securely) · Unauthenticated Remote Code Execution · Added to CISA KEV (2026-11-24) Affected versions: Drupal 8.9, 9, 10, 11 (Drupal 7 and pre-8.9 releases are not affected)

[CVE-2026-132165] (Fail2Install): How "Just a Resource Shortage

CVSS 9.8 (Critical) · CWE-636 (Not Failing Securely) · Unauthenticated Remote Code Execution · Added to CISA KEV (2026-11-24)

  • Affected versions: Drupal 8.9, 9, 10, 11 (Drupal 7 and pre-8.9 releases are not affected)
  • Patched versions: 11.4.13 / 11.3.22 / 10.6.22 (2026-11-18, SA-CORE-2026-017, commit a15a19b)
  • Discovery / analysis: Anthropic OSS Scanner (initial report, ANT-2026-GMRPK0BU) → independently rediscovered by Searchlight Cyber researchers (Kevin Gervot, Adam Kues), who published a technical write-up under the name "Fail2Install"
  • Real-world exploitation: The Drupal Security Team confirmed signs of exploitation on live sites starting around 2026-11-19 19:00 UTC — one day after the patch shipped

TL;DR

Drupal's installer (install.php) decides whether a site is "already installed" by testing a database connection. If you deliberately exhaust ordinary server resource limits — open file count, concurrent DB connections, or ephemeral TCP ports — that decision flips. As a result, the installer reopens on a live, running site. The attacker then picks SQLite as the database driver, sets the database file's extension to .php, and gets Drupal to write a fake database file that contains attacker code inside the web root. Finally, a loose regular expression in Apache's .htaccess is bypassed to execute that file.

The core idea: a condition normally treated purely as an availability problem (DoS) is turned, through Drupal's error-handling logic, into a stepping stone for authentication bypass plus remote code execution.

1. Why the Installer Can Reopen — install.php's Three-Stage Check

On every request, Drupal's /core/install.php makes a total of three database connection attempts to determine "is this site already installed?" The problem lies in how the results of those three attempts are combined.

Check #1: Basic connection test (failure doesn't stop installation)

$install_state['database_verified'] = install_verify_database_settings($site_path);

function install_verify_database_settings($site_path) {
  if ($database = Database::getConnectionInfo()) {
    $database = $database['default'];
    $settings_file = './' . $site_path . '/settings.php';
    $errors = install_database_errors($database, $settings_file);
    if (empty($errors)) {
      return TRUE;
    }
  }
  return FALSE;
}

In plain terms: Drupal first tries to connect using the DB credentials stored in settings.php. If that fails, $install_state['database_verified'] becomes FALSE — but the installation process does not stop here. It's simply recorded as "DB connection not yet confirmed."

Internally, the actual connection is performed by the following connect() function.

protected function connect() {
  try {
    Database::setActiveConnection();
    Database::getConnection();
    $this->pass('Drupal can CONNECT to the database ok.');
  }
  catch (\Exception $e) {
    $this->fail(/* ... */);
    return FALSE;
  }
  return TRUE;
}

If the database server throws something like SQLSTATE[HY000] [1040] Too many connections here, it's simply recorded as a failure in the catch block, and execution quietly moves on.

Check #2: "Is this an existing install?" — the real problem

$existing_install = FALSE;
if (Database::getConnectionInfo()) {
  try {
    $existing_install = Database::getConnection()->schema()->tableExists($table);
  }
  // Don't throw an error even if the query fails — the DB might not be ready yet.
  catch (\Exception) {
  }
}
if ($existing_install) {
  throw new AlreadyInstalledException(\Drupal::service('string_translation'));
}

What this code is trying to do: "if Drupal's tables already exist in the DB → throw AlreadyInstalledException and block installation." Under normal conditions this is perfectly reasonable logic.

But as the comment itself admits, when the query fails, the exception is silently swallowed. If Check #1 has just suffered a DB connection failure, this second tableExists() call is likely to fail for exactly the same resource-exhaustion reason. From the code's perspective, though, there's no way to distinguish "the query failed" from "the table doesn't exist" — both end up setting $existing_install = FALSE (i.e., "this is a fresh, uninstalled site").

→ This is the moment a perfectly healthy, running production site gets misjudged as "not yet installed."

Check #3: The final gate — succeed here, and it's game over

$errors = install_database_errors($database, $settings_file);

if (count($errors)) {
  $requirements['database_install_errors'] = [
    'title' => t('Database settings'),
    'description' => SiteSettingsForm::getDatabaseErrorsTemplate($errors),
    'severity' => RequirementSeverity::Error,
  ];
}

$severity = RequirementSeverity::maxSeverityFromRequirements($requirements);

if ($severity === RequirementSeverity::Error) {
  $build['#title'] = t('Requirements problem');
  $build['#suffix'] = t('Check the messages and <a href=":url">try again</a>.', [':url' => drupal_requirements_url($severity)]);
  return $build;
}

Drupal makes one more connection attempt here. If it fails again, a "Requirements problem" screen appears and the process stops. But if this attempt succeeds, the error list is empty, the condition above is passed, and Drupal starts a brand-new installation process from scratch.

In short, the attacker needs exactly one condition to hold:

Check #1 FAILS → Check #2 FAILS (silently ignored) → Check #3 SUCCEEDS

If, within the short window of a single HTTP request handling these three DB connection attempts, the exhausted resource (a DB connection slot or a TCP port) happens to free up "just in time" for the third attempt, this exact sequence reproduces itself.

2. Turning "the Server Is Just Busy" Into a Security Boundary Bypass — Three Resource-Exhaustion Techniques

The Searchlight Cyber researchers first demonstrate that this pattern isn't unique to Drupal — it's a general attack technique applicable to any code that catches a resource-limit error and falls back to an unsafe default behavior. Consider this illustrative example:

files = {}
DEFAULT_CONFIG = {"requires_auth": False}

@app.get("/file/{key}")
def file(key: str):
    files[key] = open("data.txt", encoding="utf-8")  # file descriptors keep piling up
    return files[key].read()

@app.get("/admin")
def admin():
    try:
        with open("config.json", encoding="utf-8") as config_file:
            config = json.load(config_file)
    except OSError:
        config = DEFAULT_CONFIG   # falls back to "no auth required" if the file can't be opened!

    return {"access": "denied" if config["requires_auth"] else "admin"}

Repeatedly calling /file/{key} with different key values piles up file descriptors until the process hits its RLIMIT_NOFILE (the open-file-count limit). Once there, calling /admin triggers an EMFILE: Too many open files error while trying to open config.json, and except OSError catches it, falling through to the unsafe default requires_auth: False. This is the archetype of the pattern that "turns an availability problem into a security-boundary-bypass primitive."

The three resources actually exploited against Drupal are:

① EMFILE — the open-file-count limit

RLIMIT_NOFILE caps how many files (including sockets and pipes) a process can have open simultaneously. systemd's defaults are soft 1,024 / hard 524,288, and most runtimes — PHP (Apache/FPM), Python, Ruby, and more — inherit these defaults as-is.

② The DB connection limit (max_connections) — the key lever for this attack

Database Default connection limit
PostgreSQL 18.6 (Docker) 100 (including 3 reserved slots → 97 effectively usable)
MySQL 8.4.9 (Docker) 151 (including 1 reserved for the admin)

Meanwhile, on the web-server/runtime side, concurrency looks like this:

Deployment combination Max concurrent workers
PHP 8.5 + Apache (mod_php, prefork) up to 150
PHP 8.5-FPM pm.max_children = 5 by default

This is exactly why Apache + PostgreSQL turns out to be the easiest combination to attack. Since Apache's worker maximum (150) exceeds PostgreSQL's connection slot count (100), simply firing off more than 100 concurrent requests is enough to reproduce a SQLSTATE[HY000] [1040] Too many connections error.

③ TCP TIME_WAIT — the fallback lever when the worker count is low, as with PHP-FPM

PHP-FPM only has 5 workers by default, so concurrent requests alone can't exhaust 150 DB connections. Instead, the researchers leveraged Linux TCP's TIME_WAIT state. Whichever side closes a TCP connection first (sends the FIN first) holds that connection tuple in TIME_WAIT for roughly 60 seconds, and Linux's default ephemeral port range is only 32768–60999 (28,232 ports). By continuously creating about 471 new connections per second, enough to fill that entire port pool with TIME_WAIT entries, any subsequent new connection out to the database fails with SQLSTATE[HY000] [2002] Cannot assign requested address.

3. Concrete Triggering Methods for Each Drupal Deployment Combination

Apache + PostgreSQL (the easiest)

An asset route was used as a convenient endpoint for holding a connection open for a long time.

GET /sites/default/files/css/css_x.css?theme=olivero&delta=0&language=en&include=<compressed-data>&_format=json HTTP/1.1
Host: <drupal-host>
Accept-Encoding: identity

This endpoint decompresses the value of the include parameter and reflects it directly into an error message; using compression, a small request can be made to produce a large response (= more time spent holding the DB connection open). By tuning the volume of concurrent requests to sit right around PostgreSQL's max_connections, you can time it so Checks #1 and #2 fail together, and Check #3 immediately after succeeds.

Apache + MySQL

MySQL has a more generous connection limit than PostgreSQL (151), so reaching the limit purely by concurrency alone is harder. Instead, the researchers found a way to make a single request consume two DB connections. Drupal's logging module (dblog) contains the following retry logic:

$context['referer'] = $request->headers->get('Referer', '');
// ...
try {
  $this->connection->insert('watchdog')->fields([ /* ... */ 'referer' => $context['referer'] /* ... */ ])->execute();
}
catch (\Exception $e) {
  if (($e instanceof DatabaseException || $e instanceof \PDOException) &&
      $this->connection->getTarget() != self::DEDICATED_DBLOG_CONNECTION_TARGET) {
    // Open a new, "separate" dedicated connection and retry!
    $key = $this->connection->getKey();
    $info = Database::getConnectionInfo($key);
    Database::addConnectionInfo($key, self::DEDICATED_DBLOG_CONNECTION_TARGET, $info['default']);
    $this->connection = Database::getConnection(self::DEDICATED_DBLOG_CONNECTION_TARGET, $key);
    $this->log($level, $message, $context);
  }
  else {
    throw $e;
  }
}

If the logged Referer header value contains a byte that's invalid in UTF-8 (0xFF), MySQL rejects the INSERT with an Incorrect string value error, because of the utf8mb4 charset Drupal uses. The code detects this failure and opens one additional dedicated logging connection — entirely separate from the original — to retry the write, meaning each request consumes two DB connections instead of one. This effectively halves the number of requests needed, making it realistic to exhaust even MySQL's 151-connection limit.

PHP-FPM + PostgreSQL/MySQL (the trickiest)

With only 5 workers, PHP-FPM can't fill up connection limits through concurrency alone. So the TCP TIME_WAIT exhaustion technique is used instead. The researchers initially tried a slow-responding endpoint, found the benchmark results disappointing, and reportedly used AI assistance to find a much faster endpoint:

POST /core/authorize.php HTTP/1.1
Host: <drupal-host>
X-HTTP-Method-Override: GET
Content-Length: 0

When the X-HTTP-Method-Override header tries to turn the request into a GET, one of Drupal's security modules immediately rejects it and returns an empty HTTP 400 response right after opening a DB connection. This lets the attacker cycle through TCP connect/disconnect at hundreds of iterations per second, making it practically possible to fill all 28,232 ephemeral ports with TIME_WAIT entries even on a modest 4-vCPU server.

4. From a Reopened Installer to Code Execution

Walking through the "textbook" path — reinstalling, creating a fresh admin account, and installing modules — is possible, but the researchers found a far more direct shortcut: the SQLite driver supported by Drupal's installer.

Pointing the SQLite database path at a .php file

public static function open(array &$connection_options = []) {
  // ...
  $sqlite = new SqliteConnection(
    'sqlite:' . $connection_options['database'],
    '', '', $connection_options['pdo']
  );
}

The SQLite connection string uses the user-supplied database path without any validation whatsoever. Since the installer lets users supply this path directly, a request like the following creates a SQLite database file with a .php extension inside the web root:

POST /core/install.php?langcode=en&profile=standard HTTP/1.1
Content-Type: application/x-www-form-urlencoded

driver=Drupal%5Csqlite%5CDriver%5CDatabase%5Csqlite&...[database]=%2Fopt%2Fdrupal%2Fweb%2Fmodules%2Fdrupal-rce.php&...

Because SQLite's own file format is a simple binary structure, this produces an odd hybrid: a file that is simultaneously a valid database file and, as far as the web server is concerned, "a .php file."

Planting PHP code via the site name field

Once installation reaches the "site configuration" step, the site name the user supplies is written directly into the SQLite (.php) file that was just created.

POST <installer-configuration-url> HTTP/1.1
Cookie: <installer-session>

site_name=%3C%3Fphp+echo+%22RCE%22%3B+__halt_compiler%28%29%3B&...

The PHP code <?php echo "RCE"; __halt_compiler(); ?> placed into site_name is written byte-for-byte into the SQLite file. __halt_compiler() is used to make sure the PHP parser doesn't choke on the binary SQLite garbage that follows — it forces PHP parsing to stop entirely at that point.

Breaking through .htaccess to get execution

Drupal's default .htaccess only allows execution of PHP files directly under /core (install.php, authorize.php, etc.), and blocks every other PHP file from executing.

# install.php, authorize.php etc. directly under /core are allowed to execute
RewriteCond %{REQUEST_URI} !/core/[^/]*\.php$

# Every other .php request that doesn't match the above is blocked
RewriteRule "^(.+/.*|autoload)\.php($|/)" - [F]

The problem is that the condition !/core/[^/]*\.php$ only checks the end of the URI and doesn't care about the start of the path. That makes a request like this possible:

GET /modules/drupal-rce.php/core/x.php HTTP/1.1

Since this URI ends with /core/x.php, .htaccess mistakes it for an "allowed core PHP file" and doesn't block it. But the file Apache actually executes is the one at the beginning of the path, /modules/drupal-rce.php, while the trailing /core/x.php is just treated as PATH_INFO (extra path information appended after the actual file path). In the end, the drupal-rce.php file the attacker planted earlier (which looks like a SQLite DB but contains PHP code inside) runs as-is, completing unauthenticated remote code execution.

5. Why Older Versions (Drupal 7, pre-8.9) Are Not Affected

This whole chain stems from a design change introduced in Drupal 8.9: "if an error occurs, don't trust existing configuration — assume a fresh install is needed." Older versions behave differently.

  • Drupal 7: Even if DB verification fails, if settings.php already contains DB configuration, installation is blocked outright.
  • Pre-8.9: Likewise, on DB verification failure, if stored connection information exists, an AlreadyInstalledException is thrown immediately.

In other words, older versions were fail-closed by design — trusting "whether a local settings file exists" as the basis for trust — whereas the vulnerable versions had shifted to a fail-open design that trusts "the result of a database query made right now" instead.

Timeline

Date Event
2026-10-27 Pre-auth RCE first confirmed on an Apache + PostgreSQL combination
2026-10-28 Local RCE chain confirmed on Apache + MySQL and PHP-FPM + PostgreSQL/MySQL combinations as well
2026-11-02 – 05 Benchmarking, optimization, and documentation of the PHP-FPM technique
2026-11-18 Drupal publishes SA-CORE-2026-017 and ships patches (11.4.13 / 11.3.22 / 10.6.22)
~2026-11-19 19:00 UTC Exploitation confirmed on live sites (confirmed by the Drupal Security Team)
2026-11-24 Added to the CISA KEV catalog, with a federal remediation deadline of 11-27
📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.