-
-
Notifications
You must be signed in to change notification settings - Fork 274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement commands for management of resident keys #392
Conversation
There are still some loose ends to deal with but it is pretty close |
Think this is also related to my issue #314 |
Nice reverse engineering! Some comments:
Does ssh send pinAuth? For privacy reasons I think it's mandatory to check it. Looking at https://github.com/openssh/openssh-portable/blob/9b47bd7b09d191991ad9e0506bb66b74bbc93d34/ssh-sk.c#L61-L70 I assume ssh does send it, if not, then I think we should only respond to command Implementing credential deletion needs some changes to assumptions e.g. on |
Thanks for the review, comments inline:
The command id
Yes, let's implement this in another patch.
I was about to debug how pinAuth is computed and put the relevant checks in the code. Thanks for the hint!
Thanks, I will address this.
Yeah, I have been sloppy here, will fix this.
Correct.
Yes, it does send pinAuth, will add the checks.
We should also discuss changes in how RKs are stored that may break backward compatibility. For example right now we don't store |
Addressed some of the comments from @nickray
Next thing will be parsing and checking pinAuth. We have this for
|
de5496a
to
40801ad
Compare
Checking pinAuth is implemented. I have tested with both HIDG and real hardware and everything seems to work with OpenSSH :) @nickray We already have unsuccessful attempts count and device locking in |
From the point of view of the spec, there should be a persistent retries counter, with the properties:
So this behaviour is needed also for subcommands 0x01, 0x02, 0x04, 0x06 here. -- Not necessarily a todo for you, but I think we need more tests in https://github.com/solokeys/fido2-tests before we can merge this. |
OK, I will try to address this
|
I updated the PR to address last comment from @nickray |
} | ||
else | ||
{ | ||
ctap_reset_pin_attempts(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If an unsolicited CM_cmdRPNext
or CM_cmdRKNext
was sent, this would trigger the retries counter to get reset? Then there would be a way for malware to have unlimited PIN attempts. Ideally this should only done for commands that need pinAuth, and there should be a check that the "next" commands come after a valid command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I will rework the pinAuth handling and add tests for these scenarios.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have extracted the pinAuth handling into a separate function and introduced some flags to guard against calling Next commands without corresponding Begin. Tests are also updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is still vulnerable, but now if an invalid sub command is sent, it will reset the pin attempts. Maybe all of the attempt decrement + reset logic should be placed in the verify_pin_auth_ex
function to be safe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
verify_pin_auth_ex
is called by verify_pin_auth
so if I move the checks there it will have implications to the rest of the code.
I will change line 1299 to check if the command should have pinAuth and return if this is not the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, looks good!
03bde69
to
6e27f05
Compare
Implement command 0x41 which is used by OpenSSH for reading RKs. It has the following subcommands: * CMD_CRED_METADATA - get number of saved/remaining RKs * CMD_RP_BEGIN/CMD_RP_NEXT - iterate over the saved RPs * CMD_RK_BEGIN/CMD_RK_NEXT - iterate over the RKs for a given RP Fixes issue solokeys#374 and issue solokeys#314
This is awesome, thank you! I'm going to work on running against Microsoft tests, and adding the credProtect extensions. Will make an official update soon. |
Implement command 0x41 which is used by OpenSSH for reading RKs. It has
the following subcommands:
This fixes issue #374