CVE-2024-31996: Xwiki commons velocity Remote Code Execution Vulnerability

CRITICAL
Advisory Identifier: GHSA-hf43-47q4-fhq5
CVSS 10.0
CWE-94 CWE-95
Published
Advisory Summary

CVE-2024-31996 is a CRITICAL (CVSS 10.0) remote code execution vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Xwiki commons velocity libraries in the Maven ecosystem. The issue involves xwiki commons missing escaping of `{` in velocity escapetool allows remote code execution. Remediation is available by upgrading affected packages to version 14.10.19, 15.5.4, 15.9-rc-1.

CVE-2024-31996 at a Glance

CVE Identifier CVE-2024-31996
GHSA Identifier GHSA-hf43-47q4-fhq5
Severity CRITICAL
CVSS v3.1 Base Score 10.0
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product Xwiki commons velocity
Package Ecosystem Maven
Published Date
Last Updated

Security Impact

CVSS: 10.0

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

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

How to Fix CVE-2024-31996

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

org.xwiki.commons:xwiki-commons-velocity fixed: 14.10.19
<dependency>
    <groupId>org.xwiki.commons</groupId>
    <artifactId>xwiki-commons-velocity</artifactId>
    <version>14.10.19</version>
</dependency>
org.xwiki.commons:xwiki-commons-velocity fixed: 15.5.4
<dependency>
    <groupId>org.xwiki.commons</groupId>
    <artifactId>xwiki-commons-velocity</artifactId>
    <version>15.5.4</version>
</dependency>
org.xwiki.commons:xwiki-commons-velocity fixed: 15.9-rc-1
<dependency>
    <groupId>org.xwiki.commons</groupId>
    <artifactId>xwiki-commons-velocity</artifactId>
    <version>15.9-rc-1</version>
</dependency>
Verify Direct and Transitive Dependencies

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

mvn dependency:tree -Dincludes=org.xwiki.commons

How to Check if You Are Affected

To determine whether your Java application is affected by CVE-2024-31996, inspect your build dependencies using the Maven Dependency Plugin:

mvn dependency:tree -Dincludes=org.xwiki.commons

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

Note: The mvn dependency:tree -Dincludes=org.xwiki.commons command inspects the resolved dependency graph declared in your project's POM files; it does not perform automated security scanning or inspect runtime dynamic classpaths. Always verify runtime container classpaths and shaded JARs.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. In Xwiki commons velocity, 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 The HTML escaping of escaping tool that is used in XWiki doesn't escape `{`, which, when used in certain places, allows XWiki syntax injection and thereby remote code execution. To reproduce in an XWiki installation, open `<xwiki-host>/xwiki/bin/view/Panels/PanelLayoutUpdate?place=%7B%7B%2Fhtml%7D%7D%7B%7Basync%20async%3Dfalse%7D%7D%7B%7Bvelocity%7D%7D%23evaluate(%24request.eval)%7B%7B%2Fvelocity%7D%7D%7B%7B%2Fasync%7D%7D&eval=Hello%20from%20URL%20Parameter!%20I%20got%20programming%3A%20%24services.security.authorization.hasAccess(%27programming%27)` where `<xwiki-host>` is the URL of your XWiki installation. If this displays `You are not admin on this place Hello from URL Parameter! I got programming: true`, the installation is vulnerable. ### Patches The vulnerability has been fixed on XWiki 14.10.19, 15.5.5, and 15.9 RC1. ### Workarounds Apart from upgrading, there is no generic workaround. However, replacing `$escapetool.html` by `$escapetool.xml` in XWiki documents fixes the vulnerability. In a standard XWiki installation, we're only aware of the document `Panels.PanelLayoutUpdate` that exposes this vulnerability, patching this document is thus a workaround. Any extension could expose this vulnerability and might thus require patching, too. ### References - https://github.com/xwiki/xwiki-commons/commit/b94142e2a66ec32e89eacab67c3da8d91f5ef93a - https://jira.xwiki.org/browse/XCOMMONS-2828 - https://jira.xwiki.org/browse/XWIKI-21438

CVE-2024-31996 Affected Xwiki commons velocity Versions

3 component(s)
Fixed Versions:
14.10.1915.5.415.9-rc-1
Product / Package Ecosystem Affected Versions Fixed Version
org.xwiki.commons:xwiki-commons-velocity
Maven
≥ 3.0.1
< 14.10.19
14.10.19
org.xwiki.commons:xwiki-commons-velocity
Maven
≥ 15.0-rc-1
< 15.5.4
15.5.4
org.xwiki.commons:xwiki-commons-velocity
Maven
≥ 15.6-rc-1
< 15.9-rc-1
15.9-rc-1

