-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for ClickHouse sql injection by removing ability to have expression in table options #16261
Fix for ClickHouse sql injection by removing ability to have expression in table options #16261
Conversation
plugin/trino-clickhouse/src/main/java/io/trino/plugin/clickhouse/ClickHouseClient.java
Outdated
Show resolved
Hide resolved
plugin/trino-clickhouse/src/main/java/io/trino/plugin/clickhouse/ClickHouseClient.java
Outdated
Show resolved
Hide resolved
@@ -363,7 +369,7 @@ public void setTableProperties(ConnectorSession session, JdbcTableHandle handle, | |||
.collect(toImmutableMap(Entry::getKey, entry -> entry.getValue().orElseThrow())); | |||
|
|||
ImmutableList.Builder<String> tableOptions = ImmutableList.builder(); | |||
ClickHouseTableProperties.getSampleBy(properties).ifPresent(value -> tableOptions.add("SAMPLE BY " + value)); | |||
ClickHouseTableProperties.getSampleBy(properties).ifPresent(value -> tableOptions.add("SAMPLE BY " + doubleQuote(value))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is quoting only SAMPLE BY
property sufficient? What about other properties?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same for all others.
2adb465
to
8d1092f
Compare
@@ -28,7 +28,7 @@ | |||
implements SessionPropertiesProvider | |||
{ | |||
public static final String MAP_STRING_AS_VARCHAR = "map_string_as_varchar"; | |||
|
|||
public static final String ALLOWED_EXPRESSION_IN_TABLE_OPTIONS = "allowed_expression_in_table_options"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we want to allow end-users to enable this session property. Otherwise, even if the cluster administrator disabled this flag in the config property, users can enable it and cause SQL injection.
I lean toward removing support for expressions though it might be a regression for some users. I roughly guess there're less users who specify the expression in the SAMPLE BY
in the connector. Also, security should win in this case. What do you think about it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored
in table options like SAMPLE BY e.t.c
8d1092f
to
d20aeff
Compare
plugin/trino-clickhouse/src/main/java/io/trino/plugin/clickhouse/ClickHouseClient.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good except for a comment.
Description
Fix for ClickHouse sql injection
by removing ability to have expression in table options
Additional context and related issues
Release notes
(x) Release notes are required, with the following suggested text: