You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "rich7420 (via GitHub)" <gi...@apache.org> on 2026/07/14 04:19:20 UTC
[PR] HDDS-15851. Return 403 for expired or out-of-range pre-signed S3 URLs [ozone]
rich7420 opened a new pull request, #10749:
URL: https://github.com/apache/ozone/pull/10749
What changes were proposed in this pull request?
The S3 Gateway reports an expired or out-of-range pre-signed URL as 400 MalformedHeader. AWS S3 returns 403 AccessDenied for both. This maps only those two pre-signed expiry failures to 403 AccessDenied, leaving genuinely malformed signatures at 400.
- MalformedResourceException gains an accessDenied
- AuthorizationV4QueryParser.validateDateAndExpires() sets the flag for (a) an expired pre-signed URL and (b) an out-of-range
X-Amz-Expires.
- AWSSignatureProcessor maps the flag to ACCESS_DENIED (403) instead of MALFORMED_HEADER (400). It is the single catch site for
MalformedResourceException, so all parsers route th
What is the link to the Apache JIRA?
https://issues.apache.org/jira/browse/HDDS-15851
How was this patch tested?
https://github.com/rich7420/ozone/actions/runs/29302072421
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-15851. Return 403 for expired or out-of-range pre-signed S3 URLs [ozone]
Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on code in PR #10749:
URL: https://github.com/apache/ozone/pull/10749#discussion_r3577623989
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/signature/MalformedResourceException.java:
##########
@@ -23,17 +23,32 @@
*/
public class MalformedResourceException extends Exception {
private final String resource;
+ private final boolean accessDenied;
public MalformedResourceException(String resource) {
+ this(resource, false);
+ }
+
+ public MalformedResourceException(String resource, boolean accessDenied) {
this.resource = resource;
+ this.accessDenied = accessDenied;
Review Comment:
I think we should use a dedicated exception for "access denied" case, e.g. `org.apache.hadoop.security.AccessControlException`, or create a new class if needed.
##########
hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/signature/TestAWSSignatureProcessor.java:
##########
@@ -37,4 +46,35 @@ public void testLowerCaseHeaderMapRemovesKeysCaseInsensitively() {
headers.remove("AUTHORIZATION"));
assertFalse(headers.containsKey("authorization"));
}
+
+ @Test
+ public void testOutOfRangeExpiresPreSignedUrlReturns403() throws Exception {
+ // A pre-signed URL whose X-Amz-Expires is out of range must be rejected
+ // with 403 AccessDenied, not 400 MalformedHeader.
+ MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<>();
+ queryParams.putSingle("X-Amz-Algorithm", "AWS4-HMAC-SHA256");
+ queryParams.putSingle("X-Amz-Credential",
+ "AKIAIOSFODNN7EXAMPLE%2F20130524%2Fus-east-1%2Fs3%2Faws4_request");
+ queryParams.putSingle("X-Amz-Date", "20130524T000000Z");
+ queryParams.putSingle("X-Amz-Expires", "604801");
+ queryParams.putSingle("X-Amz-SignedHeaders", "host");
+ queryParams.putSingle("X-Amz-Signature",
+ "aeeed9bbccd4d02ee5c0109b86d86835f995330da4c265957d157751f604d404");
+
+ UriInfo uriInfo = mock(UriInfo.class);
+ when(uriInfo.getQueryParameters()).thenReturn(queryParams);
+ when(uriInfo.getPathParameters()).thenReturn(new MultivaluedHashMap<>());
+ when(uriInfo.getPath()).thenReturn("key");
+ ContainerRequestContext context = mock(ContainerRequestContext.class);
+ when(context.getUriInfo()).thenReturn(uriInfo);
+ when(context.getHeaders()).thenReturn(new MultivaluedHashMap<>());
+ when(context.getMethod()).thenReturn("GET");
+
+ AWSSignatureProcessor processor = new AWSSignatureProcessor();
+ processor.setContext(context);
+
+ OS3Exception ex = assertThrows(OS3Exception.class, processor::parseSignature);
+ assertEquals(HttpStatus.SC_FORBIDDEN, ex.getHttpCode());
+ assertEquals("AccessDenied", ex.getCode());
Review Comment:
nit: simplfy using `EndpointTestUtils.assertErrorResponse`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-15851. Return 403 for expired or out-of-range pre-signed S3 URLs [ozone]
Posted by "rich7420 (via GitHub)" <gi...@apache.org>.
rich7420 commented on code in PR #10749:
URL: https://github.com/apache/ozone/pull/10749#discussion_r3577914069
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/signature/MalformedResourceException.java:
##########
@@ -23,17 +23,32 @@
*/
public class MalformedResourceException extends Exception {
private final String resource;
+ private final boolean accessDenied;
public MalformedResourceException(String resource) {
+ this(resource, false);
+ }
+
+ public MalformedResourceException(String resource, boolean accessDenied) {
this.resource = resource;
+ this.accessDenied = accessDenied;
Review Comment:
ok , I'll create a new class
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-15851. Return 403 for expired or out-of-range pre-signed S3 URLs [ozone]
Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on PR #10749:
URL: https://github.com/apache/ozone/pull/10749#issuecomment-4971423471
Thanks @rich7420 for updating the patch.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-15851. Return 403 for expired or out-of-range pre-signed S3 URLs [ozone]
Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai merged PR #10749:
URL: https://github.com/apache/ozone/pull/10749
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-15851. Return 403 for expired or out-of-range pre-signed S3 URLs [ozone]
Posted by "rich7420 (via GitHub)" <gi...@apache.org>.
rich7420 commented on PR #10749:
URL: https://github.com/apache/ozone/pull/10749#issuecomment-4971639204
@adoroszlai thanks for the review!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org