vaultix icon indicating copy to clipboard operation
vaultix copied to clipboard

vaultix renc crashes with thread panic when using age-plugin-yubikey

Open Curious-r opened this issue 4 months ago • 4 comments

I encountered a crash when running vaultix renc with a YubiKey identity (age-plugin-yubikey).

Because renc processes files concurrently, multiple threads try to hit the YubiKey's physical interface at the same time. This causes a conflict on the smart card reader, and the command ends up crashing with a thread scope panic at the end:

[nix-shell:~/Projects/nix-config]$ nix run .#vaultix.app.x86_64-linux.renc
INFO  [vaultix::cmd] start re-encrypt secrets
INFO  [vaultix::util::makeup] re-ecrypting...
Enter PIN for YubiKey with serial 61817144:
Enter PIN for YubiKey with serial 61817144:
Enter PIN for YubiKey with serial 61817144:
Enter PIN for YubiKey with serial 61817144:
Enter PIN for YubiKey with serial 61817144:
Enter PIN for YubiKey with serial 61817144:
Enter PIN for YubiKey with serial 61817144:
Enter PIN for YubiKey with serial 61817144:
Enter PIN for YubiKey with serial 61817144:
Enter PIN for YubiKey with serial 61817144:
Enter PIN for YubiKey with serial 61817144:
Enter PIN for YubiKey with serial 61817144:
Enter PIN for YubiKey with serial 61817144:
Enter PIN for YubiKey with serial 61817144:
Enter PIN for YubiKey with serial 61817144:
Enter PIN for YubiKey with serial 61817144:
Enter PIN for YubiKey with serial 61817144:
Enter PIN for YubiKey with serial 61817144:
INFO  [vaultix::util::makeup] finished
ERROR [vaultix::util::makeup] Getting Scope { num_running_threads: 1, a_thread_panicked: false, main_thread: Thread { id: ThreadId(1), name: Some("main"), .. }, .. } error

Also, even though my YubiKey PIN policy is set to once, I am prompted to enter my PIN consecutively for every single secret file in the repository during the run. It seems the plugin is being re-invoked in a separate process for each file, losing the session cache.

Curious-r avatar Jul 08 '26 07:07 Curious-r

After reading the source code, I found that this issue is not related to concurrency — the underlying implementation is sequential. The real problem was a lack of session caching for plugin identities, and the error at the end was not caused by hardware contention. It was a bug in how PIN entry failures were propagated: the error came through at the wrong time and with the wrong content. I've opened a PR with the fix.

Curious-r avatar Jul 08 '26 12:07 Curious-r

After reading the source code, I found that this issue is not related to concurrency — the underlying implementation is sequential. The real problem was a lack of session caching for plugin identities, and the error at the end was not caused by hardware contention. It was a bug in how PIN entry failures were propagated: the error came through at the wrong time and with the wrong content. I've opened a PR with the fix.

cc @oluceps

Curious-r avatar Jul 08 '26 12:07 Curious-r

Thanks for reporting! I need more time to investigate this issue. Since I can't reproduce it locally, can you provide your age-yubikey-plugin version and related nix config snippet? Seems it's a plugin interaction issue or essentially a decryption failure (and catches an obscure err msg).

oluceps avatar Jul 10 '26 18:07 oluceps

Thanks for reporting! I need more time to investigate this issue. Since I can't reproduce it locally, can you provide your age-yubikey-plugin version and related nix config snippet? Seems it's a plugin interaction issue or essentially a decryption failure (and catches an obscure err msg).

Thanks for reply, the nix config snippet is here: https://github.com/Curious-r/nix-config/blob/586b56d846de4ec08cc688cec8a69678c96f2a14/flake.nix#L171-L182 https://github.com/Curious-r/nix-config/blob/586b56d846de4ec08cc688cec8a69678c96f2a14/nixos/common/core/security.nix#L34

As the config shows, my age-yubikey-plugin version is following the nixos-unstable.

And you're right, this is fundamentally an interaction issue. The error thrown at the end happened because I intentionally pressed Enter without entering the PIN during one of the prompts, but there was no immediate feedback. Instead, the error was deferred until after all 18 interactions had completed, and the error message didn't clearly indicate it was related to the verification failure.

In the PR, I'm primarily addressing the interaction experience. As you can see from the log above, I was prompted for the PIN 18 times during renc, even though my key is configured with PIN Once. The PIN should have been cached and not required every time.

Curious-r avatar Jul 10 '26 19:07 Curious-r