[openssh-commits] [openssh] 16/18: upstream: check certificate critical options when verifying
git+noreply at mindrot.org
git+noreply at mindrot.org
Wed Nov 25 19:56:11 AEDT 2026
This is an automated email from the git hooks/post-receive script.
djm pushed a commit to branch master
in repository openssh.
commit 0d69a4cbd147b96e838e6cd46f455e46f38ca442
Author: djm at openbsd.org <djm at openbsd.org>
AuthorDate: Wed Nov 25 08:48:52 2026 +0000
upstream: check certificate critical options when verifying
sshsig signatures.
Only a single critical option is supported "verify-required" which
required FIDO signatures to assert that the user was verified (e.g.
PIN or biometric). Add support for checking this too.
Anthropic ANT-2026-J7HFTTZ6
OpenBSD-Commit-ID: 8e4097c70f98fef11c2736d2e41664ca9a1923e2
---
ssh-keygen.1 | 7 ++++--
ssh-keygen.c | 5 +++--
sshsig.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
sshsig.h | 8 ++++---
4 files changed, 81 insertions(+), 12 deletions(-)
diff --git a/ssh-keygen.1 b/ssh-keygen.1
index be69bf08a..13ee7be51 100644
--- a/ssh-keygen.1
+++ b/ssh-keygen.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ssh-keygen.1,v 1.244 2026/10/30 03:47:56 djm Exp $
+.\" $OpenBSD: ssh-keygen.1,v 1.245 2026/11/25 08:48:52 djm Exp $
.\"
.\" Author: Tatu Ylonen <ylo at cs.hut.fi>
.\" Copyright (c) 1995 Tatu Ylonen <ylo at cs.hut.fi>, Espoo, Finland
@@ -35,7 +35,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd $Mdocdate: October 30 2026 $
+.Dd $Mdocdate: November 25 2026 $
.Dt SSH-KEYGEN 1
.Os
.Sh NAME
@@ -1318,6 +1318,9 @@ Indicates that the key is valid for use at or before the specified timestamp.
When verifying signatures made by certificates, the expected principal
name must match both the principals pattern in the allowed signers file and
the principals embedded in the certificate itself.
+Certificates that contain critical options other than
+.Cm verify-required
+are refused, as are signatures that do not satisfy that option.
.Pp
An example allowed signers file:
.Bd -literal -offset 3n
diff --git a/ssh-keygen.c b/ssh-keygen.c
index ad4f1323c..3008b0321 100644
--- a/ssh-keygen.c
+++ b/ssh-keygen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-keygen.c,v 1.501 2026/11/25 06:29:41 djm Exp $ */
+/* $OpenBSD: ssh-keygen.c,v 1.502 2026/11/25 08:48:52 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo at cs.hut.fi>
* Copyright (c) 1994 Tatu Ylonen <ylo at cs.hut.fi>, Espoo, Finland
@@ -2951,7 +2951,8 @@ sig_verify(const char *signature, const char *sig_namespace,
}
if (allowed_keys != NULL && (r = sshsig_check_allowed_keys(allowed_keys,
- sign_key, principal, sig_namespace, verify_time)) != 0) {
+ sign_key, principal, sig_namespace, verify_time,
+ sig_details)) != 0) {
debug3_fr(r, "sshsig_check_allowed_keys");
goto done;
}
diff --git a/sshsig.c b/sshsig.c
index 2b64a1f1c..e0f27ba3e 100644
--- a/sshsig.c
+++ b/sshsig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sshsig.c,v 1.42 2026/10/30 02:18:03 djm Exp $ */
+/* $OpenBSD: sshsig.c,v 1.43 2026/11/25 08:48:52 djm Exp $ */
/*
* Copyright (c) 2019 Google LLC
*
@@ -35,6 +35,7 @@
#include "match.h"
#include "digest.h"
#include "myproposal.h"
+#include "sk-api.h"
#define SIG_VERSION 0x01
#define MAGIC_PREAMBLE "SSHSIG"
@@ -892,10 +893,65 @@ cert_filter_principals(const char *path, u_long linenum,
return success ? 0 : r;
}
+/*
+ * Check the critical options of a certificate used for signing. The only
+ * critical option that is meaningful here is "verify-required", which is
+ * enforced against the signature details (if any); a certificate that
+ * carries any other critical option is refused, as sshd(8) does for unknown
+ * critical options.
+ */
+static int
+cert_check_critical_options(const struct sshkey *cert,
+ const struct sshkey_sig_details *sig_details, const char **reason)
+{
+ struct sshbuf *c = NULL;
+ char *name = NULL;
+ size_t len;
+ int r = SSH_ERR_INTERNAL_ERROR;
+
+ if ((c = sshbuf_fromb(cert->cert->critical)) == NULL) {
+ *reason = "Certificate critical options allocation failed";
+ return SSH_ERR_ALLOC_FAIL;
+ }
+ while (sshbuf_len(c) > 0) {
+ free(name);
+ name = NULL;
+ if ((r = sshbuf_get_cstring(c, &name, NULL)) != 0 ||
+ (r = sshbuf_get_string_direct(c, NULL, &len)) != 0) {
+ *reason = "Certificate critical options corrupt";
+ goto out;
+ }
+ if (strcmp(name, "verify-required") != 0 || len != 0) {
+ *reason = "Certificate contains unsupported "
+ "critical options";
+ r = SSH_ERR_KEY_CERT_INVALID;
+ goto out;
+ }
+ /*
+ * sig_details is only present for FIDO signatures that
+ * have been verified; find-principals doesn't have them.
+ */
+ if (sig_details != NULL && (sig_details->sk_flags &
+ SSH_SK_USER_VERIFICATION_REQD) == 0) {
+ *reason = "Certificate user verification "
+ "requirement not met";
+ r = SSH_ERR_KEY_CERT_INVALID;
+ goto out;
+ }
+ }
+ /* success */
+ r = 0;
+ out:
+ free(name);
+ sshbuf_free(c);
+ return r;
+}
+
static int
check_allowed_keys_line(const char *path, u_long linenum, char *line,
const struct sshkey *sign_key, const char *principal,
- const char *sig_namespace, uint64_t verify_time, char **principalsp)
+ const char *sig_namespace, uint64_t verify_time,
+ const struct sshkey_sig_details *sig_details, char **principalsp)
{
struct sshkey *found_key = NULL;
char *principals = NULL;
@@ -927,6 +983,12 @@ check_allowed_keys_line(const char *path, u_long linenum, char *line,
sign_key->cert->signature_type);
goto done;
}
+ if ((r = cert_check_critical_options(sign_key, sig_details,
+ &reason)) != 0) {
+ error("%s:%lu: certificate not authorized: %s",
+ path, linenum, reason);
+ goto done;
+ }
if (principal) {
/* Match certificate CA key with specified principal */
if ((r = sshkey_cert_check_authority(sign_key, 0, 0,
@@ -997,7 +1059,8 @@ check_allowed_keys_line(const char *path, u_long linenum, char *line,
int
sshsig_check_allowed_keys(const char *path, const struct sshkey *sign_key,
- const char *principal, const char *sig_namespace, uint64_t verify_time)
+ const char *principal, const char *sig_namespace, uint64_t verify_time,
+ const struct sshkey_sig_details *sig_details)
{
FILE *f = NULL;
char *line = NULL;
@@ -1017,7 +1080,7 @@ sshsig_check_allowed_keys(const char *path, const struct sshkey *sign_key,
while (getline(&line, &linesize, f) != -1) {
linenum++;
r = check_allowed_keys_line(path, linenum, line, sign_key,
- principal, sig_namespace, verify_time, NULL);
+ principal, sig_namespace, verify_time, sig_details, NULL);
free(line);
line = NULL;
linesize = 0;
@@ -1057,7 +1120,7 @@ sshsig_find_principals(const char *path, const struct sshkey *sign_key,
while (getline(&line, &linesize, f) != -1) {
linenum++;
r = check_allowed_keys_line(path, linenum, line,
- sign_key, NULL, NULL, verify_time, principals);
+ sign_key, NULL, NULL, verify_time, NULL, principals);
free(line);
line = NULL;
linesize = 0;
diff --git a/sshsig.h b/sshsig.h
index ac5577962..e78b5e31d 100644
--- a/sshsig.h
+++ b/sshsig.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sshsig.h,v 1.11 2021/11/27 07:14:46 djm Exp $ */
+/* $OpenBSD: sshsig.h,v 1.12 2026/11/25 08:48:52 djm Exp $ */
/*
* Copyright (c) 2019 Google LLC
*
@@ -83,10 +83,12 @@ int sshsig_dearmor(struct sshbuf *sig, struct sshbuf **out);
/*
* Checks whether a particular key/principal/namespace is permitted by
- * an allowed_keys file. Returns 0 on success.
+ * an allowed_keys file. sig_details are those returned when the signature
+ * was verified, or NULL if not available. Returns 0 on success.
*/
int sshsig_check_allowed_keys(const char *path, const struct sshkey *sign_key,
- const char *principal, const char *ns, uint64_t verify_time);
+ const char *principal, const char *ns, uint64_t verify_time,
+ const struct sshkey_sig_details *sig_details);
/* Parse zero or more allowed_keys signature options */
struct sshsigopt *sshsigopt_parse(const char *opts,
--
To stop receiving notification emails like this one, please contact
djm at mindrot.org.
More information about the openssh-commits
mailing list