]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
upstream: Fix bounds checking when signing messages of length
authordjm@openbsd.org <djm@openbsd.org>
Mon, 29 Jun 2026 02:08:55 +0000 (02:08 +0000)
committerDamien Miller <djm@mindrot.org>
Mon, 29 Jun 2026 02:19:49 +0000 (12:19 +1000)
greater than will fit in a size_t. In OpenSSH, messages sizes are bounded by
SSHBUF_SIZE_MAX so this was unreachable. From Swival scanner.

OpenBSD-Commit-ID: 31ab874abe21a528fa995d78023c5ad9444a31e1

ed25519-openssl.c

index d45effdca4c6b103b1de7e4961effc60aa24adbf..bea1572dfd7c808d2ef66c183a6cbb1f78437e1d 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: ed25519-openssl.c,v 1.2 2026/06/14 03:59:34 djm Exp $ */
+/* $OpenBSD: ed25519-openssl.c,v 1.3 2026/06/29 02:08:55 djm Exp $ */
 /*
  * Copyright (c) 2025 OpenSSH
  *
@@ -194,6 +194,10 @@ crypto_sign_ed25519_open(unsigned char *m, unsigned long long *mlen,
                debug3_f("signed message bad length: %llu", smlen);
                return -1;
        }
+       if (smlen - crypto_sign_ed25519_BYTES > SIZE_MAX) {
+               debug3_f("signed message too long: %llu", smlen);
+               return -1;
+       }
        /* Signature is first crypto_sign_ed25519_BYTES, message follows */
        msg = sm + crypto_sign_ed25519_BYTES;
        msglen = smlen - crypto_sign_ed25519_BYTES;