CVE-2024-47879: Main OpenRefine's PreviewExpressionCommand, Which Is Eval, Vulnerability

HIGH
Advisory Identifier: GHSA-3jm4-c6qf-jrh3
CVSS 7.6
CWE-94 CWE-352
Published
Advisory Summary

CVE-2024-47879 is a HIGH (CVSS 7.6) openrefine's previewexpressioncommand, which is eval, vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Main libraries in the Maven ecosystem. The issue involves openrefine's previewexpressioncommand, which is eval, lacks protection against cross-site request forgery (csrf). Remediation is available by upgrading affected packages to version 3.8.3.

CVE-2024-47879 at a Glance

CVE Identifier CVE-2024-47879
GHSA Identifier GHSA-3jm4-c6qf-jrh3
Severity HIGH
CVSS v3.1 Base Score 7.6
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product Main
Package Ecosystem Maven
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:U/C:H/I:H/A:L).

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

How to Fix CVE-2024-47879

To remediate this vulnerability, upgrade all affected Main 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.openrefine:main fixed: 3.8.3
<dependency>
    <groupId>org.openrefine</groupId>
    <artifactId>main</artifactId>
    <version>3.8.3</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.openrefine

How to Check if You Are Affected

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

mvn dependency:tree -Dincludes=org.openrefine

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

Note: The mvn dependency:tree -Dincludes=org.openrefine 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 Main, 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

### Summary Lack of CSRF protection on the `preview-expression` command means that visiting a malicious website could cause an attacker-controlled expression to be executed. The expression can contain arbitrary Clojure or Python code. The attacker must know a valid project ID of a project that contains at least one row. ### Details The `com.google.refine.commands.expr.PreviewExpressionCommand` class contains the following comment: ``` /** * The command uses POST but does not actually modify any state so it does not require CSRF. */ ``` However, this appears to be false (or no longer true). The expression being previewed (executed) can be written in GREL, Python, or Clojure. Since there are no restrictions on what code can be executed, the expression can do anything the user running OpenRefine can do. For instance, the following expressions start a calculator: ``` clojure:(.exec (Runtime/getRuntime) "gnome-calculator") ``` ``` jython:import os;os.system("gnome-calculator") ``` The lack of restrictions on expressions is arguably not a problem if the user is typing their own expressions into OpenRefine: they could have just as well typed them into Clojure or Python directly. However, since the `preview-expression` command does not check for a CSRF token, the expression can actually come from a HTML form submitted by a different origin, including arbitrary websites. Issue #2164 suggested adding CSRF protection to all endpoints, but this endpoint was skipped (and the above comment added) in the associated PR #2182. ### PoC An example "malicious" page is at https://wandernauta.nl/or/ (of course, actual malicious pages would not wait for the victim to press the submit button). The following curl command (substituting the project ID) also demonstrates the issue: ```sh curl -d project=123456789 -d cellIndex=1 -d rowIndices='[0]' -d 'expression=clojure:(.exec (Runtime/getRuntime) "gnome-calculator")' http://localhost:3333/command/core/preview-expression/ ``` ### Impact CSRF into remote code execution, provided the attacker knows at least one project ID in the victim's workspace and can convince the victim to open a malicious webpage.

CVE-2024-47879 Affected Main Versions

1 component(s)
Fixed Versions:
3.8.3
Product / Package Ecosystem Affected Versions Fixed Version
org.openrefine:main
Maven
< 3.8.3
3.8.3

References

Frequently Asked Questions

What is CVE-2024-47879?
CVE-2024-47879 is a security vulnerability in Main involving OpenRefine's PreviewExpressionCommand, which is eval, lacks protection against cross-site request forgery (CSRF) under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which Main versions are affected?
Affected versions include releases prior to 3.8.3 across affected packages: org.openrefine:main.
What version fixes CVE-2024-47879?
Upgrading to 3.8.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is main affected?
Yes, org.openrefine:main is affected in releases prior to 3.8.3. Upgrade your dependency to 3.8.3 or later.
What is the CVSS score of CVE-2024-47879?
CVE-2024-47879 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:U/C:H/I:H/A:L.
What CWE is associated with CVE-2024-47879?
CVE-2024-47879 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-47879?
Run the dependency tree command: 'mvn dependency:tree -Dincludes=org.openrefine'. 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-3jm4-c6qf-jrh3",
  "modified" : "2024-12-04T22:18:02Z",
  "published" : "2024-10-24T17:58:53Z",
  "aliases" : [ "CVE-2024-47879" ],
  "summary" : "OpenRefine's PreviewExpressionCommand, which is eval, lacks protection against cross-site request forgery (CSRF)",
  "details" : "### Summary\n\nLack of CSRF protection on the `preview-expression` command means that visiting a malicious website could cause an attacker-controlled expression to be executed. The expression can contain arbitrary Clojure or Python code.\n\nThe attacker must know a valid project ID of a project that contains at least one row.\n\n### Details\n\nThe `com.google.refine.commands.expr.PreviewExpressionCommand` class contains the following comment:\n```\n/**\n * The command uses POST but does not actually modify any state so it does not require CSRF.\n */\n```\n\nHowever, this appears to be false (or no longer true). The expression being previewed (executed) can be written in GREL, Python, or Clojure. Since there are no restrictions on what code can be executed, the expression can do anything the user running OpenRefine can do. For instance, the following expressions start a calculator:\n\n```\nclojure:(.exec (Runtime/getRuntime) \"gnome-calculator\")\n```\n\n```\njython:import os;os.system(\"gnome-calculator\")\n```\n\nThe lack of restrictions on expressions is arguably not a problem if the user is typing their own expressions into OpenRefine: they could have just as well typed them into Clojure or Python directly. However, since the `preview-expression` command does not check for a CSRF token, the expression can actually come from a HTML form submitted by a different origin, including arbitrary websites.\n\nIssue #2164 suggested adding CSRF protection to all endpoints, but this endpoint was skipped (and the above comment added) in the associated PR #2182.\n\n### PoC\n\nAn example \"malicious\" page is at https://wandernauta.nl/or/ (of course, actual malicious pages would not wait for the victim to press the submit button).\n\nThe following curl command (substituting the project ID) also demonstrates the issue:\n\n```sh\ncurl -d project=123456789 -d cellIndex=1 -d rowIndices='[0]' -d 'expression=clojure:(.exec (Runtime/getRuntime) \"gnome-calculator\")' http://localhost:3333/command/core/preview-expression/\n```\n\n### Impact\n\nCSRF into remote code execution, provided the attacker knows at least one project ID in the victim's workspace and can convince the victim to open a malicious webpage.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.openrefine:main"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.8.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/OpenRefine/OpenRefine/security/advisories/GHSA-3jm4-c6qf-jrh3"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-47879"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/OpenRefine/OpenRefine/commit/090924ca923489b6c94397cf1f5df7f7f78f0126"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/OpenRefine/OpenRefine"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-352", "CWE-94" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-10-24T17:58:53Z",
    "nvd_published_at" : "2024-10-24T21:15:12Z"
  }
}