Skip to content

percent-encode IMDS role name before building credentials url - #3759

Open
ubeddulla wants to merge 1 commit into
boto:developfrom
ubeddulla:imds-role-name-encoding
Open

percent-encode IMDS role name before building credentials url#3759
ubeddulla wants to merge 1 commit into
boto:developfrom
ubeddulla:imds-role-name-encoding

Conversation

@ubeddulla

Copy link
Copy Markdown

InstanceMetadataFetcher._get_credentials appends the role name straight onto the security-credentials path, and that role name is the raw response body returned by _get_iam_role over IMDS, so a value containing separators like ../, ? or # rewrites which resource the credentials request lands on. I ran a small fetcher test with a role-name body of ../../../../latest/meta-data/iam/info and the credentials GET went to .../security-credentials/../../../../latest/meta-data/iam/info. Encoding the segment with quote and a safe set of the characters legal in an IAM role name keeps valid names byte-identical while neutralizing the separators.

@ubeddulla
ubeddulla requested a review from a team as a code owner July 29, 2026 10:45
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.

1 participant