CVE-2020-26253 (published 2020-12-08T02:15Z)

Kirby is a CMS. In Kirby CMS (getkirby/cms) before version 3.3.6, and Kirby Panel before version 2.5.14 there is a vulnerability in which the admin panel may be accessed if hosted on a .dev domain. In order to protect new installations on public servers that don't have an admin account for the Panel yet, we block account registration there by default. This is a security feature, which we implemented years ago in Kirby 2. It helps to avoid that you forget registering your first admin account on a public server. In this case – without our security block – someone else might theoretically be able to find your site, find out it's running on Kirby, find the Panel and then register the account first. It's an unlikely situation, but it's still a certain risk. To be able to register the first Panel account on a public server, you have to enforce the installer via a config setting. This helps to push all users to the best practice of registering your first Panel account on your local machine and upload it together with the rest of the site. This installation block implementation in Kirby versions before 3.3.6 still assumed that .dev domains are local domains, which is no longer true. In the meantime, those domains became publicly available. This means that our installation block is no longer working as expected if you use a .dev domain for your Kirby site. Additionally the local installation check may also fail if your site is behind a reverse proxy. You are only affected if you use a .dev domain or your site is behind a reverse proxy and you have not yet registered your first Panel account on the public server and someone finds your site and tries to login at `yourdomain.dev/panel` before you register your first account. You are not affected if you have already created one or multiple Panel accounts (no matter if on a .dev domain or behind a reverse proxy). The problem has been patched in Kirby 3.3.6. Please upgrade to this or a later version to fix the vulnerability.

Severity: MEDIUM
CVSS v2 base score: 4.3 (AV:N/AC:M/Au:N/C:N/I:P/A:N)
CVSS v3 base score: 5.9, MEDIUM (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N)

Weakness information:
cwe_id: CWE-346
cwe_name: Origin Validation Error
description: The product does not properly verify that the source of data or communication is valid.
extended_description: 
            
            
            
         
         

Fix information:
repo_url: https://github.com/getkirby-v2/panel
commit_details: repo_url: https://github.com/getkirby-v2/panel
author: Bastian Allgeier
author_date: 2020-12-01 11:11:11+01:00
msg: Better check for local environments
repository: repo_url: https://github.com/getkirby-v2/panel
repo_name: getkirby-v2/panel
description: This is the deprecated admin panel for Kirby v2.
repo_language: PHP
owner: getkirby-v2
file_changes: filename: panel.php
change_type: ModificationType.MODIFY
diff: @@ -493,13 +493,47 @@ class Panel {
   }
 
   public function isLocal() {
-    $localhosts = array('::1', '127.0.0.1', '0.0.0.0');
-    return (
-      in_array(server::get('SERVER_ADDR'), $localhosts) ||
-      server::get('SERVER_NAME') == 'localhost' ||
-      str::endsWith(server::get('SERVER_NAME'), '.localhost') ||
-      str::endsWith(server::get('SERVER_NAME'), '.test')
-    );
+
+    $host = server::get('SERVER_NAME');
+    $ip   = server::get('SERVER_ADDR');
+
+    if ($host === 'localhost') {
+      return true;
+    }
+
+    if (str::endsWith($host, '.localhost') === true) {
+      return true;
+    }
+
+    if (str::endsWith($host, '.local') === true) {
+      return true;
+    }
+
+    if (str::endsWith($host, '.test') === true) {
+      return true;
+    }
+
+    if (in_array($ip, ['::1', '127.0.0.1']) === true) {
+
+      if (
+        isset($_SERVER['HTTP_X_FORWARDED_FOR']) === true &&
+        in_array($_SERVER['HTTP_X_FORWARDED_FOR'], ['::1', '127.0.0.1']) === false
+      ) {
+        return false;
+      }
+
+      if (
+        isset($_SERVER['HTTP_CLIENT_IP']) === true &&
+        in_array($_SERVER['HTTP_CLIENT_IP'], ['::1', '127.0.0.1']) === false
+      ) {
+        return false;
+      }
+
+      // no reverse proxy or the real client also comes from localhost
+      return true;
+    }
+
+    return false;
   }
 
   public function notify($text) {

programming_language: PHP