-
Notifications
You must be signed in to change notification settings - Fork 202
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
Error when storing large token in keyring on macOS #1255
Comments
I can confirm the issue to be related to kubelogin version Not working:
Error message:
Working version:
|
I'm also seeing this issue since upgrading from
I was able to workaround it by setting the Our IdP is AWS Cognito and token length is around ~1,300 characters. |
Same same :) using keycloak/microsoft entraid |
Same issue. I can confirm that jamesrwhite's workaround works for me - i.e. add the Technical info:
So, it looks like possibly an integration issue with the OS keyring on MacOS perhaps? |
In the underlying library (go-keyring) it claims the limit for the keychain is around 3,000 bytes (source) but if you look at how it's actually implemented it's the combination of the Worth noting this is also once those values have been base64 encoded and shell escaped. A potential fix could be to calculate the length in the same way before calling Catching the error and falling back to disk storage seems simpler and less likely to break if the underlying library changes it's implementation in my opinion. I'd be happy to open a PR for this. |
Hi, As already mentioned OS: Win11 WSL-Version: 2.3.26.0 |
v1.32.1 is available with the fix of #1257. I think it is difficult to cover all edge cases in the fallback mode. I tested the keyring on Linux and it causes an error if dbus is not running. I'd like to change the default mode to |
@int128 thanks for merging and releasing my hotfix, I can confirm I'm no longer getting the same issue with |
<3 |
I had a use case where I was running oidc-login from a container which became problematic with the new keyring changes as it required dbus to be running inside the container causing this error: error: get-token: could not write the token cache: keyring write kubelogin/tokencache/...: dbus: couldn't determine address of session bus
Unable to connect to the server: getting credentials: exec: executable kubectl failed with exit code 1 Setting the |
It does make sense to use the OS keyring when available, since it is arguably more secure than just a file somewhere on disk. Having a fallback to disk when all else fails is good enough IMHO. If there are other errors that need to be exempted then those should be addressed separately, just like in #1257. |
I think the fallback mode will cause the complicated problem. It needs to handle a case if both keyring and disk have the credentials. For example,
It is possible to try to load the credentials from keyring and then disk, but I think it brings the other problems:
|
The decision could also be offloaded to the user. The problem with the original behaviour in 1.32.0 was that you just got an error from the Go library without any indication what went wrong. If the keyring was the default, the user could be given the choice to switch to disk storage, if an error with the keyring occurs. Then, being made aware of the security implications, the user could opt-in to storing it in a less secure place (on disk) by passing the Of course this is suboptimal long-term when the Go library is (hopefully) fixed to support longer tokens, but at least the user knows what happens with his token data and we tried the more secure option first. |
If the token is too large, it maybe makes sense to switch to envelope encryption? Generate a secret, encrypt the token with it, and store the key in the keyring. The key size is easy to control. Another idea, that might sound a bit silly but should be possible: Technically speaking only the signature of the token is security relevant. So storing just the signature of the token in the keyring is enough for security. However when people use access tokens instead of login tokens, there is no requirement for a JWT and therefore one can't just split the signature away. All in all, I want to emphasise: It's good we have these problems now, and we should solve them without offloading them to users, because offloading security to users is the worst security choice. |
That's right. I think we will be able to enforce keyring usage by default when the implementation is enough mature. |
Describe the issue
kubelogin repeatedly fails with:
To reproduce
Not sure how to reproduce this, as it's probably caused by a large token from our IdP. We do have a lot of groups that are mapped in the token, which significantly increases the token size.
Your environment
Additional context
I verified that this was not happening in version 1.31.1, so I'm relatively confident this is related to #973. The description of the PR states that
However, with every kubectl command, I noticed consecutive failures and wasn't able to obtain a token* to interact with the cluster. There was no fallback to the file-based cache. For a reason I don't understand yet, the new option
--no-keyring
also doesn't seem to be available (and neither is--force-keyring
), so I can't work around this by any other means than downgrading to 1.31.1:$ kubectl oidc-login --help | grep keyring $ kubectl oidc-login --version kubelogin version 1.32.0
*in fact, I did get a token (which I could verify with the verbose logging), but kubelogin wasn't able to persist it
The text was updated successfully, but these errors were encountered: