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

aws-vault fails with specified keyring backend not available when using kwallet without specifying the --backend flag #670

Closed
1 of 3 tasks
Mr-istov opened this issue Oct 9, 2020 · 12 comments
Labels

Comments

@Mr-istov
Copy link

Mr-istov commented Oct 9, 2020

Hello, until a few days ago while using aws-vault v5.4.0 I didn't had any problems running aws-vault with kwallet as a backend without specifying the --backend flag, but after upgrading to v6.1.0 it started throwing me the following error:

aws-vault: error: Specified keyring backend not available, try --help

This is the output with the --debug flag:

2020/10/09 17:29:23 [keyring] Considering backends: [secret-service]
2020/10/09 17:29:23 [keyring] Failed backend secret-service: The name org.freedesktop.secrets was not provided by any .service files
aws-vault: error: Specified keyring backend not available, try --help

If I run aws-vault with specifying the --backend=kwallet flag it seems that it works, but I wonder why I didn't had this problem before, was this changed with the upgrade somehow?

  • I am using the latest release of AWS Vault
  • I have provided my .aws/config (redacted if necessary)
  • I have provided the debug output using aws-vault --debug (redacted if necessary)
@gdamjan
Copy link

gdamjan commented Oct 9, 2020

the regression has been introduced with this change: 7572b93#diff-83de63909ead282862b13050fe347d68

removing the Default(backendsAvailable[0]). line fixes the issue - by not specifying a backend, and allowing keyring to find it automatically.

@Mr-istov
Copy link
Author

@mtibben Was there a reason as to why was that line added, and if it is not required, could it be removed?

@mtibben
Copy link
Member

mtibben commented Oct 12, 2020

AWS Vault should be able to tell you what backend it's going to use before it does - the "fallback" behaviour is good when when determining what default to display, but is not desirable when actually executing. If keyring is not returning available backends correctly, the problem is likely there.

@gdamjan
Copy link

gdamjan commented Oct 12, 2020

In both cases aws-vault reports available backends and their order
(v6.1.0):

  --backend=secret-service   Secret backend to use [secret-service kwallet pass file] ($AWS_VAULT_BACKEND)

patched with #672:

  --backend=BACKEND          Secret backend to use [secret-service kwallet pass file] ($AWS_VAULT_BACKEND)

the problem is that the Default(backendsAvailable[0]). line in aws-vault tells keyring to fix the backend to just that one, which actually limits what keyring is capable of.

@Mr-istov
Copy link
Author

As @gdamjan mentioned the Default(backendsAvailable[0]). seems to be causing the keyring to only consider the secret-service backend on Linux.
The code at fault seems to be here in globals.go when trying to open the keyring:

if a.keyringImpl == nil {
		if a.KeyringBackend != "" {
			a.KeyringConfig.AllowedBackends = []keyring.BackendType{keyring.BackendType(a.KeyringBackend)}
		}
		var err error
		a.keyringImpl, err = keyring.Open(a.KeyringConfig)

And then here in keyring.go:

if cfg.AllowedBackends == nil {
		cfg.AllowedBackends = AvailableBackends()
	}
	debugf("Considering backends: %v", cfg.AllowedBackends)

Since we make the default value of the a.KeyringBackend to be secret-service the value for the AllowedBackends here:
a.KeyringConfig.AllowedBackends = []keyring.BackendType{keyring.BackendType(a.KeyringBackend)} will make it be to [secret-service] , and it will not enter in the if statement which lists all the available backends since AllowedBackends is not nil

@mtibben
Copy link
Member

mtibben commented Oct 12, 2020

Yes that behaviour is intentional @gdamjan and @Mr-istov. Allowing the keyring to "fallback" is confusing, and results in lost credentials. See this keyring issue 99designs/keyring#74 (comment). We want to remove this behaviour from keyring altogether.

Instead keyring should determine at runtime which backends can be used, and aws-vault should specify which to use

@gdamjan
Copy link

gdamjan commented Oct 12, 2020

But then aws-vault defaults to 'secret-service' which is not even available on my system, instead of using 'kwallet' as it used before.

@mtibben
Copy link
Member

mtibben commented Oct 12, 2020

See my earlier comment

If keyring is not returning available backends correctly, the problem is likely there.

@Mr-istov
Copy link
Author

Instead keyring should determine at runtime which backends can be used, and aws-vault should specify which to use

Hmm well if that's the case if I may suggest, maybe it would be better to make the --backend flag required if the env var AWS_VAULT_BACKEND is not specified.
That way instead of forcing aws-vault to choose secret-service for a default backend for Linux, it will require the wanted backend to be specified with the env var or by the flag. That can be accomplished with the kingpin package:

Envar("AWS_VAULT_BACKEND").
Required().
EnumVar(&a.KeyringBackend, backendsAvailable...)

@mtibben
Copy link
Member

mtibben commented Oct 13, 2020

If secret-service isn't available, keyring shouldn't make that option available. I'm pretty sure secret service availability can be determined by a dbus call

@Mr-istov
Copy link
Author

@mtibben Yeah that seems understandable. This issue seems to be more applicable in keyring.
After some investigating seems that the problem is when initializing the keyring package, the secret-service seems to be added to the supportedBackends and the error is thrown when we try to open the keyring. I guess the best way would be, before adding secret-service backend to the supportedBackends there should be a check if that DBus service exists, I'm just not sure where that check would be more applicable, in keyring or go-libsecret

Since this issue is not relevant to aws-vault I plan on closing this issue and the associated PR and re-open them in keyring if there are no objections?

@zhkostadinov
Copy link

zhkostadinov commented Dec 1, 2021

Over Linux distribution, just run that sudo apt install gnome-keyring.
That resolved my issue.

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

No branches or pull requests

4 participants