fix: return BadRequest for S3 dot-dot paths (#1325)

This commit is contained in:
David Phillips authored and GitHub committed 2026-06-13 19:55:26 -05:00
1 parent cf761a9698
commit 763cdb5314
2 files changed
+25 -8

No files matched your search

@@ -1894,7 +1894,7 @@ class S3IntegrationTest {
.get("/{bucket}/%2e%2e/%2e%2e/secret.txt")
.then()
.statusCode(400)
.body(containsString("InvalidKey"));
.body(equalTo(""));
// 2. Null byte (survives URL-decoding but fails java.nio.file.Path validation)
given()
@@ -1917,7 +1917,7 @@ class S3IntegrationTest {
.get("/{bucket}/%2E%2E/%2E%2E/secret.txt")
.then()
.statusCode(400)
.body(containsString("InvalidKey"));
.body(equalTo(""));
}
@Test
@@ -1969,7 +1969,7 @@ class S3IntegrationTest {
.put("/test-bucket/../../secret.txt")
.then()
.statusCode(400)
.body(containsString("InvalidKey"));
.body(equalTo(""));
}
@Test
@@ -1983,7 +1983,7 @@ class S3IntegrationTest {
.put("/test-bucket/%2E%2E/%2E%2E/secret.txt")
.then()
.statusCode(400)
.body(containsString("InvalidKey"));
.body(equalTo(""));
}
@Test
@@ -1997,7 +1997,7 @@ class S3IntegrationTest {
.put("/test-bucket/%2E%2E%2Fsecret.txt")
.then()
.statusCode(400)
.body(containsString("InvalidKey"));
.body(equalTo(""));
}
@Test
@@ -2033,6 +2033,19 @@ class S3IntegrationTest {
.body(containsString("ListBucketResult"));
}
@Test
@Order(205)
void putObjectWithTraversalAfterBucketPrefixReturnsBadRequest() {
given()
.contentType("text/plain")
.body("safe-data")
.when()
.put("/test-bucket/../secret.txt")
.then()
.statusCode(400)
.body(equalTo(""));
}
private static String customerKeyMd5(String customerKey) {
try {
byte[] md5 = MessageDigest.getInstance("MD5").digest(Base64.getDecoder().decode(customerKey));