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

key_list(): embedded nul in string #158

Open
Ido-deBaat opened this issue Dec 27, 2024 · 3 comments · May be fixed by #159
Open

key_list(): embedded nul in string #158

Ido-deBaat opened this issue Dec 27, 2024 · 3 comments · May be fixed by #159

Comments

@Ido-deBaat
Copy link

Hi!

When I try to list the keys in my default (login) keyring with list_keys(keyring = "login") I get the following error:

Error in b_macos_list(self, private, service, keyring) : 
  embedded nul in string: blablablub

When I create a new keyring with a bunch of keys, key_list() works fine. Also when I get an existing key from the login keychain with get_key(), all works fine.

I guess there is something wrong with one of my keys in the login keychain, but I can't figure out what. Mainly because Apple replaced the keychain access app with the new passwords app. The latter doesn't give me access to the login keychain and neither does keyring at this moment. In other words, I sadly can't create a reprex.

some version details:

keyring version: 1.3.2
macOS version: 15.1.1 (24B91)
R version: 4.2.2
@gaborcsardi
Copy link
Member

gaborcsardi commented Dec 28, 2024

Seems like it is possible to store arbitrary byte sequences in the keyring, and these are not always representable in R strings.

You can use keyring::key_get_raw() to query these values.

OTOH, ideally key_list() would still do better when this happens. I am not sure what it should do, two obvious choices are leaving out these keys or include an NA instead. Maybe also throw a warning.

We could probably also have a key_list_raw() function that always works.

Btw. you can still use the Keychain Access app, I think, if you start it up directly.

@Ido-deBaat
Copy link
Author

Btw. you can still use the Keychain Access app, I think, if you start it up directly.

Tnx! I wasn't aware. This saved me a lot of trouble!

As to key_list()'s behaviour... Looking at previously stored keys is quite important to the keyring workflow. Keyring is vital to the overall security of analysis workspaces for many teams :) So I guess I'd prefer key_list() to return NA's with a warning hinting to a key_list_raw() function.

gaborcsardi added a commit that referenced this issue Dec 29, 2024
For the case when they contain zero bytes. In this case the
`service` and/or `username` is `NA`.

Closes #158.
@gaborcsardi
Copy link
Member

You can try PR #159 if you still have a keychain item with a key with embedded zero bytes.

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 a pull request may close this issue.

2 participants