CVE-2023-27577 (published 2023-03-10T21:15Z)

flarum is a forum software package for building communities. In versions prior to 1.7.0 an admin account which has already been compromised by an attacker may use a vulnerability in the `LESS` parser which can be exploited to read sensitive files on the server through the use of path traversal techniques. An attacker can achieve this by providing an absolute path to a sensitive file in the custom `LESS` setting, which the `LESS` parser will then read. For example, an attacker could use the following code to read the contents of the `/etc/passwd` file on a linux machine. The scope of what files are vulnerable will depend on the permissions given to the running flarum process. The vulnerability has been addressed in version `1.7`. Users should upgrade to this version to mitigate the vulnerability. Users unable to upgrade may mitigate the vulnerability by ensuring that their admin accounts are secured with strong passwords and follow other best practices for account security. Additionally, users can limit the exposure of sensitive files on the server by implementing appropriate file permissions and access controls at the operating system level.\n

CVSS v3 base score: 4.9, MEDIUM (CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:N/A:N)

Weakness information:
cwe_id: CWE-22
cwe_name: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
description: The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.
extended_description: 
            Many file operations are intended to take place within a restricted directory. By using special elements such as ".." and "/" separators, attackers can escape outside of the restricted location to access files or directories that are elsewhere on the system. One of the most common special elements is the "../" sequence, which in most modern operating systems is interpreted as the parent directory of the current location. This is referred to as relative path traversal. Path traversal also covers the use of absolute pathnames such as "/usr/local/bin" to access unexpected files. This is referred to as absolute path traversal.
         
         

Fix information:
repo_url: https://github.com/flarum/framework
commit_details: repo_url: https://github.com/flarum/framework
author: Sami Mazouz
author_date: 2023-03-04 20:38:19+01:00
msg: fix: disallow certain dangerous LESS features

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
repository: repo_url: https://github.com/flarum/framework
repo_name: flarum/framework
description: Simple forum software for building great communities.
repo_language: PHP
owner: flarum
file_changes: filename: core.yml
change_type: ModificationType.MODIFY
diff: @@ -18,6 +18,7 @@ core:
       custom_footer_text: => core.ref.custom_footer_text
       custom_header_heading: Custom Header
       custom_header_text: => core.ref.custom_header_text
+      custom_styles_cannot_use_less_features: "The @import and data-uri features are not allowed in custom LESS."
       custom_styles_heading: Custom Styles
       custom_styles_text: Customize your forum's appearance by adding your own Less/CSS code to be applied on top of Flarum's default styles.
       dark_mode_label: Dark Mode

programming_language: Ruby
filename: ValidateCustomLess.php
change_type: ModificationType.MODIFY
diff: @@ -21,6 +21,7 @@ use Illuminate\Filesystem\FilesystemAdapter;
 use League\Flysystem\Adapter\NullAdapter;
 use League\Flysystem\Filesystem;
 use Less_Exception_Parser;
+use Symfony\Contracts\Translation\TranslatorInterface;
 
 /**
  * @internal
@@ -61,6 +62,15 @@ class ValidateCustomLess
             return;
         }
 
+        // Restrict what features can be used in custom LESS
+        if (preg_match('/@import|data-uri\s*\(/i', $event->settings['custom_less'])) {
+            $translator = $this->container->make(TranslatorInterface::class);
+
+            throw new ValidationException([
+                'custom_less' => $translator->trans('core.admin.appearance.custom_styles_cannot_use_less_features')
+            ]);
+        }
+
         // We haven't saved the settings yet, but we want to trial a full
         // recompile of the CSS to see if this custom LESS will break
         // anything. In order to do that, we will temporarily override the

programming_language: PHP