528 Commits

Author SHA1 Message Date
djm@openbsd.org
5166b6cbf2 upstream: When certificate support was added to OpenSSH,
certificates were originally specified to represent any principal if the
principals list was empty.

This was, in retrospect, a mistake as it created a fail-open
situation if a CA could be convinced to accidentally sign a
certificate with no principals. This actually happened in a 3rd-
party CA product (CVE-2024-7594).

Somewhat fortunately, the main pathway for using certificates in
sshd (TrustedUserCAKeys) never supported empty-principals
certificates, so the blast radius of such mistakes was
substantially reduced.

This change removes this footcannon and requires all certificates
include principals sections. It also fixes interpretation of
wildcard principals, and properly enables them for host
certificates only.

This is a behaviour change that will permanently break uses of
certificates with empty principals sections.

ok markus@

OpenBSD-Commit-ID: 0a901f03c567c100724a492cf91e02939904712e
2025-12-22 12:51:24 +11:00
dtucker@openbsd.org
d9955e4571 upstream: Remove calls to OpenSSL_add_all_algorithms()
and ERR_load_crypto_strings(). These are no-ops in LibreSSL, and in
Portable have been mostly replaced by a call to OPENSSL_init_crypto()
in the compat layer.  ok tb@

OpenBSD-Commit-ID: 4c3e0af10fe276766054eda34428a37a5606d3ea
2025-11-13 22:08:28 +11:00
djm@openbsd.org
e7b4b3f153 upstream: don't abuse SSHKEY_FLAG_EXT to signal that a key is in
the agent, as that triggers special handling on sshkey_free()

OpenBSD-Commit-ID: 2ae2247babd2db167a30cf7a4f7eae4f26c000a8
2025-10-10 13:30:51 +11:00
djm@openbsd.org
a9cbe10da2 upstream: include openssl/bn.h explicitly in files where we use BN_*
makes things simpler for portable; from Mike Frysinger

OpenBSD-Commit-ID: 717e93403fd1108e175afd7451b5a4ab46a598fe
2025-10-03 10:12:15 +10:00
jsg@openbsd.org
b1c4bf5c2f upstream: avoid use-after-free in update_krl_from_file() found with
clang scan-build, ok dtucker@

OpenBSD-Commit-ID: 8ec86eca573740c94d5bc7e252959174555f4eb8
2025-09-29 13:24:57 +10:00
djm@openbsd.org
846987d123 upstream: fix some one-off leaks in ssh-keygen; ok dtucker@
OpenBSD-Commit-ID: 32f51289c93246474659aa49067926fcab9e02e8
2025-09-25 17:07:30 +10:00
Darren Tucker
22cfd2dd32 Move ssh-pkcs11.h include to match upstream. 2025-09-05 20:26:14 +10:00
Darren Tucker
5f09983d1e Create replacement paths.h if needed.
Remove #ifdef HAVE_PATHS_H wrapper.  ok djm@
2025-09-05 17:24:50 +10:00
Darren Tucker
9b2c5a2db0 Fill in missing system header files.
Create replacement header files inside openbsd-compat for common headers
that are missing on a given platform.  Usually these are just empty,
but in some cases they'll include the equivalent file.  This avoids
having to wrap those includes in '#ifdef HAVE_FOO_H' and reduces the
diff vs OpenBSD.

If we create any such headers, add the path to includes.

Initially just stdint.h, more to follow.

ok djm@
2025-09-05 17:06:14 +10:00
djm@openbsd.org
a9a3f025d7 upstream: remove experimental support for XMSS keys;
ok deraadt markus

OpenBSD-Commit-ID: 38eaf4df6189acad9e46eddf7cf32d7f6d07df35
2025-08-29 13:58:40 +10:00
dtucker@openbsd.org
2168241727 upstream: Remove ssh-keygen's moduli screen -Omemory option.
This vaguely made sense 20 years ago, but these days you'd be hard
pressed to *find* a machine small enough to not support the maximum
(127MB), and no one is screening moduli on such machines anyway,
so just use the max.  This also fixes Coverity CID 470522 by deleting
code in question.  "kill it with fire" djm@.

OpenBSD-Commit-ID: 39036aa406a99f0a91923aa3a96afff1205558e6
2025-05-24 14:03:17 +10:00
dtucker@openbsd.org
eccc15014f upstream: Use pointer from strprefix in error message,
missed in previous.

OpenBSD-Commit-ID: d2cdec6cf0fcd4b0ee25e4e3fad8bc8cf0ee657d
2025-05-24 14:02:49 +10:00
dtucker@openbsd.org
91903511d0 upstream: Replace strncmp and strncasecmp with hand-counting bytes
with strprefix. nits lucas@, ok lucas@ djm@

