Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove timestamp validation for requests that use query string authentication #651

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

timursaikaliev
Copy link
Contributor

Relates to #648

@@ -447,9 +447,6 @@ public final void doHandle(HttpServletRequest baseRequest,
dateSkew = parseIso8601(request.getHeader(
AwsHttpHeaders.DATE));
}
} else if (request.getParameter("X-Amz-Date") != null) { // v4 query
String dateString = request.getParameter("X-Amz-Date");
dateSkew = parseIso8601(dateString);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a unit test that shows this problem more clearly? This will allow fixing the underlying issue more easily.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I just saw #648 (comment). I'm trying to understand the intention from AWS -- do the Date parameters/headers only apply to unauthenticated requests and the Expires parameters apply to authenticated requests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Date Header: Used in both unauthenticated and authenticated requests. For authenticated requests, it's part of the signing process.

  • Expires Parameter: Used for pre-signed URLs to specify how long the URL is valid. It applies to authenticated requests where temporary access is provided.

When using pre-signed URLs in AWS, the Date header is generally not required as the timestamp and expiration are included in the URL parameters themselves. The crucial components in a pre-signed URL are the Expires parameter and the signature, which are used to validate the request.

Even if the Date header is not included, AWS validates the pre-signed URL based on the following:

  1. Expiration Check:
  • AWS checks the current time against the Expires parameter in the URL. If the current time is beyond the expiration time specified, the request is denied.
  1. Signature Verification:
  • AWS verifies that the signature is correct by recalculating the expected signature using the provided parameters (including Expires).

  • This ensures the URL has not been altered since it was generated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, if we use a pre-signed URL with no Date header, but even with Date parameters in the request, we don't need to validate the timestamp, because if we do, we will always get an error when maximumTimeSkew expires, which is 15 minutes by default.

@timursaikaliev timursaikaliev requested a review from gaul June 14, 2024 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants