-
Notifications
You must be signed in to change notification settings - Fork 83
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
Adds OpenPubkey Support to SSH3 #146
Open
EthanHeilman
wants to merge
39
commits into
francoismichel:main
Choose a base branch
from
EthanHeilman:opkssh3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…th from the base client
EthanHeilman
changed the title
Adds OpenPubkey Support to SSH3 [WIP]
Adds OpenPubkey Support to SSH3
Aug 21, 2024
EthanHeilman
force-pushed
the
opkssh3
branch
2 times, most recently
from
September 9, 2024 21:36
45e85a4
to
a76534c
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds an OpenPubkey authentication plugin to SSH3. OpenPubkey is a protocol that adds user held public keys to OpenID Connect (OIDC) while maintaining compatibility with existing OpenID Providers.
This provides a number of improvements to SSH3 over the current OIDC authentication in SSH3:
Prevents replay attacks by signing TLS export materials: SSH3 OIDC authentication ID Tokens sent to one SSH3 server can be replayed by that server to authenticate that as that user to SSH3 servers. With OpenPubkey the ID Token (PK Token) is simply used as certificate, the SSH3 client can sign the export materials of the TLS session under the user's public key as specified in the PK Token removing the risk of replay attacks during OIDC authentication.
Prevents MITM attacks via signature based authentication of the user: In SSH3 OIDC authentication, if the SSH3 server uses a self-signed certificate, an attacker can MITM the TLS session pretending to be the server, learn the user's ID Token and then send that to the real SSH3 server. This not only allows such an attacker to read and tamper with the communications between the SSH3 client and the SSH3 server, but also by learning the ID Token, the attacker can perform the replay attack above. With OpenPubkey this is not possible, but the MITM attacker can be impersonate the user to the SSH3 server.
One way to think about the security offered by the SS3 OpenPubkey auth plugin is that it gets to the security offered by the SSH3 public key plugin, but with OpenID Connect.
Support for this OpenPubkey in SSH3 would allow SSH3 to leverage OpenPubkey's MFA (webauthn) feature in SSH3. This feature is out of scope for this PR.
This feature in OpenPubkey is being tracked as: openpubkey/openpubkey#202
Demo
Short video of using OpenPubkey as an authentication plugin for SSH3
Screen.Recording.2024-08-20.at.8.43.22.PM.mov
~/.ssh3/authorized_identities
on the remote serverThe local command to run openpubkey auth on SSH3
How it works
Our design for the OpenPubkey auth plugin uses the pattern established by SSH3's public key auth. The SSH3 client generates a JWT which attests to the TLS export materials of the current TLS session, it signs this JWT under the user's public key and then puts the JWT in the HTTP Authorization header. In OpenPubkey the public key is the public key in the PK Token (ID Token with additional metadata).
More specifically:
authorization=Compact(SSH3-JWT)#Compact(PK Token)
.JWT format used by OpenPubkey auth plugin
This is the same format as used by SSH3 pubkey auth. For the username
Alice
the JWT format is:Rationale for distinguishing between OpenPubkey and OIDC in Authorized Identities
SSH3 uses an
authorized_identities
file to configure policy for which identities defined in OpenID Connect are allowed to connect to the remote server.To distinguish OpenPubkey identities from OpenIDConnect identities we set
openpubkey
as the first part of an authorized identity rather thanoidc
. This distinction is important to security as OpenPubkey PK Tokens contain OpenID Connect ID Tokens. Thus, if a SSH3 server was configured to accept either OpenPubkey PK Tokens or OpenID Connect ID Tokens, we would lose the security advantages offered by OpenPubkey as the ID Token in the PK Token could simply be replayed as standard OpenID Connect ID Token.Consider an attacker Eve who learned the PK Token of
anon.author.aardvark
This
authorized_identities
would not protect against replay attacks because Eve could take the ID Token contained inanon.author.aardvark
PK Token as an OpenID Connect authentication value.This
authorized_identities
protects against replay attacks because Eve couldn't use the ID Token contained inanon.author.aardvark
PK Token as an OpenID Connect authentication value since the audiences don't match: audienceA !=audienceB. The same would be true if the issuers didn't match or the email addresses didn't match.This
authorized_identities
prevents the attacker because it will reject OpenID Connect authentication. Only using This is the most secure configuration.If for compatibility purposes OpenPubkey and OpenID Connect are used for the same audience, issuer and user, the downside is simply that OpenPubkey's security degrades to security of OpenID Connect.
GQ/ZK Signatures
If OpenPubkey GQ or ZK Signatures are used then the above replay attacks are completely eliminated. In this case there would not be a benefit to distinguishing between OpenID Connect and OpenPubkey in authorized identities. I am avoiding using GQ or ZK signatures in SSH3 because I want to keep the implementation simple. It may be worth rethinking that decision when deciding on the final format of authorized_identities.