GHSA-x5mr-p6v4-wp93 CVE-2023-38488
Field injection in the KirbyData text storage handler
- Severity
- 7.1 / 10
- High · CVSS 3.1
- Exploit chance (EPSS)
- 0.92%
- Chance of exploitation in the next 30 days. Higher than 60.44% of scored vulnerabilities.
- Known exploited
- No
- Not in CISA's catalog
- Fix
3.5.8.3- Upgrade getkirby/cms to this version or later
Description
TL;DR
This vulnerability 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).
Your Kirby sites are not affected if they don't allow write access for untrusted users or visitors.
Introduction
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.
Impact
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 during the read process the BOM was removed, turning the malicious line into a valid separator. This 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.
Patches
The problem has been patched in Kirby 3.5.8.3, Kirby 3.6.6.3, Kirby 3.7.5.2, Kirby 3.8.4.1 and Kirby 3.9.6. Please update to one of these or a later version to fix the vulnerability.
In all of the mentioned releases, we 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.
Credits
Thanks to Patrick Falb (@dapatrese) at FORMER 03 for responsibly reporting the identified issue.
Affected versions
Packagist
| Package | Vulnerable | Fixed in |
|---|---|---|
| getkirby/cms | < 3.5.8.3 |
3.5.8.3 |
| getkirby/cms | >= 3.6.0, < 3.6.6.3 |
3.6.6.3 |
| getkirby/cms | >= 3.7.0, < 3.7.5.2 |
3.7.5.2 |
| getkirby/cms | >= 3.8.0, < 3.8.4.1 |
3.8.4.1 |
| getkirby/cms | >= 3.9.0, < 3.9.6 |
3.9.6 |
How to fix
Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.
getkirby/cms Packagist → 3.5.8.3
- composer
composer require getkirby/cms:^3.5.8.3
Severity breakdown
CVSS 3.1 7.1
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:L
- Attack vector
- Network
- Attack complexity
- Low
- Privileges required
- Low
- User interaction
- None
- Scope
- Unchanged
- Confidentiality
- None
- Integrity
- High
- Availability
- Low
Weakness
CWE-140: Improper Neutralization of Delimiters
The product does not neutralize or incorrectly neutralizes delimiters.
How to prevent it
- Implementation: Developers should anticipate that delimiters will be injected/removed/manipulated in the input vectors of their product. Use an appropriate combination of denylists and allowlists to ensure only valid, expected and appropriate input is processed by the system.
- Implementation: Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue." Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright.
- Implementation: While it is risky to use dynamically-generated query strings, code, or commands that mix control and data together, sometimes it may be unavoidable. Properly quote arguments and escape any special characters within those arguments. The most conservative approach is to escape or filter all characters that do not pass an extremely strict allowlist (such as everything that is not alphanumeric or white space). If some special characters are still needed, such as white space, wrap each argument in quotes after the escaping/filtering step. Be careful of argument injection (CWE-88).
- Implementation: Inputs should be decoded and canonicalized to the application's current internal representation before being validated (CWE-180). Make sure that the application does not decode the same input twice (CWE-174). Such errors could be used to bypass allowlist validation schemes by introducing dangerous inputs after they have been checked.
CWE-863: Incorrect Authorization
The product performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check.
How to prevent it
- Architecture and Design: Divide the product into anonymous, normal, privileged, and administrative areas. Reduce the attack surface by carefully mapping roles with data and functionality. Use role-based access control (RBAC) [REF-229] to enforce the roles at the appropriate boundaries. Note that this approach may not protect against horizontal authorization, i.e., it will not protect a user from attacking others with the same role.
- Architecture and Design: Ensure that access control checks are performed related to the business logic. These checks may be different than the access control checks that are applied to more generic resources such as files, connections, processes, memory, and database records. For example, a database may restrict access for medical records to a specific database user, but each record might only be intended to be accessible to the patient and the patient's doctor [REF-7].
- Architecture and Design: Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid. For example, consider using authorization frameworks such as the JAAS Authorization Framework [REF-233] and the OWASP ESAPI Access Control feature [REF-45].
- Architecture and Design: For web applications, make sure that the access control mechanism is enforced correctly at the server side on every page. Users should not be able to access any unauthorized functionality or information by simply requesting direct access to that page. One way to do this is to ensure that all pages containing sensitive information are not cached, and that all such pages restrict access to requests that are accompanied by an active and authenticated session token associated with a user who has the required permissions to access that page.
- System Configuration, Installation: Use the access control capabilities of your operating system and server environment and define your access control lists accordingly. Use a "default deny" policy when defining these ACLs.
References
Advisories
Packages
Other links
- github.com/getkirby/kirby/security/advisories/GHSA-x5mr-p6v4-wp93
- github.com/getkirby/kirby/commit/a1e0f81c799ddae1af91cf37216f8ded9cb93540
- github.com/getkirby/kirby/releases/tag/3.5.8.3
- github.com/getkirby/kirby/releases/tag/3.6.6.3
- github.com/getkirby/kirby/releases/tag/3.7.5.2
- github.com/getkirby/kirby/releases/tag/3.8.4.1
- github.com/getkirby/kirby/releases/tag/3.9.6
Timeline
- Published
- Last updated by the source
- Latest EPSS score
Related advisories
| Advisory | Severity | Why it's related |
|---|---|---|
| GHSA-9vx2-j98c-p72w Kirby: Access to image files and limited access to JSON files outside of the site root via path traversal in the media handling | High | Also affects getkirby/cms |
| GHSA-6j4c-mgqr-qv76 Kirby: Access to image files outside of the site root via path traversal in the media handling | Medium | Also affects getkirby/cms |
| GHSA-67mx-6wf2-92xp Kirby: File upload permissions are not checked during processing of chunk data | High | Also affects getkirby/cms |
| GHSA-rf2p-vh74-7vvh Kirby: System path exposure from error messages in the REST API | Medium | Also affects getkirby/cms |
| GHSA-r3w8-2c5r-h9j9 Kirby: `pages.access` permission is not checked in the `site/find` REST API route | High | Also affects getkirby/cms |
| GHSA-89cp-7p28-jffg Kirby: Access to files of top-level drafts is not protected by permissions | Medium | Also affects getkirby/cms |
| GHSA-whxw-24jc-cwmv Kirby: External Initialization of the Panel on reverse proxy setups with the `Forwarded` header | Critical | Also affects getkirby/cms |
| GHSA-wr9h-4r83-f4v6 Kirby: Cross-site scripting (XSS) from incomplete HTML/XML sanitization in `Dom::sanitize()` | High | Also affects getkirby/cms |
MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.
Check your repos with MergeHarbor