OpenBSD-Commit-ID: f0888807f151ea2bdaf6fed36303ae81f259d1d4
2025-05-24 13:44:37 +10:00
djm@openbsd.org
a32d28d792 upstream: finally remove DSA signature support from OpenSSH.
feedback/ok tb@, ok deraadt@

OpenBSD-Commit-ID: bfe6ee73c1b676c81a2901030c791f8ec888228f
2025-05-07 14:20:14 +10:00
djm@openbsd.org
6993d9f095 upstream: don't screw up ssh-keygen -l output when the file
contains CR characters; GHPR236 bz3385, fix from Dmitry Belyavskiy

OpenBSD-Commit-ID: e458cf6b0adcea5b69ef4c7ba38e590841d02ef4
2024-12-05 01:28:55 +11:00
djm@openbsd.org
d9cd208e89 upstream: allow "-" as output file for moduli screening
based on GHPR393

OpenBSD-Commit-ID: 1517763764eb55d03a6092dd120d2909c6fef0e1
2024-10-18 16:37:53 +11:00
djm@openbsd.org
dd424d7c38 upstream: include pathname in some of the ssh-keygen passphrase
prompts. Helps the user know what's going on when ssh-keygen is invoked via
other tools. Requested in GHPR503

OpenBSD-Commit-ID: 613b0bb6cf845b7e787d69a5b314057ceda6a8b6
2024-09-15 11:23:08 +10:00
djm@openbsd.org
13cc78d016 upstream: be more strict in parsing key type names. Only allow
shortnames (e.g "rsa") in user-interface code and require full SSH protocol
names (e.g. "ssh-rsa") everywhere else.

Prompted by bz3725; ok markus@

OpenBSD-Commit-ID: b3d8de9dac37992eab78adbf84fab2fe0d84b187
2024-09-04 15:38:50 +10:00
djm@openbsd.org
7bdfc20516 upstream: Convert RSA and ECDSA key to the libcrypto EVP_PKEY API.
DSA remains unconverted as it will be removed within six months.

