mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(dsql): refuse a connection that sends no TLS server name (#6282)
DSQL knows the cluster only by the TLS server name, and refuses a connection that sends none with FATAL 08P01 "unable to accept connection, sni was not received" once its password is in, whatever the password (measured). The endpoint fell back to the host in the token and let such a connection in. It now refuses it as DSQL does, and admit takes the cluster from the server name alone. The integration tests connected to 127.0.0.1 through pgjdbc's NonValidatingFactory and sent no server name; DsqlClusterFixture now gives pgjdbc a NonValidatingFactory that names the cluster, as the compatibility test's factory does.
This commit is contained in:
1 parent
a9ceee1de6
commit
d20084ade3
6 files changed
+61
-8
No files matched your search
@@ -276,9 +276,8 @@ public class DsqlEndpoint {
|
||||
|
||||
/**
|
||||
* Whether {@code token} lets {@code user} in, checked in the order DSQL reports: the cluster
|
||||
* the client asked for by name (or, without a name, the one the token is for), the action
|
||||
* the user needs, the token's expiry, then its signature and, for a role other than
|
||||
* {@code admin}, the IAM role mapped to it.
|
||||
* the client named as its TLS server, the action the user needs, the token's expiry, then its
|
||||
* signature and, for a role other than {@code admin}, the IAM role mapped to it.
|
||||
*/
|
||||
Admission admit(String token, String user, String serverName) {
|
||||
URI uri;
|
||||
@@ -294,8 +293,7 @@ public class DsqlEndpoint {
|
||||
return Admission.refused(null);
|
||||
}
|
||||
host = host.toLowerCase(Locale.ROOT);
|
||||
String target = serverName == null ? host : serverName.toLowerCase(Locale.ROOT);
|
||||
Route route = routes.get(target);
|
||||
Route route = routes.get(serverName.toLowerCase(Locale.ROOT));
|
||||
if (route == null || !route.host().equals(host)) {
|
||||
return Admission.refused(null);
|
||||
}
|
||||
|
||||
@@ -176,6 +176,12 @@ final class DsqlSession {
|
||||
refuse(out, "08006", ACCESS_DENIED, null);
|
||||
return;
|
||||
}
|
||||
if (serverName[0] == null) {
|
||||
// DSQL knows the cluster only by the TLS server name, and refuses a connection that sends
|
||||
// none once its password is in, whatever the password (measured).
|
||||
refuse(out, "08P01", "unable to accept connection, sni was not received", null);
|
||||
return;
|
||||
}
|
||||
String token = PostgresWire.cString(password.body(), 0).value();
|
||||
DsqlEndpoint.Admission admission = endpoint.admit(token, user, serverName[0]);
|
||||
if (!admission.allowed()) {
|
||||
|
||||
Reference in new issue
Block a user