CVE-2021-29460: Getkirby/cms Cross-Site Scripting Vulnerability

HIGH
Advisory Identifier: GHSA-qgp4-5qx6-548g
CVSS 7.6
CWE-79
Published
Advisory Summary

CVE-2021-29460 is a HIGH (CVSS 7.6) cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Getkirby/cms libraries in the Packagist ecosystem. The issue involves cross-site scripting (xss) from unsanitized uploaded svg files in kirby. Remediation is available by upgrading affected packages to version 3.5.4.

CVE-2021-29460 at a Glance

CVE Identifier CVE-2021-29460
GHSA Identifier GHSA-qgp4-5qx6-548g
Severity HIGH
CVSS v3.1 Base Score 7.6
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product Getkirby/cms
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 7.6

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:L/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2021-29460

To remediate this vulnerability, upgrade all affected Getkirby/cms dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

getkirby/cms fixed: 3.5.4
Upgrade getkirby/cms to 3.5.4
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for getkirby/cms

How to Check if You Are Affected

To determine whether your application is affected by CVE-2021-29460, inspect your project dependencies for Getkirby/cms:

inspect dependencies for getkirby/cms

Analyze the terminal output to locate any version of Getkirby/cms in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.5.4), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In Getkirby/cms, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact An editor with write access to the Kirby Panel can upload an SVG or XML file that contains harmful content like `<script>` tags. The direct link to that file can be sent to other users or visitors of the site. If the victim opens that link in a browser where they are logged in to Kirby, the script will run and can for example trigger requests to Kirby's API with the permissions of the victim. This vulnerability is critical if you might have potential attackers in your group of authenticated Panel users. They can escalate their privileges if they get access to the Panel session of an admin user. Depending on your site, other JavaScript-powered attacks are possible. Visitors without Panel access can only use this attack vector if your site allows SVG or XML file uploads in frontend forms and you don't already validate or sanitize uploaded SVG or XML files. The attack requires user interaction by another user or visitor and *cannot* be automated. ### Patches #### Uploads in the Panel The problem has been patched in [Kirby 3.5.4](https://github.com/getkirby/kirby/releases/tag/3.5.4) by validating uploaded SVG and XML files and rejecting potentially harmful files. Please update to this or a [later version](https://github.com/getkirby/kirby/releases/) to fix the vulnerability. #### Frontend upload forms Frontend upload forms need to be patched separately depending on how they store the uploaded file(s). If you use `File::create()`, you are protected by updating to Kirby 3.5.4+. #### Validate existing files Already uploaded files are *not* automatically validated again. If you are not sure if you have been impacted by this vulnerability in the past, we recommend to run all site files through the validator classes after updating to Kirby 3.5.4. You can use the following test script by pasting it into a template or uploading it to your web root: ```php <?php @include_once __DIR__ . '/kirby/bootstrap.php'; if (version_compare(kirby()->version(), '3.5.4', '<') === true) { die('This script requires Kirby 3.5.4+.'); } $objects = [ // the site itself site(), // all pages and drafts ...site()->index(true)->values(), // all users ...kirby()->users()->values() ]; $errors = false; foreach ($objects as $object) { foreach ($object->files() as $file) { try { // validate the contents lazily // (if a validator exists) $file->validateContents(true); } catch (\Kirby\Exception\InvalidArgumentException $e) { echo $file->id() . ': ' . $e->getMessage() . "<br>\n"; $errors = true; } } } if ($errors === false) { echo 'No validation errors found.'; } ``` You only need to run this validator script once as future uploads will automatically be validated. If the script prints "No validation errors found", you have not been impacted by the vulnerability so far. Errors that it lists may or may not be critical as our validator classes also catch files with an invalid data structure or less harmful attacks like the ["billion laughs" denial-of-service attack](https://en.wikipedia.org/wiki/Billion_laughs_attack) or the usage of external sources. We recommend to review and fix each listed error manually until the script no longer finds any validation errors. **Please delete the script again after you have used it.** ### Workarounds If you cannot update to Kirby 3.5.4, you can disable the upload of SVG and XML files in your [file blueprints](https://getkirby.com/docs/reference/panel/blueprints/file#accept) and validate or replace your already uploaded files once. ### Credits Thanks to @sreenathr10 for reporting the problem.

CVE-2021-29460 Affected Getkirby/cms Versions

1 component(s)
Fixed Versions:
3.5.4
Product / Package Ecosystem Affected Versions Fixed Version
getkirby/cms
Packagist
< 3.5.4
3.5.4

References

Frequently Asked Questions

