fix(s3): route signed multipart requests by virtual host (#3464)

* fix(s3): route signed multipart requests by virtual host

* fix(s3): recognize presigned virtual-host requests

---------

Co-authored-by: xujiantop-crypto <265865031+xujiantop-crypto@users.noreply.github.com>
This commit is contained in:
XuJianandxujiantop-crypto authored and GitHub committed 2026-09-13 00:42:15 -04:00
1 parent ae7548a70c
commit 01ec7af8d5
3 files changed
+102 -4

No files matched your search

@@ -107,14 +107,20 @@ public class S3VirtualHostFilter implements ContainerRequestFilter {
// Do not hijack requests meant for other AWS services
String auth = requestContext.getHeaderString("Authorization");
if (auth != null && auth.contains("Credential=") && !auth.contains("/s3/aws4_request")) {
boolean hasAuthorizationCredential = auth != null && auth.contains("Credential=");
boolean headerSignedForS3 = hasAuthorizationCredential && auth.contains("/s3/aws4_request");
if (hasAuthorizationCredential && !headerSignedForS3) {
return;
}
String queryCredential = requestContext.getUriInfo().getQueryParameters()
.getFirst("X-Amz-Credential");
boolean signedForS3 = headerSignedForS3
|| queryCredential != null && queryCredential.contains("/s3/aws4_request");
// S3 does not use these content types for bucket/object operations,
// but other AWS services (AwsQuery, JSON protocols) do.
// Other AWS services use these content types on the shared edge endpoint. An explicit
// S3 SigV4 scope is authoritative, including empty-body multipart initiation requests.
String contentType = requestContext.getHeaderString("Content-Type");
if (contentType != null && (
if (!signedForS3 && contentType != null && (
contentType.startsWith("application/x-www-form-urlencoded") ||
contentType.startsWith("application/x-amz-json-"))) {
return;