Advisory Database
  • Advisories
  • Dependency Scanning
  1. composer
  2. ›
  3. getgrav/grav
  4. ›
  5. CVE-2024-27923

CVE-2024-27923: Remote Code Execution by uploading a phar file using frontmatter

March 6, 2024

Summary

  • Due to insufficient permission verification, user who can write a page use frontmatter feature.
  • Inadequate File Name Validation

Details

  1. Insufficient Permission Verification

In Grav CMS, “Frontmatter” refers to the metadata block located at the top of a Markdown file. Frontmatter serves the purpose of providing additional information about a specific page or post. In this feature, only administrators are granted access, while regular users who can create pages are not. However, if a regular user adds the data[_json][header][form] parameter to the POST Body while creating a page, they can use Frontmatter. The demonstration of this vulnerability is provided in video format. Video Link

  1. Inadequate File Name Validation

To create a Contact Form, Frontmatter and markdown can be written as follows: Contact Form Example Form Action Save Option When an external user submits the Contact Form after filling it out, the data is stored in the user/data folder. The filename under which the data is stored corresponds to the value specified in the filename attribute of the process property. For instance, if the filename attribute has a value of “feedback.txt,” a feedback.txt file is created in the user/data/contact folder. This file contains the value entered by the user in the “name” field. The problem with this functionality is the lack of validation for the filename attribute, potentially allowing the creation of files such as phar files on the server. An attacker could input arbitrary PHP code into the “name” field to be saved on the server. However, Grav filter the < and > characters, so to disable these options, an xss_check: false attribute should be added. Disable XSS

---
title: Contact Form

form:
    name: contact
    xss_check: false

    fields:
        name:
          label: Name
          placeholder: Enter your name
          autocomplete: on
          type: text
          validate:
            required: true

    buttons:
        submit:
          type: submit
          value: Submit

    process:
        save:
            filename: this_is_file_name.phar
            operation: add

---

# Contact form

Some sample page content

Exploiting these two vulnerabilities allows the following scenario:

  • A regular user account capable of creating pages is required.
  • An attacker creates a Contact Form page containing malicious Frontmatter using the regular user’s account.
  • Accessing the Contact Form page, the attacker submits PHP code.
  • The attacker attempts Remote Code Execution by accessing HOST/user/data/[form-name]/[filename].

References

  • github.com/advisories/GHSA-f6g2-h7qv-3m5v
  • github.com/getgrav/grav
  • github.com/getgrav/grav/commit/e3b0aa0c502aad251c1b79d1ee973dcd93711f07
  • github.com/getgrav/grav/security/advisories/GHSA-f6g2-h7qv-3m5v
  • nvd.nist.gov/vuln/detail/CVE-2024-27923

Code Behaviors & Features

Detect and mitigate CVE-2024-27923 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →

Affected versions

All versions before 1.7.43

Fixed versions

  • 1.7.43

Solution

Upgrade to version 1.7.43 or above.

Impact 8.8 HIGH

CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

Learn more about CVSS

Weakness

  • CWE-287: Improper Authentication
  • CWE-434: Unrestricted Upload of File with Dangerous Type

Source file

packagist/getgrav/grav/CVE-2024-27923.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Wed, 14 May 2025 12:15:11 +0000.