Based on patches originally from Dmitry Belyavskiy, but significantly
reworked based on feedback from Bob Beck, Joel Sing and especially
Theo Buehler (apologies to anyone I've missed).

ok tb@

OpenBSD-Commit-ID: d098744e89f1dc7e5952a6817bef234eced648b5
2024-08-15 12:07:59 +10:00
djm@openbsd.org
4e838120a7 upstream: make DSA key support compile-time optional, defaulting to
on

ok markus@

OpenBSD-Commit-ID: 4f8e98fc1fd6de399d0921d5b31b3127a03f581d
2024-01-11 15:46:22 +11:00
job@openbsd.org
e1c284d60a upstream: Generate Ed25519 keys when invoked without arguments
Ed25519 public keys are very convenient due to their small size.
OpenSSH has supported Ed25519 since version 6.5 (January 2014).

OK djm@ markus@ sthen@ deraadt@

OpenBSD-Commit-ID: f498beaad19c8cdcc357381a60df4a9c69858b3f
2023-09-07 09:53:59 +10:00
djm@openbsd.org
beec17bb31 upstream: remove vestigal support for KRL signatures
When the KRL format was originally defined, it included support for
signing of KRL objects. However, the code to sign KRLs and verify KRL
signatues was never completed in OpenSSH.

Now, some years later, we have SSHSIG support in ssh-keygen that is
more general, well tested and actually works. So this removes the
semi-finished KRL signing/verification support from OpenSSH and
refactors the remaining code to realise the benefit - primarily, we
no longer need to perform multiple parsing passes over KRL objects.

ok markus@

OpenBSD-Commit-ID: 517437bab3d8180f695c775410c052340e038804
2023-07-17 14:52:35 +10:00
djm@openbsd.org
2ee48adb9f upstream: add defence-in-depth checks for some unreachable integer
overflows reported by Yair Mizrahi @ JFrog; feedback/ok millert@

OpenBSD-Commit-ID: 52af085f4e7ef9f9d8423d8c1840a6a88bda90bd
2023-07-14 15:33:30 +10:00
djm@openbsd.org
b4ac435b4e upstream: reset comment=NULL for each key in do_fingerprint();
fixes "no comment" not showing on when running `ssh-keygen -l` on multiple
keys where one has a comment and other following keys do not. Patch from
Markus Kuhn via GHPR407, bz3580

OpenBSD-Commit-ID: 3cce84456fdcd67dc6b84e369f92c6686d111d9b
2023-06-20 10:07:06 +10:00
jsg@openbsd.org
740dafa20f upstream: fix double words ok dtucker@
OpenBSD-Commit-ID: 44d3223902fbce5276422bdc8063ab72a4078489
2023-04-17 09:21:13 +10:00
djm@openbsd.org
27fd251bc9 upstream: use RSA/SHA256 when testing usability of private key;
based on fix in bz3546 by Dmitry Belyavskiy; with/ok dtucker

OpenBSD-Commit-ID: 0ef414cc363a832f9fab92a5da0234448bce2eba
2023-03-08 11:06:57 +11:00
dtucker@openbsd.org
aa59d6a489 upstream: Fix mem and FILE leaks in moduli screening.
If multiple -Ocheckpoint= options are passed, the earlier ones would
be overwritten and leaked.  If we use an input file that wasn't stdin,
close that.  From Coverity CIDs 291884 and 291894.

OpenBSD-Commit-ID: a4d9d15f572926f841788912e2b282485ad09e8b
2023-03-05 20:33:29 +11:00
dtucker@openbsd.org
23b8cb4176 upstream: Plug mem leak in moduli checkpoint option parsing.
From Coverity CID 291894.

OpenBSD-Commit-ID: 9b1aba2d049741ae21c8dc4560a7e29ab17310f4
2023-03-05 19:33:39 +11:00
dtucker@openbsd.org
44ca56ba0b upstream: Explicitly ignore return from fchmod
similar to other calls to prevent warning.

OpenBSD-Commit-ID: fdc5287dcee0860b5a493186414226c655b0eb0a
2023-02-28 20:02:29 +11:00
djm@openbsd.org
d651f5c9fe upstream: let ssh-keygen and ssh-keyscan accept
-Ohashalg=sha1|sha256 when outputting SSHFP fingerprints to allow algorithm
selection. bz3493 ok dtucker@

OpenBSD-Commit-ID: e6e07fe21318a873bd877f333e189eb963a11b3d
2023-02-10 16:12:42 +11:00
cheloha@openbsd.org
b85c3581c1 upstream: remove '?' from getopt(3) loops
userspace: remove vestigial '?' cases from top-level getopt(3) loops

getopt(3) returns '?' when it encounters a flag not present in the in
the optstring or if a flag is missing its option argument.  We can
handle this case with the "default" failure case with no loss of
legibility.  Hence, remove all the redundant "case '?':" lines.

Prompted by dlg@.  With help from dlg@ and millert@.

Link: https://marc.info/?l=openbsd-tech&m=167011979726449&w=2

ok naddy@ millert@ dlg@

OpenBSD-Commit-ID: b2f89346538ce4f5b33ab8011a23e0626a67e66e
2022-12-09 11:36:12 +11:00
djm@openbsd.org
a00f59a645 upstream: fix parsing of hex cert expiry time; was checking whether the
start time began with "0x", not the expiry time.

from Ed Maste

OpenBSD-Commit-ID: 6269242c3e1a130b47c92cfca4d661df15f05739
2022-11-07 15:43:13 +11:00
djm@openbsd.org
ec1ddb72a1 upstream: allow certificate validity intervals, sshsig verification
times and authorized_keys expiry-time options to accept dates in the UTC time
zone in addition to the default of interpreting them in the system time zone.
YYYYMMDD and YYMMDDHHMM[SS] dates/times will be interpreted as UTC if
suffixed with a 'Z' character.

Also allow certificate validity intervals to be specified in raw
seconds-since-epoch as hex value, e.g. -V 0x1234:0x4567890. This
is intended for use by regress tests and other tools that call
ssh-keygen as part of a CA workflow.

bz3468 ok dtucker

OpenBSD-Commit-ID: 454db1cdffa9fa346aea5211223a2ce0588dfe13
2022-08-11 12:00:49 +10:00
djm@openbsd.org
2a108c0ea9 upstream: don't prompt for FIDO passphrase before attempting to enroll
the credential, just let the enroll operating fail and we'll attempt to get a
PIN anyway. Might avoid some unneccessary PIN prompts.

Part of GHPR#302 from Corinna Vinschen; ok dtucker@

OpenBSD-Commit-ID: bd5342ffc353ee37d39617906867c305564d1ce2
2022-08-05 15:03:40 +10:00
djm@openbsd.org
f208e3b9ff upstream: ssh-keygen: fix touch prompt, pin retries;
part of GHPR329 from Pedro Martelletto

OpenBSD-Commit-ID: 75d1005bd2ef8f29fa834c90d2684e73556fffe8
2022-07-20 13:38:48 +10:00
djm@openbsd.org
9ab929ca2d upstream: when enrolling a resident key on a security token, check
if a credential with matching application and user ID strings already exists.
if so, prompt the user for confirmation before overwriting the credential.

patch from Pedro Martelletto via GHPR329

NB. cranks SSH_SK_VERSION_MAJOR, so any third-party FIDO middleware
implementations will need to adjust

OpenBSD-Commit-ID: e45e9f1bf2b2f32d9850669e7a8dbd64acc5fca4
2022-07-20 13:38:47 +10:00
djm@openbsd.org
5bcfc788b3 upstream: pull passphrase reading and confirmation into a separate
function so it can be used for FIDO2 PINs; no functional change

OpenBSD-Commit-ID: bf34f76b8283cc1d3f54633e0d4f13613d87bb2f
2022-07-20 13:18:53 +10:00
dtucker@openbsd.org
88e376fcd6 upstream: ssh-keygen -A: do not generate DSA keys by default.
Based on github PR#303 from jsegitz with man page text from jmc@, ok markus@
djm@

OpenBSD-Commit-ID: 5c4c57bdd7063ff03381cfb6696659dd3f9f5b9f
2022-06-03 13:38:19 +10:00
naddy@openbsd.org
6b3fb62467 upstream: ssh-keygen: implement "verify-required" certificate option.
This was already documented when support for user-verified FIDO
keys was added, but the ssh-keygen(1) code was missing.

ok djm@

OpenBSD-Commit-ID: f660f973391b593fea4b7b25913c9a15c3eb8a06
2022-06-03 13:38:15 +10:00
djm@openbsd.org
0086a286ea upstream: Allow existing -U (use agent) flag to work with "-Y sign"
operations, where it will be interpreted to require that the private keys is
hosted in an agent; bz3429, suggested by Adam Szkoda; ok dtucker@

OpenBSD-Commit-ID: a7bc69873b99c32c42c7628ed9ea91565ba08c2f
2022-05-09 13:11:03 +10:00
djm@openbsd.org
cb010744cc upstream: improve error message when 'ssh-keygen -Y sign' is unable to
load a private key; bz3429, reported by Adam Szkoda ok dtucker@

OpenBSD-Commit-ID: bb57b285e67bea536ef81b1055467be2fc380e74
2022-05-09 13:10:09 +10:00
djm@openbsd.org
807be68684 upstream: helpful comment
OpenBSD-Commit-ID: e3315a45cb04e7feeb614d76ec80a9fe4ca0e8c7
2022-03-18 13:33:36 +11:00
djm@openbsd.org
a0b5816f8f upstream: ssh-keygen -Y check-novalidate requires namespace or SEGV
will ensue. Patch from Mateusz Adamowski via GHPR#307

OpenBSD-Commit-ID: 99e8ec38f9feb38bce6de240335be34aedeba5fd
2022-03-18 13:33:36 +11:00
djm@openbsd.org
541667fe6d upstream: mark const string array contents const too, i.e. static
const char *array => static const char * const array from Mike Frysinger

OpenBSD-Commit-ID: a664e31ea6a795d7c81153274a5f47b22bdc9bc1
2022-02-02 10:38:59 +11:00
djm@openbsd.org
24c5187edf upstream: add a comment so I don't make this mistake again
OpenBSD-Commit-ID: 69c7f2362f9de913bb29b6318580c5a1b52c921e
2022-01-07 09:10:42 +11:00
djm@openbsd.org
7369900441 upstream: fix cut-and-pasto in error message
OpenBSD-Commit-ID: 4cc5c619e4b456cd2e9bb760d17e3a9c84659198
2022-01-07 09:10:42 +11:00
djm@openbsd.org
2327c306b5 upstream: allow selection of hash at sshsig signing time; code
already supported either sha512 (default) or sha256, but plumbing wasn't
there mostly by Linus Nordberg

OpenBSD-Commit-ID: 1b536404b9da74a84b3a1c8d0b05fd564cdc96cd
2022-01-05 16:06:01 +11:00
djm@openbsd.org
56e941d0a0 upstream: add missing -O option to usage() for ssh-keygen -Y sign;
from Linus Nordberg

OpenBSD-Commit-ID: 4e78feb4aa830727ab76bb2e3d940440ae1d7af0
2022-01-05 16:06:01 +11:00
djm@openbsd.org
141a14ec9b upstream: move sig_process_opts() to before sig_sign(); no
functional code change

OpenBSD-Commit-ID: da02d61f5464f72b4e8b299f83e93c3b657932f9
2022-01-05 16:06:01 +11:00
djm@openbsd.org
56db1f4a4c upstream: fix indenting in last commit
OpenBSD-Commit-ID: 8b9ba989815d0dec1fdf5427a4a4b58eb9cac4d2
2021-11-28 18:28:08 +11:00