Skip to content

Commit

Permalink
DBZ-6157 Disable potentially dangerous MySQL JDBC props
Browse files Browse the repository at this point in the history
  • Loading branch information
jpechane committed May 4, 2023
1 parent 4be4f5c commit 58ef4f0
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,13 @@ public MySqlConnectionConfiguration(Configuration config) {

jdbcConfigBuilder.with(JDBC_PROPERTY_CONNECTION_TIME_ZONE, determineConnectionTimeZone(dbConfig));

// Set and remove options to prevent potential vulnerabilities
jdbcConfigBuilder
.with("allowLoadLocalInfile", "false")
.with("allowUrlInLocalInfile", "false")
.with("autoDeserialize", false)
.without("queryInterceptors");

this.jdbcConfig = JdbcConfiguration.adapt(jdbcConfigBuilder.build());
String driverClassName = this.jdbcConfig.getString(MySqlConnectorConfig.JDBC_DRIVER);
factory = JdbcConnection.patternBasedFactory(MySqlConnection.URL_PATTERN, driverClassName, getClass().getClassLoader());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ public Builder withDefault(String key, String value) {
return this;
}

@Override
public Builder without(String key) {
builder.without(key);
return this;
}

@Override
public Builder apply(Consumer<SqlServerJdbcConfiguration.Builder> function) {
function.accept(this);
Expand Down Expand Up @@ -148,6 +154,12 @@ public Builder withDefault(String key, String value) {
return this;
}

@Override
public Builder without(String key) {
builder.without(key);
return this;
}

@Override
public Builder apply(Consumer<SqlServerJdbcConfiguration.Builder> function) {
function.accept(this);
Expand Down
14 changes: 14 additions & 0 deletions debezium-core/src/main/java/io/debezium/config/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,14 @@ default B withDefault(Field field, Class<?> value) {
return withDefault(field.name(), value != null ? value.getName() : null);
}

/**
* Remove the value associated with the specified key.
*
* @param key the key
* @return this builder object so methods can be chained together; never null
*/
B without(String key);

/**
* Apply the function to this builder.
*
Expand Down Expand Up @@ -691,6 +699,12 @@ public Builder withDefault(String key, String value) {
return this;
}

@Override
public Builder without(String key) {
props.remove(key);
return this;
}

@Override
public Builder apply(Consumer<Builder> function) {
function.accept(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ public Builder withDefault(String key, String value) {
return this;
}

@Override
public Builder without(String key) {
builder.without(key);
return this;
}

@Override
public Builder apply(Consumer<Builder> function) {
function.accept(this);
Expand Down Expand Up @@ -264,6 +270,12 @@ public Builder withDefault(String key, String value) {
return this;
}

@Override
public Builder without(String key) {
builder.without(key);
return this;
}

@Override
public Builder apply(Consumer<Builder> function) {
function.accept(this);
Expand Down

0 comments on commit 58ef4f0

Please sign in to comment.