From e58784a4dc01c843d9284fea7f33367d0f9ae865 Mon Sep 17 00:00:00 2001 From: Aldo Borrero <82811+aldoborrero@users.noreply.github.com> Date: Mon, 30 Mar 2026 23:20:37 +0200 Subject: [PATCH] fix: gracefully decline signing requests for security keys The SSH agent cannot perform signing operations for FIDO2/security keys (ed25519-sk, ecdsa-sk) since these require physical hardware interaction (user presence/touch). Previously, the agent would attempt to find a matching private key and fail with an unhelpful error, which also caused issues with SSH agent multiplexers. Now the agent checks for sk key types early in the sign handler and returns SSH_AGENT_FAILURE immediately, allowing the SSH client to fall back to another agent or direct hardware access. Fixes #281 --- src/bin/rbw-agent/ssh_agent.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/bin/rbw-agent/ssh_agent.rs b/src/bin/rbw-agent/ssh_agent.rs index 4d0bb50c..bf84ffa0 100644 --- a/src/bin/rbw-agent/ssh_agent.rs +++ b/src/bin/rbw-agent/ssh_agent.rs @@ -57,6 +57,20 @@ impl ssh_agent_lib::agent::Session for SshAgent { ssh_agent_lib::ssh_key::Signature, ssh_agent_lib::error::AgentError, > { + // Security keys (FIDO2) require physical hardware interaction that + // this agent cannot perform. Decline early so the SSH client can + // fall back to another agent or direct hardware access. + if matches!( + &request.pubkey, + ssh_agent_lib::ssh_key::public::KeyData::SkEcdsaSha2NistP256(_) + | ssh_agent_lib::ssh_key::public::KeyData::SkEd25519(_) + ) { + return Err(ssh_agent_lib::error::AgentError::Other( + "security keys require hardware interaction; declining" + .into(), + )); + } + let pubkey = ssh_agent_lib::ssh_key::PublicKey::new(request.pubkey, "");