Kirby CMS vulnerable to cross-site scripting (XSS) from list field content in the site frontend
Description
TL;DR
This vulnerability affects all Kirby sites that use the list field or list block, when content is authored by users who may not be fully trusted. The attack requires an authenticated Panel user with update permission to any list field or list block.
This vulnerability is of high severity for affected sites.
Kirby sites are *not* affected if they don't use the list field (or blocks field with the list block) in any of their blueprints, or if every user who can edit content is fully trusted. The attack only surfaces in the site frontend (i.e. in the consuming project's templates). The Panel itself is unaffected and will not execute JavaScript that was injected into list field content.
----
Introduction
Cross-site scripting (XSS) is a type of vulnerability that allows to execute any kind of JavaScript code inside the site frontend or Panel session of the same or other users. In the Panel, a harmful script can for example trigger requests to Kirby's API with the permissions of the victim.
In a *stored* XSS attack, the malicious payload is saved into the content data and has the potential to affect other users or site visitors.
Such vulnerabilities are critical if applications might have potential attackers in their group of authenticated Panel users. They can escalate their privileges if they get access to the Panel session of an admin user. Depending on the site, other JavaScript-powered attacks are possible.
A specific class of stored XSS is auto-firing, meaning the malicious injected JavaScript code is executed by the browser when the page loads without the victim having to perform a specific action.
Affected components
Kirby's list field stores its formatted content as HTML code. Unlike with other field types, it is not possible to escape HTML special characters against cross-site scripting (XSS) attacks, otherwise the formatting would be lost.
Impact
In affected releases, Kirby did not securely sanitize the contents of list fields on save. This allowed attackers to inject malicious HTML code into the content file by sending it to Kirby's API directly without using the Panel. This malicious HTML code would then be displayed on the site frontend and executed in the browsers of site visitors and logged in users who are browsing the site.
Patches
The problem has been patched in Kirby 4.9.1 and Kirby 5.4.1. Please update to one of these or a later version to fix the vulnerability.
In all of the mentioned releases, Kirby has added HTML sanitization (like in the writer field) to the backend code that handles updates to the contents of list fields.
Credits
Kirby thanks @offset for responsibly reporting the identified issue.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
Stored XSS in Kirby's list field/list block allows authenticated Panel users to inject malicious HTML/JavaScript executed in the site frontend.
Vulnerability
Kirby's list field and list block store formatted content as HTML. Unlike other field types, escaping HTML special characters would break formatting. In affected versions (prior to 5.4.1 and 4.9.1), Kirby did not sanitize list field contents on save, allowing injection of malicious HTML and JavaScript [1][2][3]. This affects all Kirby sites that use the list field or list block in their blueprints, when content is authored by users who may not be fully trusted [2].
Exploitation
An attacker must be an authenticated Panel user with update permission to any list field or list block [2]. They can craft a payload containing malicious HTML/JavaScript and save it as list field content. The payload is stored in the content file and, when the page is rendered in the site frontend, the injected script executes automatically without user interaction (auto-firing XSS) [3]. The Panel itself does not execute the injected JavaScript [2].
Impact
Successful exploitation results in stored cross-site scripting (XSS) in the site frontend. The attacker can execute arbitrary JavaScript in the context of any visitor's browser, including other authenticated Panel users. This can lead to privilege escalation if an admin user views the affected page, as the script can trigger requests to Kirby's API with the victim's permissions [2][3]. Depending on the site, further JavaScript-powered attacks are possible.
Mitigation
The vulnerability is fixed in Kirby versions 5.4.1 [1] and 4.9.1 (backport for Kirby 4.x) [4]. Users should upgrade immediately. If upgrading is not possible, ensure that every user with edit permissions is fully trusted, or remove the list field and list block from all blueprints [2]. No other workarounds are available.
AI Insight generated on May 27, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
getkirby/cmsPackagist | < 4.9.1 | 4.9.1 |
getkirby/cmsPackagist | >= 5.0.0, < 5.4.1 | 5.4.1 |
Affected products
2- Range: <4.9.1, >=5.0.0 <5.4.1
Patches
12f3243cc153dfix: Sanitize list field values
5 files changed · +44 −8
config/fields/list.php+5 −1 modified@@ -1,5 +1,7 @@ <?php +use Kirby\Sane\Sane; + return [ 'props' => [ /** @@ -17,7 +19,9 @@ ], 'computed' => [ 'value' => function () { - return trim($this->value ?? ''); + $value = trim($this->value ?? ''); + $value = Sane::sanitizeProseMirrorFields($value); + return $value; } ] ];
config/fields/writer.php+1 −7 modified@@ -63,13 +63,7 @@ 'computed' => [ 'value' => function () { $value = trim($this->value ?? ''); - $value = Sane::sanitize($value, 'html'); - - // convert non-breaking spaces to HTML entity - // as that's how ProseMirror handles it internally; - // will allow comparing saved and current content - $value = str_replace(' ', ' ', $value); - + $value = Sane::sanitizeProseMirrorFields($value); return $value; } ],
src/Sane/Sane.php+18 −0 modified@@ -136,6 +136,24 @@ public static function sanitizeFile( } } + /** + * Sanitizes the given string from ProseMirror-backed fields + * @since 5.4.1 + */ + public static function sanitizeProseMirrorFields( + string $string, + bool $isExternal = false + ): string { + $string = static::sanitize($string, 'html', $isExternal); + + // convert non-breaking spaces to HTML entity + // as that's how ProseMirror handles it internally; + // will allow comparing saved and current content + $string = str_replace(' ', ' ', $string); + + return $string; + } + /** * Validates file contents with the specified handler *
tests/Form/Field/ListFieldTest.php+9 −0 modified@@ -15,4 +15,13 @@ public function testDefaultProps(): void $this->assertNull($field->text()); $this->assertTrue($field->save()); } + + public function testValueSanitized(): void + { + $field = $this->field('list', [ + 'value' => '<ul><li>Item <strong>one</strong></li></ul><script>alert("Hacked")</script>' + ]); + + $this->assertSame('<ul><li>Item <strong>one</strong></li></ul>', $field->value()); + } }
tests/Sane/SaneTest.php+11 −0 modified@@ -141,6 +141,17 @@ public function testSanitizeFileMultipleHandlersExplicit(): void $this->assertFileEquals($expected, $tmp); } + public function testSanitizeProseMirrorFields(): void + { + $this->assertSame( + 'This is a <strong>test</strong> with <em>formatting</em>', + Sane::sanitizeProseMirrorFields('This is a <strong>test</strong><script>alert("Hacked")</script> with <em>formatting</em>') + ); + + // non-breaking spaces are converted to HTML entities + $this->assertSame('foo bar', Sane::sanitizeProseMirrorFields("foo\u{00A0}bar")); + } + public function testValidate(): void { $this->assertNull(Sane::validate('<svg></svg>', 'svg'));
Vulnerability mechanics
Synthesis attempt was rejected by the grounding validator. Re-run pending.
References
4News mentions
0No linked articles in our index yet.