Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/OPENSSH]: src/crypto/external/bsd/openssh/dist OpenSSH 8.2/8.2p1 (2020-0...



details:   https://anonhg.NetBSD.org/src/rev/85797100b9f9
branches:  OPENSSH
changeset: 745266:85797100b9f9
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Feb 27 00:21:35 2020 +0000

description:
OpenSSH 8.2/8.2p1 (2020-02-14)
OpenSSH 8.2 was released on 2020-02-14. It is available from the
mirrors listed at https://www.openssh.com/.

OpenSSH is a 100% complete SSH protocol 2.0 implementation and
includes sftp client and server support.

Once again, we would like to thank the OpenSSH community for their
continued support of the project, especially those who contributed
code or patches, reported bugs, tested snapshots or donated to the
project. More information on donations may be found at:
https://www.openssh.com/donations.html

Future deprecation notice
=========================

It is now possible[1] to perform chosen-prefix attacks against the
SHA-1 hash algorithm for less than USD$50K. For this reason, we will
be disabling the "ssh-rsa" public key signature algorithm that depends
on SHA-1 by default in a near-future release.

This algorithm is unfortunately still used widely despite the
existence of better alternatives, being the only remaining public key
signature algorithm specified by the original SSH RFCs.

The better alternatives include:

 * The RFC8332 RSA SHA-2 signature algorithms rsa-sha2-256/512. These
   algorithms have the advantage of using the same key type as
   "ssh-rsa" but use the safe SHA-2 hash algorithms. These have been
   supported since OpenSSH 7.2 and are already used by default if the
   client and server support them.

 * The ssh-ed25519 signature algorithm. It has been supported in
   OpenSSH since release 6.5.

 * The RFC5656 ECDSA algorithms: ecdsa-sha2-nistp256/384/521. These
   have been supported by OpenSSH since release 5.7.

To check whether a server is using the weak ssh-rsa public key
algorithm for host authentication, try to connect to it after
removing the ssh-rsa algorithm from ssh(1)'s allowed list:

    ssh -oHostKeyAlgorithms=-ssh-rsa user@host

If the host key verification fails and no other supported host key
types are available, the server software on that host should be
upgraded.

A future release of OpenSSH will enable UpdateHostKeys by default
to allow the client to automatically migrate to better algorithms.
Users may consider enabling this option manually.

[1] "SHA-1 is a Shambles: First Chosen-Prefix Collision on SHA-1 and
    Application to the PGP Web of Trust" Leurent, G and Peyrin, T
    (2020) https://eprint.iacr.org/2020/014.pdf

Security
========

 * ssh(1), sshd(8), ssh-keygen(1): this release removes the "ssh-rsa"
   (RSA/SHA1) algorithm from those accepted for certificate signatures
   (i.e. the client and server CASignatureAlgorithms option) and will
   use the rsa-sha2-512 signature algorithm by default when the
   ssh-keygen(1) CA signs new certificates.

   Certificates are at special risk to the aforementioned SHA1
   collision vulnerability as an attacker has effectively unlimited
   time in which to craft a collision that yields them a valid
   certificate, far more than the relatively brief LoginGraceTime
   window that they have to forge a host key signature.

   The OpenSSH certificate format includes a CA-specified (typically
   random) nonce value near the start of the certificate that should
   make exploitation of chosen-prefix collisions in this context
   challenging, as the attacker does not have full control over the
   prefix that actually gets signed. Nonetheless, SHA1 is now a
   demonstrably broken algorithm and futher improvements in attacks
   are highly likely.

   OpenSSH releases prior to 7.2 do not support the newer RSA/SHA2
   algorithms and will refuse to accept certificates signed by an
   OpenSSH 8.2+ CA using RSA keys unless the unsafe algorithm is
   explicitly selected during signing ("ssh-keygen -t ssh-rsa").
   Older clients/servers may use another CA key type such as
   ssh-ed25519 (supported since OpenSSH 6.5) or one of the
   ecdsa-sha2-nistp256/384/521 types (supported since OpenSSH 5.7)
   instead if they cannot be upgraded.

Potentially-incompatible changes
================================

This release includes a number of changes that may affect existing
configurations:

 * ssh(1), sshd(8): the above removal of "ssh-rsa" from the accepted
   CASignatureAlgorithms list.

 * ssh(1), sshd(8): this release removes diffie-hellman-group14-sha1
   from the default key exchange proposal for both the client and
   server.

 * ssh-keygen(1): the command-line options related to the generation
   and screening of safe prime numbers used by the
   diffie-hellman-group-exchange-* key exchange algorithms have
   changed. Most options have been folded under the -O flag.

 * sshd(8): the sshd listener process title visible to ps(1) has
   changed to include information about the number of connections that
   are currently attempting authentication and the limits configured
   by MaxStartups.

 * ssh-sk-helper(8): this is a new binary. It is used by the FIDO/U2F
   support to provide address-space isolation for token middleware
   libraries (including the internal one). It needs to be installed
   in the expected path, typically under /usr/libexec or similar.

Changes since OpenSSH 8.1
=========================

This release contains some significant new features.

FIDO/U2F Support
----------------

This release adds support for FIDO/U2F hardware authenticators to
OpenSSH. U2F/FIDO are open standards for inexpensive two-factor
authentication hardware that are widely used for website
authentication.  In OpenSSH FIDO devices are supported by new public
key types "ecdsa-sk" and "ed25519-sk", along with corresponding
certificate types.

ssh-keygen(1) may be used to generate a FIDO token-backed key, after
which they may be used much like any other key type supported by
OpenSSH, so long as the hardware token is attached when the keys are
used. FIDO tokens also generally require the user explicitly authorise
operations by touching or tapping them.

Generating a FIDO key requires the token be attached, and will usually
require the user tap the token to confirm the operation:

  $ ssh-keygen -t ecdsa-sk -f ~/.ssh/id_ecdsa_sk
  Generating public/private ecdsa-sk key pair.
  You may need to touch your security key to authorize key generation.
  Enter file in which to save the key (/home/djm/.ssh/id_ecdsa_sk):
  Enter passphrase (empty for no passphrase):
  Enter same passphrase again:
  Your identification has been saved in /home/djm/.ssh/id_ecdsa_sk
  Your public key has been saved in /home/djm/.ssh/id_ecdsa_sk.pub

This will yield a public and private key-pair. The private key file
should be useless to an attacker who does not have access to the
physical token. After generation, this key may be used like any other
supported key in OpenSSH and may be listed in authorized_keys, added
to ssh-agent(1), etc. The only additional stipulation is that the FIDO
token that the key belongs to must be attached when the key is used.

FIDO tokens are most commonly connected via USB but may be attached
via other means such as Bluetooth or NFC. In OpenSSH, communication
with the token is managed via a middleware library, specified by the
SecurityKeyProvider directive in ssh/sshd_config(5) or the
$SSH_SK_PROVIDER environment variable for ssh-keygen(1) and
ssh-add(1). The API for this middleware is documented in the sk-api.h
and PROTOCOL.u2f files in the source distribution.

OpenSSH includes a middleware ("SecurityKeyProvider=internal") with
support for USB tokens. It is automatically enabled in OpenBSD and may
be enabled in portable OpenSSH via the configure flag
--with-security-key-builtin. If the internal middleware is enabled
then it is automatically used by default. This internal middleware
requires that libfido2 (https://github.com/Yubico/libfido2) and its
dependencies be installed. We recommend that packagers of portable
OpenSSH enable the built-in middleware, as it provides the
lowest-friction experience for users.

Note: FIDO/U2F tokens are required to implement the ECDSA-P256
"ecdsa-sk" key type, but hardware support for Ed25519 "ed25519-sk" is
less common. Similarly, not all hardware tokens support some of the
optional features such as resident keys.

The protocol-level changes to support FIDO/U2F keys in SSH are
documented in the PROTOCOL.u2f file in the OpenSSH source
distribution.

There are a number of supporting changes to this feature:

 * ssh-keygen(1): add a "no-touch-required" option when generating
   FIDO-hosted keys, that disables their default behaviour of
   requiring a physical touch/tap on the token during authentication.
   Note: not all tokens support disabling the touch requirement.

 * sshd(8): add a sshd_config PubkeyAuthOptions directive that
   collects miscellaneous public key authentication-related options
   for sshd(8). At present it supports only a single option
   "no-touch-required". This causes sshd to skip its default check for
   FIDO/U2F keys that the signature was authorised by a touch or press
   event on the token hardware.

 * ssh(1), sshd(8), ssh-keygen(1): add a "no-touch-required" option
   for authorized_keys and a similar extension for certificates. This
   option disables the default requirement that FIDO key signatures
   attest that the user touched their key to authorize them, mirroring
   the similar PubkeyAuthOptions sshd_config option.

 * ssh-keygen(1): add support for the writing the FIDO attestation
   information that is returned when new keys are generated via the
   "-O write-attestation=/path" option. FIDO attestation certificates
   may be used to verify that a FIDO key is hosted in trusted
   hardware. OpenSSH does not currently make use of this information,
   beyond optionally writing it to disk.

FIDO2 resident keys
-------------------

FIDO/U2F OpenSSH keys consist of two parts: a "key handle" part stored
in the private key file on disk, and a per-device private key that is
unique to each FIDO/U2F token and that cannot be exported from the
token hardware. These are combined by the hardware at authentication
time to derive the real key that is used to sign authentication
challenges.

For tokens that are required to move between computers, it can be
cumbersome to have to move the private key file first. To avoid this
requirement, tokens implementing the newer FIDO2 standard support
"resident keys", where it is possible to effectively retrieve the key
handle part of the key from the hardware.

OpenSSH supports this feature, allowing resident keys to be generated
using the ssh-keygen(1) "-O resident" flag. This will produce a
public/private key pair as usual, but it will be possible to retrieve
the private key part from the token later. This may be done using
"ssh-keygen -K", which will download all available resident keys from
the tokens attached to the host and write public/private key files
for them. It is also possible to download and add resident keys
directly to ssh-agent(1) without writing files to the file-system
using "ssh-add -K".

Resident keys are indexed on the token by the application string and
user ID. By default, OpenSSH uses an application string of "ssh:" and
an empty user ID. If multiple resident keys on a single token are
desired then it may be necessary to override one or both of these
defaults using the ssh-keygen(1) "-O application=" or "-O user="
options. Note: OpenSSH will only download and use resident keys whose
application string begins with "ssh:"

Storing both parts of a key on a FIDO token increases the likelihood
of an attacker being able to use a stolen token device. For this
reason, tokens should enforce PIN authentication before allowing
download of keys, and users should set a PIN on their tokens before
creating any resident keys.

Other New Features
------------------

 * sshd(8): add an Include sshd_config keyword that allows including
   additional configuration files via glob(3) patterns. bz2468

 * ssh(1)/sshd(8): make the LE (low effort) DSCP code point available
   via the IPQoS directive; bz2986,

 * ssh(1): when AddKeysToAgent=yes is set and the key contains no
   comment, add the key to the agent with the key's path as the
   comment. bz2564

 * ssh-keygen(1), ssh-agent(1): expose PKCS#11 key labels and X.509
   subjects as key comments, rather than simply listing the PKCS#11
   provider library path. PR138

 * ssh-keygen(1): allow PEM export of DSA and ECDSA keys; bz3091

 * ssh(1), sshd(8): make zlib compile-time optional, available via the
   Makefile.inc ZLIB flag on OpenBSD or via the --with-zlib configure
   option for OpenSSH portable.

 * sshd(8): when clients get denied by MaxStartups, send a
   notification prior to the SSH2 protocol banner according to
   RFC4253 section 4.2.

 * ssh(1), ssh-agent(1): when invoking the $SSH_ASKPASS prompt
   program, pass a hint to the program to describe the type of
   desired prompt.  The possible values are "confirm" (indicating
   that a yes/no confirmation dialog with no text entry should be
   shown), "none" (to indicate an informational message only), or
   blank for the original ssh-askpass behaviour of requesting a
   password/phrase.

 * ssh(1): allow forwarding a different agent socket to the path
   specified by $SSH_AUTH_SOCK, by extending the existing ForwardAgent
   option to accepting an explicit path or the name of an environment
   variable in addition to yes/no.

 * ssh-keygen(1): add a new signature operations "find-principals" to
   look up the principal associated with a signature from an allowed-
   signers file.

 * sshd(8): expose the number of currently-authenticating connections
   along with the MaxStartups limit in the process title visible to
   "ps".

Bugfixes
--------

 * sshd(8): make ClientAliveCountMax=0 have sensible semantics: it
   will now disable connection killing entirely rather than the
   current behaviour of instantly killing the connection after the
   first liveness test regardless of success. bz2627

 * sshd(8): clarify order of AllowUsers / DenyUsers vs AllowGroups /
   DenyGroups in the sshd(8) manual page. bz1690

 * sshd(8): better describe HashKnownHosts in the manual page. bz2560

 * sshd(8): clarify that that permitopen=/PermitOpen do no name or
   address translation in the manual page. bz3099

 * sshd(8): allow the UpdateHostKeys feature to function when
   multiple known_hosts files are in use. When updating host keys,
   ssh will now search subsequent known_hosts files, but will add
   updated host keys to the first specified file only. bz2738

 * All: replace all calls to signal(2) with a wrapper around
   sigaction(2). This wrapper blocks all other signals during the
   handler preventing races between handlers, and sets SA_RESTART
   which should reduce the potential for short read/write operations.

 * sftp(1): fix a race condition in the SIGCHILD handler that could
   turn in to a kill(-1); bz3084

 * sshd(8): fix a case where valid (but extremely large) SSH channel
   IDs were being incorrectly rejected. bz3098

 * ssh(1): when checking host key fingerprints as answers to new
   hostkey prompts, ignore whitespace surrounding the fingerprint
   itself.

 * All: wait for file descriptors to be readable or writeable during
   non-blocking connect, not just readable. Prevents a timeout when
   the server doesn't immediately send a banner (e.g. multiplexers
   like sslh)

 * sshd_config(5): document the sntrup4591761x25519-sha512%tinyssh.org@localhost
   key exchange algorithm. PR#151

diffstat:

 crypto/external/bsd/openssh/dist/PROTOCOL.certkeys      |     9 +-
 crypto/external/bsd/openssh/dist/PROTOCOL.u2f           |   337 ++++
 crypto/external/bsd/openssh/dist/auth-options.c         |    38 +-
 crypto/external/bsd/openssh/dist/auth-options.h         |     5 +-
 crypto/external/bsd/openssh/dist/auth.c                 |    26 +-
 crypto/external/bsd/openssh/dist/auth2-chall.c          |     3 +-
 crypto/external/bsd/openssh/dist/auth2-hostbased.c      |     4 +-
 crypto/external/bsd/openssh/dist/auth2-kbdint.c         |     3 +-
 crypto/external/bsd/openssh/dist/auth2-pubkey.c         |    39 +-
 crypto/external/bsd/openssh/dist/authfd.c               |    62 +-
 crypto/external/bsd/openssh/dist/authfd.h               |     7 +-
 crypto/external/bsd/openssh/dist/authfile.c             |   108 +-
 crypto/external/bsd/openssh/dist/authfile.h             |     5 +-
 crypto/external/bsd/openssh/dist/channels.c             |     9 +-
 crypto/external/bsd/openssh/dist/channels.h             |    10 +-
 crypto/external/bsd/openssh/dist/cipher.c               |    13 +-
 crypto/external/bsd/openssh/dist/cipher.h               |     3 +-
 crypto/external/bsd/openssh/dist/clientloop.c           |   136 +-
 crypto/external/bsd/openssh/dist/hash.c                 |    30 +-
 crypto/external/bsd/openssh/dist/hostfile.c             |     3 +-
 crypto/external/bsd/openssh/dist/kex.c                  |     7 +-
 crypto/external/bsd/openssh/dist/kexgen.c               |     4 +-
 crypto/external/bsd/openssh/dist/kexgexc.c              |     4 +-
 crypto/external/bsd/openssh/dist/krl.c                  |    20 +-
 crypto/external/bsd/openssh/dist/match.c                |     3 +-
 crypto/external/bsd/openssh/dist/misc.c                 |    67 +-
 crypto/external/bsd/openssh/dist/misc.h                 |    11 +-
 crypto/external/bsd/openssh/dist/moduli-gen/moduli.2048 |   161 +-
 crypto/external/bsd/openssh/dist/moduli-gen/moduli.3072 |   149 +-
 crypto/external/bsd/openssh/dist/moduli-gen/moduli.4096 |   132 +-
 crypto/external/bsd/openssh/dist/moduli-gen/moduli.6144 |   140 +-
 crypto/external/bsd/openssh/dist/moduli-gen/moduli.7680 |   142 +-
 crypto/external/bsd/openssh/dist/moduli-gen/moduli.8192 |   130 +-
 crypto/external/bsd/openssh/dist/moduli.c               |    12 +-
 crypto/external/bsd/openssh/dist/monitor.c              |    90 +-
 crypto/external/bsd/openssh/dist/monitor_wrap.c         |    28 +-
 crypto/external/bsd/openssh/dist/monitor_wrap.h         |     7 +-
 crypto/external/bsd/openssh/dist/msg.c                  |    14 +-
 crypto/external/bsd/openssh/dist/mux.c                  |    22 +-
 crypto/external/bsd/openssh/dist/myproposal.h           |    47 +-
 crypto/external/bsd/openssh/dist/packet.c               |    45 +-
 crypto/external/bsd/openssh/dist/pathnames.h            |     9 +-
 crypto/external/bsd/openssh/dist/progressmeter.c        |     8 +-
 crypto/external/bsd/openssh/dist/readconf.c             |   154 +-
 crypto/external/bsd/openssh/dist/readconf.h             |     5 +-
 crypto/external/bsd/openssh/dist/readpass.c             |   119 +-
 crypto/external/bsd/openssh/dist/scp.1                  |     6 +-
 crypto/external/bsd/openssh/dist/scp.c                  |    22 +-
 crypto/external/bsd/openssh/dist/servconf.c             |   268 +++-
 crypto/external/bsd/openssh/dist/servconf.h             |    25 +-
 crypto/external/bsd/openssh/dist/serverloop.c           |    26 +-
 crypto/external/bsd/openssh/dist/session.c              |     5 +-
 crypto/external/bsd/openssh/dist/sftp-glob.c            |     3 +-
 crypto/external/bsd/openssh/dist/sftp-server.8          |     6 +-
 crypto/external/bsd/openssh/dist/sftp.1                 |     6 +-
 crypto/external/bsd/openssh/dist/sftp.c                 |    35 +-
 crypto/external/bsd/openssh/dist/sk-api.h               |    93 +
 crypto/external/bsd/openssh/dist/sk-usbhid.c            |  1019 +++++++++++++++
 crypto/external/bsd/openssh/dist/ssh-add.1              |    33 +-
 crypto/external/bsd/openssh/dist/ssh-add.c              |   141 +-
 crypto/external/bsd/openssh/dist/ssh-agent.1            |   170 +-
 crypto/external/bsd/openssh/dist/ssh-agent.c            |   151 +-
 crypto/external/bsd/openssh/dist/ssh-ecdsa-sk.c         |   199 ++
 crypto/external/bsd/openssh/dist/ssh-ed25519-sk.c       |   164 ++
 crypto/external/bsd/openssh/dist/ssh-keygen.1           |   895 +++++++-----
 crypto/external/bsd/openssh/dist/ssh-keygen.c           |   835 ++++++++---
 crypto/external/bsd/openssh/dist/ssh-keyscan.1          |     6 +-
 crypto/external/bsd/openssh/dist/ssh-keyscan.c          |    24 +-
 crypto/external/bsd/openssh/dist/ssh-keysign.8          |     6 +-
 crypto/external/bsd/openssh/dist/ssh-keysign.c          |     7 +-
 crypto/external/bsd/openssh/dist/ssh-pkcs11-client.c    |    14 +-
 crypto/external/bsd/openssh/dist/ssh-pkcs11-helper.8    |     6 +-
 crypto/external/bsd/openssh/dist/ssh-pkcs11-helper.c    |    21 +-
 crypto/external/bsd/openssh/dist/ssh-pkcs11.c           |   142 +-
 crypto/external/bsd/openssh/dist/ssh-pkcs11.h           |     4 +-
 crypto/external/bsd/openssh/dist/ssh-sk-client.c        |   439 ++++++
 crypto/external/bsd/openssh/dist/ssh-sk-helper.8        |    66 +
 crypto/external/bsd/openssh/dist/ssh-sk-helper.c        |   347 +++++
 crypto/external/bsd/openssh/dist/ssh-sk-helper/Makefile |    20 +
 crypto/external/bsd/openssh/dist/ssh-sk.c               |   802 +++++++++++
 crypto/external/bsd/openssh/dist/ssh-sk.h               |    69 +
 crypto/external/bsd/openssh/dist/ssh.1                  |    36 +-
 crypto/external/bsd/openssh/dist/ssh.c                  |   119 +-
 crypto/external/bsd/openssh/dist/ssh_api.c              |     9 +-
 crypto/external/bsd/openssh/dist/ssh_config.5           |   101 +-
 crypto/external/bsd/openssh/dist/sshbuf-getput-basic.c  |     5 +-
 crypto/external/bsd/openssh/dist/sshbuf-getput-crypto.c |    12 +-
 crypto/external/bsd/openssh/dist/sshbuf-io.c            |   115 +
 crypto/external/bsd/openssh/dist/sshbuf-misc.c          |     2 +-
 crypto/external/bsd/openssh/dist/sshbuf.c               |     4 +-
 crypto/external/bsd/openssh/dist/sshbuf.h               |    18 +-
 crypto/external/bsd/openssh/dist/sshconnect.c           |    37 +-
 crypto/external/bsd/openssh/dist/sshconnect.h           |     5 +-
 crypto/external/bsd/openssh/dist/sshconnect2.c          |   171 +-
 crypto/external/bsd/openssh/dist/sshd.8                 |    64 +-
 crypto/external/bsd/openssh/dist/sshd.c                 |   160 +-
 crypto/external/bsd/openssh/dist/sshd_config.5          |   121 +-
 crypto/external/bsd/openssh/dist/ssherr.c               |     6 +-
 crypto/external/bsd/openssh/dist/ssherr.h               |     4 +-
 crypto/external/bsd/openssh/dist/sshkey-xmss.c          |    80 +-
 crypto/external/bsd/openssh/dist/sshkey.c               |   505 ++++++-
 crypto/external/bsd/openssh/dist/sshkey.h               |    53 +-
 crypto/external/bsd/openssh/dist/sshsig.c               |   354 ++++-
 crypto/external/bsd/openssh/dist/sshsig.h               |    26 +-
 crypto/external/bsd/openssh/dist/umac.c                 |     3 +-
 crypto/external/bsd/openssh/dist/version.h              |     4 +-
 crypto/external/bsd/openssh/dist/xmalloc.c              |    21 +-
 crypto/external/bsd/openssh/dist/xmalloc.h              |     4 +-
 108 files changed, 8288 insertions(+), 2206 deletions(-)

diffs (truncated from 16453 to 300 lines):

diff -r 8008c462b9fa -r 85797100b9f9 crypto/external/bsd/openssh/dist/PROTOCOL.certkeys
--- a/crypto/external/bsd/openssh/dist/PROTOCOL.certkeys        Sat Oct 12 15:13:53 2019 +0000
+++ b/crypto/external/bsd/openssh/dist/PROTOCOL.certkeys        Thu Feb 27 00:21:35 2020 +0000
@@ -280,6 +280,13 @@
 
 Name                    Format        Description
 -----------------------------------------------------------------------------
+no-presence-required    empty         Flag indicating that signatures made
+                                      with this certificate need not assert
+                                      user presence. This option only make
+                                      sense for the U2F/FIDO security key
+                                      types that support this feature in
+                                      their signature formats.
+
 permit-X11-forwarding   empty         Flag indicating that X11 forwarding
                                       should be permitted. X11 forwarding will
                                       be refused if this option is absent.
@@ -304,4 +311,4 @@
                                       of this script will not be permitted if
                                       this option is not present.
 
-$OpenBSD: PROTOCOL.certkeys,v 1.16 2018/10/26 01:23:03 djm Exp $
+$OpenBSD: PROTOCOL.certkeys,v 1.17 2019/11/25 00:57:51 djm Exp $
diff -r 8008c462b9fa -r 85797100b9f9 crypto/external/bsd/openssh/dist/PROTOCOL.u2f
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/crypto/external/bsd/openssh/dist/PROTOCOL.u2f     Thu Feb 27 00:21:35 2020 +0000
@@ -0,0 +1,337 @@
+This document describes OpenSSH's support for U2F/FIDO security keys.
+
+Background
+----------
+
+U2F is an open standard for two-factor authentication hardware, widely
+used for user authentication to websites. U2F tokens are ubiquitous,
+available from a number of manufacturers and are currently by far the
+cheapest way for users to achieve hardware-backed credential storage.
+
+The U2F protocol however cannot be trivially used as an SSH protocol key
+type as both the inputs to the signature operation and the resultant
+signature differ from those specified for SSH. For similar reasons,
+integration of U2F devices cannot be achieved via the PKCS#11 API.
+
+U2F also offers a number of features that are attractive in the context
+of SSH authentication. They can be configured to require indication
+of "user presence" for each signature operation (typically achieved
+by requiring the user touch the key). They also offer an attestation
+mechanism at key enrollment time that can be used to prove that a
+given key is backed by hardware. Finally the signature format includes
+a monotonic signature counter that can be used (at scale) to detect
+concurrent use of a private key, should it be extracted from hardware.
+
+U2F private keys are generated through an enrollment operation,
+which takes an application ID - a URL-like string, typically "ssh:"
+in this case, but a HTTP origin for the case of web authentication,
+and a challenge string (typically randomly generated). The enrollment
+operation returns a public key, a key handle that must be used to invoke
+the hardware-backed private key, some flags and signed attestation
+information that may be used to verify that a private key is hosted on a
+particular hardware instance.
+
+It is common for U2F hardware to derive private keys from the key handle
+in conjunction with a small per-device secret that is unique to the
+hardware, thus requiring little on-device storage for an effectively
+unlimited number of supported keys. This drives the requirement that
+the key handle be supplied for each signature operation. U2F tokens
+primarily use ECDSA signatures in the NIST-P256 field, though the FIDO2
+standard specifies additional key types, including one based on Ed25519.
+
+SSH U2F Key formats
+-------------------
+
+OpenSSH integrates U2F as new key and corresponding certificate types:
+
+       sk-ecdsa-sha2-nistp256%openssh.com@localhost
+       sk-ecdsa-sha2-nistp256-cert-v01%openssh.com@localhost
+       sk-ssh-ed25519%openssh.com@localhost
+       sk-ssh-ed25519-cert-v01%openssh.com@localhost
+
+While each uses ecdsa-sha256-nistp256 as the underlying signature primitive,
+keys require extra information in the public and private keys, and in
+the signature object itself. As such they cannot be made compatible with
+the existing ecdsa-sha2-nistp* key types.
+
+The format of a sk-ecdsa-sha2-nistp256%openssh.com@localhost public key is:
+
+       string          "sk-ecdsa-sha2-nistp256%openssh.com@localhost"
+       string          curve name
+       ec_point        Q
+       string          application (user-specified, but typically "ssh:")
+
+The corresponding private key contains:
+
+       string          "sk-ecdsa-sha2-nistp256%openssh.com@localhost"
+       string          curve name
+       ec_point        Q
+       string          application (user-specified, but typically "ssh:")
+       uint8           flags
+       string          key_handle
+       string          reserved
+
+The format of a sk-ssh-ed25519%openssh.com@localhost public key is:
+
+       string          "sk-ssh-ed25519%openssh.com@localhost"
+       string          public key
+       string          application (user-specified, but typically "ssh:")
+
+With a private half consisting of:
+
+       string          "sk-ssh-ed25519%openssh.com@localhost"
+       string          public key
+       string          application (user-specified, but typically "ssh:")
+       uint8           flags
+       string          key_handle
+       string          reserved
+
+The certificate form for SSH U2F keys appends the usual certificate
+information to the public key:
+
+       string          "sk-ecdsa-sha2-nistp256-cert-v01%openssh.com@localhost"
+       string          nonce
+       string          curve name
+       ec_point        Q
+       string          application
+       uint64          serial
+       uint32          type
+       string          key id
+       string          valid principals
+       uint64          valid after
+       uint64          valid before
+       string          critical options
+       string          extensions
+       string          reserved
+       string          signature key
+       string          signature
+
+and for security key ed25519 certificates:
+
+       string          "sk-ssh-ed25519-cert-v01%openssh.com@localhost"
+       string          nonce
+       string          public key
+       string          application
+       uint64          serial
+       uint32          type
+       string          key id
+       string          valid principals
+       uint64          valid after
+       uint64          valid before
+       string          critical options
+       string          extensions
+       string          reserved
+       string          signature key
+       string          signature
+
+Both security key certificates use the following encoding for private keys:
+
+       string          type (e.g. "sk-ssh-ed25519-cert-v01%openssh.com@localhost")
+       string          pubkey (the above key/cert structure)
+       string          application
+       uint8           flags
+       string          key_handle
+       string          reserved
+
+During key generation, the hardware also returns attestation information
+that may be used to cryptographically prove that a given key is
+hardware-backed. Unfortunately, the protocol required for this proof is
+not privacy-preserving and may be used to identify U2F tokens with at
+least manufacturer and batch number granularity. For this reason, we
+choose not to include this information in the public key or save it by
+default.
+
+Attestation information is useful for out-of-band key and certificate
+registration worksflows, e.g. proving to a CA that a key is backed
+by trusted hardware before it will issue a certificate. To support this
+case, OpenSSH optionally allows retaining the attestation information
+at the time of key generation. It will take the following format:
+
+       string          "ssh-sk-attest-v00"
+       string          attestation certificate
+       string          enrollment signature
+       uint32          reserved flags
+       string          reserved string
+
+OpenSSH treats the attestation certificate and enrollment signatures as
+opaque objects and does no interpretation of them itself.
+
+SSH U2F signatures
+------------------
+
+In addition to the message to be signed, the U2F signature operation
+requires the key handle and a few additional parameters. The signature
+is signed over a blob that consists of:
+
+       byte[32]        SHA256(application)
+       byte            flags (including "user present", extensions present)
+       uint32          counter
+       byte[]          extensions
+       byte[32]        SHA256(message)
+
+No extensons are yet defined for SSH use. If any are defined in the future,
+it will be possible to infer their presence from the contents of the "flags"
+value.
+
+The signature returned from U2F hardware takes the following format:
+
+       byte            flags (including "user present")
+       uint32          counter
+       byte[]          ecdsa_signature (in X9.62 format).
+
+For use in the SSH protocol, we wish to avoid server-side parsing of ASN.1
+format data in the pre-authentication attack surface. Therefore, the
+signature format used on the wire in SSH2_USERAUTH_REQUEST packets will
+be reformatted to better match the existing signature encoding:
+
+       string          "sk-ecdsa-sha2-nistp256%openssh.com@localhost"
+       string          ecdsa_signature
+       byte            flags
+       uint32          counter
+
+Where the "ecdsa_signature" field follows the RFC5656 ECDSA signature
+encoding:
+
+       mpint           r
+       mpint           s
+
+For Ed25519 keys the signature is encoded as:
+
+       string          "sk-ssh-ed25519%openssh.com@localhost"
+       string          signature
+       byte            flags
+       uint32          counter
+
+ssh-agent protocol extensions
+-----------------------------
+
+ssh-agent requires a protocol extension to support U2F keys. At
+present the closest analogue to Security Keys in ssh-agent are PKCS#11
+tokens, insofar as they require a middleware library to communicate with
+the device that holds the keys. Unfortunately, the protocol message used
+to add PKCS#11 keys to ssh-agent does not include any way to send the
+key handle to the agent as U2F keys require.
+
+To avoid this, without having to add wholly new messages to the agent
+protocol, we will use the existing SSH2_AGENTC_ADD_ID_CONSTRAINED message
+with a new key constraint extension to encode a path to the middleware
+library for the key. The format of this constraint extension would be:
+
+       byte            SSH_AGENT_CONSTRAIN_EXTENSION
+       string          sk-provider%openssh.com@localhost
+       string          middleware path
+
+This constraint-based approach does not present any compatibility
+problems.
+
+OpenSSH integration
+-------------------
+
+U2F tokens may be attached via a number of means, including USB and NFC.
+The USB interface is standardised around a HID protocol, but we want to
+be able to support other transports as well as dummy implementations for
+regress testing. For this reason, OpenSSH shall support a dynamically-
+loaded middleware libraries to communicate with security keys, but offer
+support for the common case of USB HID security keys internally.
+
+The middleware library need only expose a handful of functions:
+
+       #define SSH_SK_VERSION_MAJOR            0x00040000 /* API version */
+       #define SSH_SK_VERSION_MAJOR_MASK       0xffff0000
+
+       /* Flags */
+       #define SSH_SK_USER_PRESENCE_REQD       0x01
+       #define SSH_SK_USER_VERIFICATION_REQD   0x04
+       #define SSH_SK_RESIDENT_KEY             0x20
+
+       /* Algs */
+       #define SSH_SK_ECDSA                   0x00
+       #define SSH_SK_ED25519                 0x01
+
+       /* Error codes */
+       #define SSH_SK_ERR_GENERAL              -1
+       #define SSH_SK_ERR_UNSUPPORTED          -2
+       #define SSH_SK_ERR_PIN_REQUIRED         -3
+       #define SSH_SK_ERR_DEVICE_NOT_FOUND     -4
+
+       struct sk_enroll_response {
+               uint8_t *public_key;
+               size_t public_key_len;
+               uint8_t *key_handle;
+               size_t key_handle_len;
+               uint8_t *signature;
+               size_t signature_len;
+               uint8_t *attestation_cert;
+               size_t attestation_cert_len;
+       };
+
+       struct sk_sign_response {
+               uint8_t flags;
+               uint32_t counter;
+               uint8_t *sig_r;
+               size_t sig_r_len;
+               uint8_t *sig_s;



Home | Main Index | Thread Index | Old Index