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

Fix IMDSv2 URL when fetching credentials #1464

Closed
wants to merge 1 commit into from

Conversation

setu4993
Copy link
Contributor

@setu4993 setu4993 commented Dec 6, 2024

I missed 1 change in the final version of #1437 where the URL to fetch the endpoint must include "/latest/meta-data/iam/security-credentials/" before the role name. This adds that back.

Closes #1459.

Comment on lines -511 to -517
urlunsplit(
url_replace(
urlsplit(url),
path="/latest/meta-data/iam/security-credentials/",
),
),
headers=headers,
Copy link
Contributor Author

@setu4993 setu4993 Dec 6, 2024

Choose a reason for hiding this comment

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

This seemed unnecessary so I simplified it with L507.

)
role_names = res.data.decode("utf-8").split("\n")
if not role_names:
raise ValueError(f"no IAM roles attached to EC2 service {url}")
url += "/" + role_names[0].strip("\r")
url += role_names[0].strip("\r")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The role gets added at the end of the URL that was updated on L507.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is also in the Go implementation here: https://github.com/minio/minio-go/blob/e337e77c06bbf8a65247fb018e59c1263e4d86e1/pkg/credentials/iam_aws.go#L400-L402

We just missed it in the revisions in #1437.

@setu4993
Copy link
Contributor Author

setu4993 commented Dec 6, 2024

@balamurugana : Fixes IMDSv2 that didn't work correctly. Only found out today.

@balamurugana
Copy link
Member

I am closing on behalf of #1465

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.

Invalid Address Used for IMDSv2
2 participants