mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(s3): prevent S3VirtualHostFilter from hijacking non-S3 requests (#199)
This commit is contained in:
1 parent
665af53149
commit
59cdc3fea6
6 files changed
+170
No files matched your search
@@ -16,6 +16,21 @@ public class S3VirtualHostFilter implements ContainerRequestFilter {
|
||||
String host = requestContext.getHeaderString("Host");
|
||||
if (host == null) return;
|
||||
|
||||
// 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")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// S3 does not use these content types for bucket/object operations,
|
||||
// but other AWS services (AwsQuery, JSON protocols) do.
|
||||
String contentType = requestContext.getHeaderString("Content-Type");
|
||||
if (contentType != null && (
|
||||
contentType.startsWith("application/x-www-form-urlencoded") ||
|
||||
contentType.startsWith("application/x-amz-json-"))) {
|
||||
return;
|
||||
}
|
||||
|
||||
String bucket = extractBucket(host);
|
||||
if (bucket == null) return;
|
||||
|
||||
|
||||
Reference in new issue
Block a user