Skip to content

Commit d6cc86a

Browse files
authored
Improve message about insecure S3 settings (#116915)
Clarifies that insecure settings are stored in plaintext and must not be used. Also removes the mention of the (wrong) system property from the error message if insecure settings are not permitted.
1 parent c832572 commit d6cc86a

File tree

6 files changed

+19
-15
lines changed

6 files changed

+19
-15
lines changed

docs/changelog/116915.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 116915
2+
summary: Improve message about insecure S3 settings
3+
area: Snapshot/Restore
4+
type: enhancement
5+
issues: []

modules/repository-s3/src/main/java/org/elasticsearch/repositories/s3/S3Repository.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,7 @@ class S3Repository extends MeteredBlobStoreRepository {
318318
deprecationLogger.critical(
319319
DeprecationCategory.SECURITY,
320320
"s3_repository_secret_settings",
321-
"Using s3 access/secret key from repository settings. Instead "
322-
+ "store these in named clients and the elasticsearch keystore for secure settings."
321+
INSECURE_CREDENTIALS_DEPRECATION_WARNING
323322
);
324323
}
325324

@@ -336,6 +335,11 @@ class S3Repository extends MeteredBlobStoreRepository {
336335
);
337336
}
338337

338+
static final String INSECURE_CREDENTIALS_DEPRECATION_WARNING = Strings.format("""
339+
This repository's settings include a S3 access key and secret key, but repository settings are stored in plaintext and must not be \
340+
used for security-sensitive information. Instead, store all secure settings in the keystore. See [%s] for more information.\
341+
""", ReferenceDocs.SECURE_SETTINGS);
342+
339343
private static Map<String, String> buildLocation(RepositoryMetadata metadata) {
340344
return Map.of("base_path", BASE_PATH_SETTING.get(metadata.settings()), "bucket", BUCKET_SETTING.get(metadata.settings()));
341345
}

modules/repository-s3/src/test/java/org/elasticsearch/repositories/s3/RepositoryCredentialsTests.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,9 @@ public void testRepositoryCredentialsOverrideSecureCredentials() {
107107
assertThat(credentials.getAWSSecretKey(), is("insecure_aws_secret"));
108108

109109
assertCriticalWarnings(
110+
"[access_key] setting was deprecated in Elasticsearch and will be removed in a future release.",
110111
"[secret_key] setting was deprecated in Elasticsearch and will be removed in a future release.",
111-
"Using s3 access/secret key from repository settings. Instead store these in named clients and"
112-
+ " the elasticsearch keystore for secure settings.",
113-
"[access_key] setting was deprecated in Elasticsearch and will be removed in a future release."
112+
S3Repository.INSECURE_CREDENTIALS_DEPRECATION_WARNING
114113
);
115114
}
116115

@@ -194,10 +193,9 @@ public void testReinitSecureCredentials() {
194193

195194
if (hasInsecureSettings) {
196195
assertCriticalWarnings(
196+
"[access_key] setting was deprecated in Elasticsearch and will be removed in a future release.",
197197
"[secret_key] setting was deprecated in Elasticsearch and will be removed in a future release.",
198-
"Using s3 access/secret key from repository settings. Instead store these in named clients and"
199-
+ " the elasticsearch keystore for secure settings.",
200-
"[access_key] setting was deprecated in Elasticsearch and will be removed in a future release."
198+
S3Repository.INSECURE_CREDENTIALS_DEPRECATION_WARNING
201199
);
202200
}
203201
}
@@ -238,10 +236,7 @@ public void sendResponse(RestResponse response) {
238236
throw error.get();
239237
}
240238

241-
assertWarnings(
242-
"Using s3 access/secret key from repository settings. Instead store these in named clients and"
243-
+ " the elasticsearch keystore for secure settings."
244-
);
239+
assertWarnings(S3Repository.INSECURE_CREDENTIALS_DEPRECATION_WARNING);
245240
}
246241

247242
private void createRepository(final String name, final Settings repositorySettings) {

server/src/main/java/org/elasticsearch/common/ReferenceDocs.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public enum ReferenceDocs {
8282
CIRCUIT_BREAKER_ERRORS,
8383
ALLOCATION_EXPLAIN_NO_COPIES,
8484
ALLOCATION_EXPLAIN_MAX_RETRY,
85+
SECURE_SETTINGS,
8586
// this comment keeps the ';' on the next line so every entry above has a trailing ',' which makes the diff for adding new links cleaner
8687
;
8788

server/src/main/java/org/elasticsearch/common/settings/SecureSetting.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,7 @@ private InsecureStringSetting(String name) {
185185
@Override
186186
public SecureString get(Settings settings) {
187187
if (ALLOW_INSECURE_SETTINGS == false && exists(settings)) {
188-
throw new IllegalArgumentException(
189-
"Setting [" + name + "] is insecure, " + "but property [allow_insecure_settings] is not set"
190-
);
188+
throw new IllegalArgumentException("Setting [" + name + "] is insecure, use the elasticsearch keystore instead");
191189
}
192190
return super.get(settings);
193191
}

server/src/main/resources/org/elasticsearch/common/reference-docs-links.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@ FORMING_SINGLE_NODE_CLUSTERS modules-discover
4444
CIRCUIT_BREAKER_ERRORS circuit-breaker-errors.html
4545
ALLOCATION_EXPLAIN_NO_COPIES cluster-allocation-explain.html#no-valid-shard-copy
4646
ALLOCATION_EXPLAIN_MAX_RETRY cluster-allocation-explain.html#maximum-number-of-retries-exceeded
47+
SECURE_SETTINGS secure-settings.html

0 commit comments

Comments
 (0)