From da3bf25c434e0a96944d2646ee2192a12593f277 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Mon, 26 Oct 2026 12:56:24 +1300 Subject: [PATCH 1/2] fix(cli): take turns with the security key across commands Two rack-gateway commands using the security key at once (two AI agents each running a command) both failed: the key answers one at a time, and libfido2 reported "rx error" or "unsupported option" to the other, after the person had entered both PINs and touched the key. The person also couldn't tell which touch was for which command. Every command now holds a lock while it uses the key: from its PIN dialog to its touch, and around the PIN check in the script review dialog. The lock file is in the user's cache directory, which every command shares (an agent session can have a TMPDIR of its own), and the operating system releases it when a command exits. A command that has to wait says so. The config file lock moves onto the same filelock package. --- .../docs/user-guide/cli/mfa-verification.mdx | 4 ++ internal/cli/config_lock.go | 16 ++---- internal/cli/config_lock_unix.go | 17 ------- internal/cli/config_lock_windows.go | 19 ------- internal/cli/filelock/filelock.go | 37 ++++++++++++++ internal/cli/filelock/filelock_test.go | 39 +++++++++++++++ internal/cli/filelock/filelock_unix.go | 27 ++++++++++ internal/cli/filelock/filelock_windows.go | 33 ++++++++++++ internal/cli/webauthn/key_lock.go | 37 ++++++++++++++ internal/cli/webauthn/key_lock_test.go | 50 +++++++++++++++++++ internal/cli/webauthn/pin_check.go | 32 +++++++----- internal/cli/webauthn/webauthn.go | 17 ++++++- 12 files changed, 265 insertions(+), 63 deletions(-) delete mode 100644 internal/cli/config_lock_unix.go delete mode 100644 internal/cli/config_lock_windows.go create mode 100644 internal/cli/filelock/filelock.go create mode 100644 internal/cli/filelock/filelock_test.go create mode 100644 internal/cli/filelock/filelock_unix.go create mode 100644 internal/cli/filelock/filelock_windows.go create mode 100644 internal/cli/webauthn/key_lock.go create mode 100644 internal/cli/webauthn/key_lock_test.go diff --git a/docs/src/content/docs/user-guide/cli/mfa-verification.mdx b/docs/src/content/docs/user-guide/cli/mfa-verification.mdx index 538416cd..20ecadfd 100644 --- a/docs/src/content/docs/user-guide/cli/mfa-verification.mdx +++ b/docs/src/content/docs/user-guide/cli/mfa-verification.mdx @@ -51,6 +51,10 @@ The CLI supports multiple MFA methods: you don't miss one while the terminal is out of sight. On macOS, allow notifications for Script Editor if they don't appear. To turn them off, set `"touch_notifications": false` in `~/.config/rack-gateway/config.json`. + Commands take turns with the key. When two run at once (say, two AI agents each running a command), the second + prints `Waiting for another rack-gateway command to finish with the security key...` and asks for its PIN and + touch only once the first has its touch, so each prompt is for one command. + Only security keys marked **CLI Compatible** in the web UI can be used from the CLI.