CVE-2023-38488 in Kirbyinfo

Summary

by MITRE • 07/27/2023

Kirby is a content management system. A vulnerability in versions prior to 3.5.8.3, 3.6.6.3, 3.7.5.2, 3.8.4.1, and 3.9.6 affects all Kirby sites that might have potential attackers in the group of authenticated Panel users or that allow external visitors to update a Kirby content file (e.g. via a contact or comment form). Kirby sites are *not* affected if they don't allow write access for untrusted users or visitors.

A field injection in a content storage implementation is a type of vulnerability that allows attackers with content write access to overwrite content fields that the site developer didn't intend to be modified. In a Kirby site this can be used to alter site content, break site behavior or inject malicious data or code. The exact security risk depends on the field type and usage.

Kirby stores content of the site, of pages, files and users in text files by default. The text files use Kirby's KirbyData format where each field is separated by newlines and a line with four dashes (`----`). When reading a KirbyData file, the affected code first removed the Unicode BOM sequence from the file contents and afterwards split the content into fields by the field separator.

When writing to a KirbyData file, field separators in field data are escaped to prevent user input from interfering with the field structure. However this escaping could be tricked by including a Unicode BOM sequence in a field separator (e.g. `--\xEF\xBB\xBF--`). When writing, this was not detected as a separator, but because the BOM was removed during reading, it could be abused by attackers to inject other field data into content files.

Because each field can only be defined once per content file, this vulnerability only affects fields in the content file that were defined above the vulnerable user-writable field or not at all. Fields that are defined below the vulnerable field override the injected field content and were therefore already protected.

The problem has been patched in Kirby 3.5.8.3, 3.6.6.3, 3.7.5.2, 3.8.4.1, and Kirby 3.9.6. In all of the mentioned releases, the maintainers have fixed the affected code to only remove the Unicode BOM sequence at the beginning of the file. This fixes this vulnerability both for newly written as well as for existing content files.

If you want to get the best quality for vulnerability data then you always have to consider VulDB.

Analysis

by VulDB Data Team • 08/20/2023

The vulnerability identified as CVE-2023-38488 represents a critical field injection flaw in the Kirby content management system that affects multiple versions prior to specific patches. This vulnerability operates within the core content storage mechanism of Kirby, which utilizes a proprietary KirbyData format for persisting site content, pages, files, and user information in text files. The flaw emerges from the interaction between how Kirby handles Unicode Byte Order Mark (BOM) sequences during file reading and writing operations, creating an exploitable condition that allows authenticated Panel users or external visitors with write access to manipulate content fields in unintended ways. The vulnerability specifically targets the field separation mechanism where content is structured using newline delimiters and four-dash separators, making it particularly dangerous for sites that permit untrusted user input to modify content through contact forms or comment systems. This issue falls under the CWE-1236 category for improper neutralization of special elements used in data queries, and aligns with ATT&CK technique T1059.001 for command and scripting interpreter, as it enables arbitrary code injection through content manipulation.

The technical implementation of this vulnerability exploits the inconsistent handling of Unicode BOM sequences during the content parsing process. During file reading operations, Kirby correctly removes the Unicode BOM sequence from the beginning of files to prevent interference with field parsing, but this protection mechanism fails during the writing process. When attackers insert a Unicode BOM sequence into field separators within user-modifiable content fields, they can manipulate the field structure during subsequent reading operations. The system processes the BOM as part of the field separator, allowing malicious data to be injected into content files. This occurs because the writing process doesn't detect or prevent BOM sequences from being embedded within field data, while the reading process removes BOM sequences from the entire file content. The vulnerability specifically affects content files where fields defined above the vulnerable user-writable field can be overwritten, creating a cascading effect that can modify critical site behavior or inject malicious payloads. The exploitation requires attackers to have either authenticated Panel user access or write permissions for untrusted visitors, making it particularly dangerous for sites that accept external content submissions.

The operational impact of CVE-2023-38488 extends beyond simple content modification to potentially compromise entire site functionalities and security postures. Attackers can leverage this vulnerability to alter site content, break site behavior, inject malicious code, or manipulate user data in ways that could lead to more severe consequences including credential theft, data exfiltration, or server compromise. The vulnerability's scope is particularly concerning because it affects sites that allow external visitors to update content, creating a broad attack surface that could be exploited by threat actors without requiring advanced privileges. The fact that this vulnerability only affects fields defined above the vulnerable user-writable field or not at all provides partial protection but doesn't eliminate the risk entirely, as multiple content fields could still be compromised depending on the site structure and content organization. This makes the vulnerability particularly dangerous for sites with complex content structures where attackers could strategically target critical fields to maximize impact. Organizations running affected versions of Kirby face significant risks including potential service disruption, data integrity compromise, and reputational damage from content tampering.

The remediation implemented by the Kirby development team addresses the root cause through a targeted fix that modifies the BOM handling mechanism to only remove Unicode BOM sequences from the beginning of content files. This patch ensures that field separators within content data cannot be manipulated to inject additional fields during the parsing process, effectively closing the exploitation vector. The fix applies to all affected versions including 3.5.8.3, 3.6.6.3, 3.7.5.2, 3.8.4.1, and 3.9.6, providing comprehensive protection for both newly created and existing content files. Organizations should prioritize immediate patching of all affected Kirby installations, particularly those that allow untrusted user input to modify content. Additionally, security teams should conduct thorough audits of their Kirby installations to identify any potential exploitation attempts, review content access controls, and implement additional monitoring for unauthorized content modifications. The fix demonstrates proper input validation and sanitization practices that align with security best practices, ensuring that Unicode BOM sequences are handled consistently during both read and write operations. This vulnerability highlights the importance of consistent security controls across all data handling operations and serves as a reminder of the critical nature of proper input sanitization in content management systems.

Responsible

GitHub, Inc.

Reservation

07/18/2023

Disclosure

07/27/2023

Moderation

accepted

CPE

ready

EPSS

0.00799

KEV

no

Activities

very low

Sources

Want to know what is going to be exploited?

We predict KEV entries!