-
Notifications
You must be signed in to change notification settings - Fork 916
CredentialsEndpointProvider.java: Adds the sending of a User-Agent other than default User-Agent to the metadata service #471
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
CredentialsEndpointProvider.java: Adds the sending of a User-Agent other than default User-Agent to the metadata service #471
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like HttpCredentialsUtilsTest
failed, could you fix that?
@@ -56,7 +57,12 @@ default CredentialsEndpointRetryPolicy retryPolicy() { | |||
* Allows passing additional headers to the request | |||
*/ | |||
default Map<String, String> headers() { | |||
return Collections.emptyMap(); | |||
Map<String, String> requestHeaders = new HashMap<String, String>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we use diamond operator here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure thing
@zoewangg the tests fail because of NullPointerException. I'm trying to use |
VersionInfo is generated from the build process. I think the tests failed because we are mocking the Mockito.when(mockConnection.connectToEndpoint(endpoint, emptyHeaders)).thenThrow(new IOException()); So we just need to update the empty headers with the default headers. |
Once the build succeeds, could you add a new-change entry? you can do that by running the scripts/new-change script and following the instructions. Can you confirm that this PR is submitted under Apache 2.0 license by checking the |
Will do, working on these changes |
@zoewangg updated |
@willbengtson Thanks for making the changes! LGTM. Looks like the branch is out-of-date with master. Could you do a merge from master and then squash all commits to a single commit? I'll merge it afterwards. |
…her than default User-Agent in Java when making requests to metadata service Similar to AWS Golang SDK and Ruby SDK, send a User-Agent other than the default User-Agent when making requests to the EC2 metadata for credentials. aws/aws-sdk-java#1562 for aws-sdk-java addresses this also. PR aws#1445 for botocore implements this too. This will enable protection of AWS credentials from Server Side Request Forgery (SSRF) vectors by being able to use a metadata proxy to block requests that do not have the right User-Agent set. User-Agent is not controllable by an attacker via SSRF.
f89c21f
to
313f7c9
Compare
@zoewangg Done |
…7083fb6a Pull request: release <- staging/a671180a-b536-44af-99a2-6ce57083fb6a
Adds the sending of a User-Agent other than default User-Agent in Java when making requests to metadata service
Similar to AWS Golang SDK and Ruby SDK, send a User-Agent other than the default User-Agent when making requests to the EC2 metadata for credentials.
aws/aws-sdk-java#1562 for aws-sdk-java addresses this also. PR #1445 for botocore implements this too.
This will enable protection of AWS credentials from Server Side Request Forgery (SSRF) vectors by being able to use a metadata proxy to block requests that do not have the right User-Agent set. User-Agent is not controllable by an attacker via SSRF.
Description
Set default headers in the
CredentialsEndpointProvider
interfaceMotivation and Context
This will enable protection of AWS credentials from Server Side Request Forgery (SSRF) vectors by being able to use a metadata proxy to block requests that do not have the right User-Agent set. User-Agent is not controllable by an attacker via SSRF.
Testing
Screenshots (if appropriate)
Types of changes
Checklist
mvn install
succeedsLicense