References

Frequently Asked Questions

What is CVE-2024-31996?
CVE-2024-31996 is a security vulnerability in Xwiki commons velocity involving XWiki Commons missing escaping of `{` in Velocity escapetool allows remote code execution under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which Xwiki commons velocity versions are affected?
Affected versions include releases prior to 14.10.19, 15.5.4, 15.9-rc-1 across affected packages: org.xwiki.commons:xwiki-commons-velocity.
What version fixes CVE-2024-31996?
Upgrading to 14.10.19, 15.5.4, 15.9-rc-1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is xwiki-commons-velocity affected?
Yes, org.xwiki.commons:xwiki-commons-velocity is affected in releases prior to 14.10.19, 15.5.4, 15.9-rc-1. Upgrade your dependency to 14.10.19, 15.5.4, 15.9-rc-1 or later.
What is the CVSS score of CVE-2024-31996?
CVE-2024-31996 has a CVSS v3.1 base score of 10.0 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H.
What CWE is associated with CVE-2024-31996?
CVE-2024-31996 is classified under CWE-94: Improper Control of Generation of Code ('Code Injection') (The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.).
How can I check Maven dependencies for CVE-2024-31996?
Run the dependency tree command: 'mvn dependency:tree -Dincludes=org.xwiki.commons'. 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-hf43-47q4-fhq5",
  "modified" : "2024-04-10T22:01:56Z",
  "published" : "2024-04-10T17:16:37Z",
  "aliases" : [ "CVE-2024-31996" ],
  "summary" : "XWiki Commons missing escaping of `{` in Velocity escapetool allows remote code execution",
  "details" : "### Impact\nThe HTML escaping of escaping tool that is used in XWiki doesn't escape `{`, which, when used in certain places, allows XWiki syntax injection and thereby remote code execution.\n\nTo reproduce in an XWiki installation, open `<xwiki-host>/xwiki/bin/view/Panels/PanelLayoutUpdate?place=%7B%7B%2Fhtml%7D%7D%7B%7Basync%20async%3Dfalse%7D%7D%7B%7Bvelocity%7D%7D%23evaluate(%24request.eval)%7B%7B%2Fvelocity%7D%7D%7B%7B%2Fasync%7D%7D&eval=Hello%20from%20URL%20Parameter!%20I%20got%20programming%3A%20%24services.security.authorization.hasAccess(%27programming%27)` where `<xwiki-host>` is the URL of your XWiki installation. If this displays `You are not admin on this place Hello from URL Parameter! I got programming: true`, the installation is vulnerable.\n\n### Patches\nThe vulnerability has been fixed on XWiki 14.10.19, 15.5.5, and 15.9 RC1.\n\n### Workarounds\nApart from upgrading, there is no generic workaround. However, replacing `$escapetool.html` by `$escapetool.xml` in XWiki documents fixes the vulnerability. In a standard XWiki installation, we're only aware of the document `Panels.PanelLayoutUpdate` that exposes this vulnerability, patching this document is thus a workaround. Any extension could expose this vulnerability and might thus require patching, too.\n\n### References\n- https://github.com/xwiki/xwiki-commons/commit/b94142e2a66ec32e89eacab67c3da8d91f5ef93a\n- https://jira.xwiki.org/browse/XCOMMONS-2828\n- https://jira.xwiki.org/browse/XWIKI-21438",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.xwiki.commons:xwiki-commons-velocity"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.0.1"
      }, {
        "fixed" : "14.10.19"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.xwiki.commons:xwiki-commons-velocity"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "15.0-rc-1"
      }, {
        "fixed" : "15.5.4"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.xwiki.commons:xwiki-commons-velocity"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "15.6-rc-1"
      }, {
        "fixed" : "15.9-rc-1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/xwiki/xwiki-commons/security/advisories/GHSA-hf43-47q4-fhq5"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-31996"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/xwiki/xwiki-commons/commit/b0805160ec7b01ee12417e79cb384e60ae4817aa"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/xwiki/xwiki-commons/commit/b94142e2a66ec32e89eacab67c3da8d91f5ef93a"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/xwiki/xwiki-commons/commit/ed7ff515a2436a1c6dcbd0c6ca0c41e434d58915"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/xwiki/xwiki-commons"
  }, {
    "type" : "WEB",
    "url" : "https://jira.xwiki.org/browse/XCOMMONS-2828"
  }, {
    "type" : "WEB",
    "url" : "https://jira.xwiki.org/browse/XWIKI-21438"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-94", "CWE-95" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-04-10T17:16:37Z",
    "nvd_published_at" : "2024-04-10T21:15:07Z"
  }
}