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

Unable to obtain credentials for a profile that requires a double role assumption #6681

Closed
4 tasks done
iliapolo opened this issue Nov 20, 2024 · 5 comments
Closed
4 tasks done
Assignees
Labels
bug This issue is a bug. p2 This is a standard priority issue potential-regression Marking this issue as a potential regression to be checked by team member response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.

Comments

@iliapolo
Copy link

Checkboxes for prior research

Describe the bug

When using a profile that requires 2 role assumption, sts.getCallerIdentity fails.

Regression Issue

  • Select this option if this issue appears to be a regression.

SDK version number

@aws-sdk/client-sts@3.632.0, @aws-sdk/credential-providers@3.632.0

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v18.20.4

Reproduction Steps

Consider the following ~/.aws/credentials file:

# ACCOUNT_A
[role0]
aws_access_key_id        = XXXX
aws_secret_access_key    = XXXX
aws_session_token        = XXXX

# ACCOUNT_B
[role1]
source_profile = role0
role_arn       = arn:aws:iam::ACCOUNT_B:role/TestIssue32195

# ACCOUNT_B
[role2]
source_profile = role1
role_arn       = arn:aws:iam::ACCOUNT_B:role/TestIssue32195-2

All cross account trust policies and IAM policies have been setup properly to allow:

  • role0 can assume role1
  • role0 can assume role2
  • role1 can assume role2

Now run the following program:

import { STS } from '@aws-sdk/client-sts';
import { fromIni } from '@aws-sdk/credential-providers';

const creds = fromIni({ profile: 'role2' });

async function main() {
  const sts = new STS({ credentials: await creds() });
  await sts.getCallerIdentity();
}

void main();

Observed Behavior

AccessDenied: User: arn:aws:sts::ACCOUNT_B:assumed-role/TestIssue32195-2/aws-sdk-js-1732101456622 is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::ACCOUNT_B:role/TestIssue32195-2

Expected Behavior

The call should succeed and return the ARN of role2.

Possible Solution

No response

Additional Information/Context

  • Note that the error indicates that role2 is trying to assume itself. For some reason there seem to be an extra role assumption happening.
  • Using the same configuration file, the following aws cli command works: aws sts get-caller-identity --profile role2 (tested both aws cli v1 and v2).
  • This worked with the SDK v2.
  • Originally reported here: CDK CLI: assuming a doubly-chained role fails since 2.167.0 aws-cdk#32195
@iliapolo iliapolo added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 20, 2024
@github-actions github-actions bot added the potential-regression Marking this issue as a potential regression to be checked by team member label Nov 20, 2024
@zshzbh zshzbh self-assigned this Nov 20, 2024
@kuhe
Copy link
Contributor

kuhe commented Nov 20, 2024

Please try v3.651.1 or higher.

@zshzbh
Copy link
Contributor

zshzbh commented Nov 20, 2024

I'm using the dependencies below and can't reproduce this issue:

{
  "dependencies": {
    "@aws-sdk/client-sts": "^3.696.0",
    "@aws-sdk/credential-providers": "^3.696.0"
  }
}

As @kuhe commented above, try v3.651.1 or higher, and let us know if the issue persists.

@zshzbh zshzbh added response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Nov 20, 2024
@iliapolo
Copy link
Author

Will do thanks. Looks like I didn't dive deep enough through existing issues.

@iliapolo
Copy link
Author

Tested with 3.696.0 and all works. Thank you!

Copy link

github-actions bot commented Dec 5, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. p2 This is a standard priority issue potential-regression Marking this issue as a potential regression to be checked by team member response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.
Projects
None yet
Development

No branches or pull requests

3 participants