Presto JDBC Server-Side Request Forgery by nextUri
Date: 2023-10
Affected: maven/com.facebook.presto:presto-jdbc
Attack vector: ssrf
Category: vulnerability-disclosure
Severity: High
CWE: CWE-918
CVSS: 7.6 (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:L/A:L)

### 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":"what


Mitigations:

Architectural layers (MAESTRO):