/

CVE-2026-32870

Severity:

HIGH RISK

(7.5)

XML Injection in Kirby Xml::value() Utility Methods

CVE-2026-32870

Analyzed

Vulnerability type

Category:

XML Injection

CWE:

CWE-91

Impact:

XML Schema Manipulation / Data Injection into Downstream XML Consumers

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

An XML encoding issue in Kirby's Xml::value() method allows specially crafted input to bypass CDATA value protection and inject additional XML structured data alongside valid CDATA blocks.

When site or plugin code uses Kirby utilities to generate XML from user input and that XML is consumed by another system that interprets the XML schema, an attacker may be able to manipulate that downstream system's behavior.

Affected context

This vulnerability arises in Kirby-based projects that:

  • Use Xml::value(), Xml::tag(), Xml::create() or the Xml data handler (Data::encode($string, 'xml')) to build XML from untrusted or semi-trusted data, and
  • Forward the generated XML to other components or external systems that interpret the XML structure (e.g., APIs, configuration processors, or integration endpoints).

The Kirby core itself does not invoke these methods in a way that exposes the bug by default; the risk exists primarily in custom site templates, controllers, or plugins that perform XML generation.

Exploit preconditions

  • Attack surface: XML generation pathways using Xml::value(), Xml::tag(), Xml::create() or Data::encode(..., 'xml') with attacker-controlled or user-supplied input.
  • Required access: Ability to influence the data passed into these XML helper methods (e.g., form fields, query parameters, content fields stored in Kirby, or plugin configuration).
  • Trigger point: The crafted string is processed by Xml::value(), which incorrectly treats partially wrapped input as safe CDATA and outputs it without proper escaping.
  • Why exploitation is possible: The CDATA detection logic previously only checked for the presence of valid CDATA blocks and allowed passthrough when such a block existed, even if additional XML markup or structured data appeared outside those blocks. This breaks the intended trust boundary and allows XML injection.

Why this happens

The underlying issue is an improper sanitization and encoding of output values in XML context, aligning with CWE-91: XML Injection.

The Xml::value() method contains special logic to avoid double-escaping values that are already wrapped in <![CDATA[ ... ]]>. However, the implementation validated only that the input contained valid CDATA, not that the entire string was composed exclusively of one or more CDATA sections.

As a result, attackers could craft input that started or included a valid CDATA block while also appending or prepending additional XML markup or entities outside those blocks. Because the function treated such input as safe, the surrounding structured content was emitted verbatim into the XML output, bypassing the intended encoding layer.

Abstractly, this represents a flawed context-aware encoder: it conditionally skips escaping based on an incomplete structural check, allowing attacker-controlled content to cross the boundary from "data" into "XML structure."

Potential impact

  • Injection of additional XML elements, attributes, or entity references into generated XML documents.
  • Manipulation of downstream systems that interpret the XML schema, such as:
  • Altering configuration values or flags encoded in XML.
  • Influencing access control or routing decisions based on XML content.
  • Tampering with data feeds, API requests, or integration payloads that rely on XML.
  • Potential chaining with other XML-related weaknesses in downstream consumers (e.g., logic flaws, misrouting, or over-permissive XML mappers).
  • Integrity impact on systems that treat the XML as authoritative configuration or business data.

General mitigation guidance

Effective mitigation focuses on robust, context-aware XML encoding and tight control over when raw CDATA is trusted:

  • Ensure that XML helper methods only skip escaping when the entire value is verified as strictly composed of valid CDATA blocks, without any extra markup or text outside of them.
  • Favor safe-by-default encoders that always escape special XML characters (<, >, &, ", ') unless there is a compelling need to support raw CDATA, and that enforce strict structural checks whenever they detect CDATA wrappers.
  • Treat all user-supplied or external input as untrusted and encode it as pure data within XML elements or attributes, rather than allowing it to define or modify XML structure.
  • Apply a clear separation between data and schema: only static, vetted code should define element and attribute names, while dynamic values are always encoded as content.
  • Where possible, reduce the need for raw CDATA by normalizing or transforming inputs into safe representations (e.g., base64 or entity-escaped text) before embedding in XML.
  • Use least-privilege design for downstream components consuming the XML so that injected XML has limited authority to alter critical application behavior.

How teams detect issues like this

Identification of this class of issue typically involves both code-centric and behavior-centric approaches:

  • Static analysis and code review:
  • Search for usage of Xml::value(), Xml::tag(), Xml::create(), and Data::encode(..., 'xml') where parameters may derive from request data, editable content, or other untrusted sources.
  • Inspect custom logic that conditionally disables escaping based on CDATA detection or patterns like <![CDATA[ to ensure it validates the whole string, not just a substring.
  • Flag patterns where XML element or attribute boundaries can be influenced by user input (e.g., concatenating <tag> fragments around raw data).
  • Dynamic and integration testing:
  • Fuzz XML-producing endpoints or code paths with inputs containing mixed CDATA and XML markup to see if the output document structure changes in unexpected ways.
  • Monitor downstream systems that consume the XML for anomalous configuration changes or behavior shifts when varied input is supplied.
  • Policy and tooling:
  • Enforce secure encoding policies in CI pipelines, such as lint rules that prohibit custom CDATA "passthrough" handling without full-structure validation.
  • Use automated security review tools or linters capable of recognizing XML construction APIs and checking that they are used with proper escaping.

Sources

SourceLink
github.comgithub.com/getkirby/kirby/releases/tag/4.9.0
github.comgithub.com/getkirby/kirby/releases/tag/5.4.0
github.comgithub.com/getkirby/kirby/security/advisories/GHSA-9wfj-c55w-j9qr

Frequently asked

questions

Exploitability depends heavily on how a Kirby site or plugin uses the XML utilities. Sites that never generate XML from user-controlled data, or that do not pass generated XML into schema-aware consumers, are effectively not exposed. The risk is highest where untrusted input is transformed into XML and then used by another system to drive logic or configuration.

An attacker needs the ability to influence or control the data that is fed into Xml::value(), Xml::tag(), Xml::create() or Data::encode(..., 'xml'). This can occur through typical application inputs, such as form submissions, editable content fields in the CMS, API parameters, or plugin settings, depending on how the site is implemented.

The safest pattern is to enforce strict, unconditional XML escaping for all untrusted values and to only treat content as CDATA after verifying that the entire value is composed of one or more valid CDATA sections with no extra markup. In many cases, removing special CDATA passthrough logic and relying solely on a robust standard encoder simplifies the model and prevents similar bugs.

Use high-level XML APIs that handle escaping automatically, keep XML structure definitions in static code, and always treat external data as opaque content to be encoded. Avoid custom parsing or conditional escaping based on partial string checks, and incorporate security review or static analysis rules that flag concatenation-based XML construction and raw CDATA handling in pull requests.

Find out what's already
exploitable in your codebase.