What happened

A repeated, five-second annoyance stemming from the inadvertent pressing of two SSH keys within a USB port led to a confusing authentication process. Both keys were configured as resident credentials with user verification required, meaning a PIN was needed before SSH could utilize them for authentication.

The issue surfaced when attempting to connect via GitHub, where the first key offered by the SSH agent – yk1-12345678 – successfully authenticated due to its association with the logged-in GitHub session. However, subsequent attempts using the second key, yk2-12345679, triggered a PIN dialog because the key’s ‘resident’ flag and user verification requirement demanded interaction.

Why it matters

The seemingly trivial interruption in the SSH authentication flow represented a significant security risk. The agent's key ordering, combined with the ‘user verification required’ flags on the keys, forced users into an unnecessary PIN entry process even when a valid key was already available.

This created a frustrating and confusing experience for the user while potentially exposing sensitive credentials to unauthorized access. This case illuminates how subtle design choices can significantly impact security posture and user friction.

But, but, but…

The root cause lay in the way OpenSSH handles resident keys and user verification. Without an SSH configuration file (~/.ssh/config) specifying identity files, the agent delivers keys in the order they are presented.

The user verification requirement added another layer of complexity, requiring a PIN before any key could be used for authentication. This forced the user to repeatedly enter their PIN, creating the five-second annoyance and ultimately triggering the entire sequence. The fact that both keys were configured as resident meant there was no silent fail – just an insistent prompt for the PIN.

“only after you have typed the PIN does the assertion request go down the wire, and only then does the key answer that it has never held this credential.”
— Dr Non

The counter-take

The reliance on agent-delivered keys without explicit configuration is often accepted as standard practice, but it introduces vulnerabilities related to key ordering and user verification flags. It's a reminder that trusting default behavior can be problematic in security contexts.

The AI angle

AI systems are increasingly relying on secure key management for access control and data protection. This incident underscores the importance of robust authentication protocols and careful consideration of user interaction requirements when implementing such systems, with a shift to asymmetric cryptography.