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 decrypt file: AssumeRoleTokenProvider session option not set #1299

Open
Thegaram opened this issue Sep 20, 2023 · 4 comments
Open

Comments

@Thegaram
Copy link

Possible regression in v3.8.0. Since upgrading, I'm unable to decrypt a file using AWS KMS. Verified that this works with v3.7.3.

Failed to get the data key required to decrypt the SOPS file.

Group 0: FAILED
  ****: FAILED
    - | could not load AWS config: assume role with MFA enabled, but
      | AssumeRoleTokenProvider session option not set.

Recovery failed because no master key was able to decrypt the file. In
order for SOPS to recover the file, at least one key has to be successful,
but none were.
@hiddeco
Copy link
Member

hiddeco commented Sep 20, 2023

This is a side-effect from updating to AWS SDK v2. The workaround is to prepare you environment before running a command, for example using a tool like https://github.com/99designs/aws-vault.

Terraform (and some other tools) suffer from the exact same problem, and you can find other information here: https://stackoverflow.com/questions/52432717/terraform-unable-to-assume-roles-with-mfa-enabled

@weiguo-pki
Copy link

in kms/keysource.go

	region := matches[1]

	cfg, err := config.LoadDefaultConfig(context.TODO(), func(lo *config.LoadOptions) error {
		// add to be compatible with MFA code input
                if lo.AssumeRoleCredentialOptions == nil {
			lo.AssumeRoleCredentialOptions = func(aro *stscreds.AssumeRoleOptions) {
				aro.TokenProvider = stscreds.StdinTokenProvider
			}
		}

		// Use the credentialsProvider if present, otherwise default to reading credentials
		// from the environment.
		if key.credentialsProvider != nil {
			lo.Credentials = key.credentialsProvider
		}
		if key.AwsProfile != "" {
			lo.SharedConfigProfile = key.AwsProfile
		}

@GreasyAvocado
Copy link

I'm having a similar issue.
A file gets properly decrypted with v3.7.x, but not with v3.8.x:

Failed to get the data key required to decrypt the SOPS file.

Group 0: FAILED
  <REDACTED KMS KEY ARN>: FAILED
    - | failed to decrypt sops data key with AWS KMS: operation
      | error KMS: Decrypt, https response error StatusCode: 400,
      | RequestID: <REDACTED REQUEST ID>,
      | IncorrectKeyException: The key ID in the request does not
      | identify a CMK that can perform this operation.

Recovery failed because no master key was able to decrypt the file. In
order for SOPS to recover the file, at least one key has to be successful,
but none were.

It's not AssumeRole or identity related, as described in this issue, but I guess it's in the same area.

Any idea what's wrong here?

@guitarrapc
Copy link

Issue happens but move foward to aws-vault + sops fixed issue. thanks @hiddeco

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants