I use a Yubikey in PIV/CCID mode. The PIN is sent from the host computer via automated script and unlocks the Yubikey PIV smartcard. In this mode, is it essential that the USB connection is trusted? In other words if an attacker can sniff the USB traffic can the attacker sniff the PIN and/or use the keys inside the Yubikey?
So if somebody would plug in a malicious USB HUB between my computer and the Yubikey could they first get the PIN and then steal the Yubikey and use it with the sniffed PIN?
All assuming the host is safe. I know that is somewhat of a contrived scenario: if somebody could add a malicious USB hub, they would likely also be able to compromise the host. But assume that the host is not compromised for argument's sake.
If the answer is that is that it is not secure in this scenario, where can I find more information about how the host sends data to the PIV applet in the Yubikey and how the connection might be encrypted via CCID and (PC/SC?)
PS: I know that OpenPGP card supports Key Derived Function (KDF) protected PINs. But (a) I am specifially asking about PIV in this question and not OpenPGP card applet. And (b) that would prevent anybody from sniffing the original PIN, but still would not prevent anybody from using the sniffed hash to access the applet. Or is there some kind of challenge response to prevent hash reuse? https://developers.yubico.com/PGP/YubiKey_5.2.3_Enhancements_to_OpenPGP_3.4.html