What is CVE-2021-29460?
CVE-2021-29460 is a security vulnerability in Getkirby/cms involving Cross-site scripting (XSS) from unsanitized uploaded SVG files in Kirby under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which Getkirby/cms versions are affected?
Affected versions include releases prior to 3.5.4 across affected packages: getkirby/cms.
What version fixes CVE-2021-29460?
Upgrading to 3.5.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is getkirby/cms affected?
Yes, getkirby/cms is affected in releases prior to 3.5.4. Upgrade your dependency to 3.5.4 or later.
What is the CVSS score of CVE-2021-29460?
CVE-2021-29460 has a CVSS v3.1 base score of 7.6 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:L/A:N.
What CWE is associated with CVE-2021-29460?
CVE-2021-29460 is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.).
How can I check Packagist dependencies for CVE-2021-29460?
Run the dependency tree command: 'inspect dependencies for getkirby/cms'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-qgp4-5qx6-548g",
  "modified" : "2021-04-27T20:11:58Z",
  "published" : "2021-04-30T17:30:06Z",
  "aliases" : [ "CVE-2021-29460" ],
  "summary" : "Cross-site scripting (XSS) from unsanitized uploaded SVG files in Kirby",
  "details" : "### Impact\n\nAn editor with write access to the Kirby Panel can upload an SVG or XML file that contains harmful content like `<script>` tags. The direct link to that file can be sent to other users or visitors of the site. If the victim opens that link in a browser where they are logged in to Kirby, the script will run and can for example trigger requests to Kirby's API with the permissions of the victim.\n\nThis vulnerability is critical if you might have potential attackers in your group of authenticated Panel users. They can escalate their privileges if they get access to the Panel session of an admin user. Depending on your site, other JavaScript-powered attacks are possible.\n\nVisitors without Panel access can only use this attack vector if your site allows SVG or XML file uploads in frontend forms and you don't already validate or sanitize uploaded SVG or XML files.\n\nThe attack requires user interaction by another user or visitor and *cannot* be automated.\n\n### Patches\n\n#### Uploads in the Panel\n\nThe problem has been patched in [Kirby 3.5.4](https://github.com/getkirby/kirby/releases/tag/3.5.4) by validating uploaded SVG and XML files and rejecting potentially harmful files. Please update to this or a [later version](https://github.com/getkirby/kirby/releases/) to fix the vulnerability.\n\n#### Frontend upload forms\n\nFrontend upload forms need to be patched separately depending on how they store the uploaded file(s). If you use `File::create()`, you are protected by updating to Kirby 3.5.4+.\n\n#### Validate existing files\n\nAlready uploaded files are *not* automatically validated again. If you are not sure if you have been impacted by this vulnerability in the past, we recommend to run all site files through the validator classes after updating to Kirby 3.5.4. You can use the following test script by pasting it into a template or uploading it to your web root:\n\n```php\n<?php\n\n@include_once __DIR__ . '/kirby/bootstrap.php';\n\nif (version_compare(kirby()->version(), '3.5.4', '<') === true) {\n  die('This script requires Kirby 3.5.4+.');\n}\n\n$objects = [\n  // the site itself\n  site(),\n\n  // all pages and drafts\n  ...site()->index(true)->values(),\n\n  // all users\n  ...kirby()->users()->values()\n];\n\n$errors = false;\nforeach ($objects as $object) {\n  foreach ($object->files() as $file) {\n    try {\n      // validate the contents lazily\n      // (if a validator exists)\n      $file->validateContents(true);\n    } catch (\\Kirby\\Exception\\InvalidArgumentException $e) {\n      echo $file->id() . ': ' . $e->getMessage() . \"<br>\\n\";\n      $errors = true;\n    }\n  }\n}\n\nif ($errors === false) {\n  echo 'No validation errors found.';\n}\n```\n\nYou only need to run this validator script once as future uploads will automatically be validated. If the script prints \"No validation errors found\", you have not been impacted by the vulnerability so far.\n\nErrors that it lists may or may not be critical as our validator classes also catch files with an invalid data structure or less harmful attacks like the [\"billion laughs\" denial-of-service attack](https://en.wikipedia.org/wiki/Billion_laughs_attack) or the usage of external sources. We recommend to review and fix each listed error manually until the script no longer finds any validation errors.\n\n**Please delete the script again after you have used it.**\n\n### Workarounds\n\nIf you cannot update to Kirby 3.5.4, you can disable the upload of SVG and XML files in your [file blueprints](https://getkirby.com/docs/reference/panel/blueprints/file#accept) and validate or replace your already uploaded files once.\n\n### Credits\n\nThanks to @sreenathr10 for reporting the problem.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "getkirby/cms"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.5.4"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/getkirby/kirby/security/advisories/GHSA-qgp4-5qx6-548g"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-29460"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/getkirby/kirby/releases/tag/3.5.4"
  }, {
    "type" : "WEB",
    "url" : "http://packetstormsecurity.com/files/162359/Kirby-CMS-3.5.3.1-Cross-Site-Scripting.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-04-27T20:11:58Z",
    "nvd_published_at" : "2021-04-27T20:15:00Z"
  }
}