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

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/main/java/org/gaul/s3proxy/S3ProxyHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.

} else if (hasDateHeader) {
try {
dateSkew = request.getDateHeader(HttpHeaders.DATE);
Expand Down
Loading