RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2066882 - OpenSSH can still use 1k RSA keys despite DEFAULT crypto-policy settings claims 2k is minimum
Summary: OpenSSH can still use 1k RSA keys despite DEFAULT crypto-policy settings clai...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: openssh
Version: 9.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Dmitry Belyavskiy
QA Contact: Ondrej Moriš
Jan Fiala
URL:
Whiteboard:
Depends On:
Blocks: 2102774
TreeView+ depends on / blocked
 
Reported: 2022-03-22 16:49 UTC by Jakub Jelen
Modified: 2022-11-15 13:18 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: Enhancement
Doc Text:
.New option in OpenSSH supports setting the minimum RSA key length Accidentally using short RSA keys makes the system more vulnerable to attacks. With this update, you can set minimum RSA key lengths for OpenSSH servers and clients. To define the minimum RSA key length, use the new `RequiredRSASize` option in the `/etc/ssh/sshd_config` file for OpenSSH servers, and in the `/etc/ssh/ssh_config` file for OpenSSH clients.
Clone Of:
Environment:
Last Closed: 2022-11-15 11:21:44 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github openssh openssh-portable pull 325 0 None open Providing MinRSABits option to limit RSA key length 2022-06-10 15:05:09 UTC
Red Hat Issue Tracker CRYPTO-7342 0 None None None 2022-05-27 10:03:03 UTC
Red Hat Issue Tracker RHELPLAN-116427 0 None None None 2022-03-22 16:52:05 UTC
Red Hat Knowledge Base (Solution) 6973518 0 None None None 2022-08-29 13:02:46 UTC
Red Hat Product Errata RHBA-2022:8375 0 None None None 2022-11-15 11:21:59 UTC

Description Jakub Jelen 2022-03-22 16:49:10 UTC
Description of problem:
The crypto-policy claims the RSA keys smaller than 2k are not allowed:

https://gitlab.com/redhat-crypto/fedora-crypto-policies/-/blob/rhel9/policies/DEFAULT.pol#L11

But they clearly work in OpenSSH. They can be generated, used to authenticate to remote server and the server accepts them.

The upstream OpenSSH has hardcoded minimum 1024 since 2017 [1] and this is not configurable at runtime:

https://github.com/openssh/openssh-portable/commit/bd636f40911094a39c2920bf87d2ec340533c152

The OpenSSL claims that this affects only TLS usage so I see the only way out to invent a new configuration option that would make this value dynamic and that could be passed from the crypto-policies.

Version-Release number of selected component (if applicable):
openssl-3.0.1-17.el9.x86_64
openssh-8.7p1-8.el9.x86_64

How reproducible:
always

Steps to Reproduce:
1. Generate 1k RSA key
2. Copy the public key to authorized_keys
3. Try to connect using this key to RHEL9 server

Actual results:
succeeds

Expected results:
failure with scary security warning

Additional info:

The same issue will be with hostkeys.

Transcript of the reproducer above:

# ssh-keygen -t rsa -b 1024
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa
Your public key has been saved in /root/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:UHcLLdAM5BKczf+J/LodXoVe+H8l+ZCljyh0trcX6gk root.local
The key's randomart image is:
+---[RSA 1024]----+
|     ..===o..    |
|      o+o.+o..   |
|      o .. ..    |
|       o  .    o.|
|        S. o .o=o|
|          + =.*=.|
|         . E.o+*+|
|          .o=++ *|
|          o+++.oo|
+----[SHA256]-----+
# ssh-keygen -lf .ssh/id_rsa
1024 SHA256:UHcLLdAM5BKczf+J/LodXoVe+H8l+ZCljyh0trcX6gk root.local (RSA)
# cat .ssh/id_rsa.pub  >> ~/.ssh/authorized_keys 
# grep DEBUG3 /etc/ssh/sshd_config
LogLevel DEBUG3
# systemctl restart sshd
# ssh -i .ssh/id_rsa localhost
The authenticity of host 'localhost (::1)' can't be established.
ED25519 key fingerprint is SHA256:yEvZW3MpW2BeXmbMPMNTUyM8tuJc950AAPhnXaEjTNE.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'localhost' (ED25519) to the list of known hosts.
Last login: Fri Mar 18 13:35:24 2022 from 10.0.2.2
[root@rhel-9-1-0-20220313-2 ~]# 
logout
Connection to localhost closed.
# grep RSA /var/log/secure 
Mar 18 13:36:39 rhel-9-1-0-20220313-2 sshd[897]: Accepted publickey for root from ::1 port 42286 ssh2: RSA SHA256:UHcLLdAM5BKczf+J/LodXoVe+H8l+ZCljyh0trcX6gk
Mar 18 13:49:04 rhel-9-1-0-20220313-2 sshd[938]: debug1: userauth_pubkey: test pkalg rsa-sha2-256 pkblob RSA SHA256:UHcLLdAM5BKczf+J/LodXoVe+H8l+ZCljyh0trcX6gk [preauth]
Mar 18 13:49:04 rhel-9-1-0-20220313-2 sshd[938]: debug1: /root/.ssh/authorized_keys:2: matching key found: RSA SHA256:UHcLLdAM5BKczf+J/LodXoVe+H8l+ZCljyh0trcX6gk
Mar 18 13:49:04 rhel-9-1-0-20220313-2 sshd[938]: Accepted key RSA SHA256:UHcLLdAM5BKczf+J/LodXoVe+H8l+ZCljyh0trcX6gk found at /root/.ssh/authorized_keys:2
Mar 18 13:49:04 rhel-9-1-0-20220313-2 sshd[938]: debug3: mm_answer_keyallowed: publickey authentication test: RSA key is allowed
Mar 18 13:49:04 rhel-9-1-0-20220313-2 sshd[938]: debug3: userauth_pubkey: have rsa-sha2-256 signature for RSA SHA256:UHcLLdAM5BKczf+J/LodXoVe+H8l+ZCljyh0trcX6gk [preauth]
Mar 18 13:49:04 rhel-9-1-0-20220313-2 sshd[938]: debug1: /root/.ssh/authorized_keys:2: matching key found: RSA SHA256:UHcLLdAM5BKczf+J/LodXoVe+H8l+ZCljyh0trcX6gk
Mar 18 13:49:04 rhel-9-1-0-20220313-2 sshd[938]: Accepted key RSA SHA256:UHcLLdAM5BKczf+J/LodXoVe+H8l+ZCljyh0trcX6gk found at /root/.ssh/authorized_keys:2
Mar 18 13:49:04 rhel-9-1-0-20220313-2 sshd[938]: debug3: mm_answer_keyallowed: publickey authentication: RSA key is allowed
Mar 18 13:49:04 rhel-9-1-0-20220313-2 sshd[938]: debug3: mm_answer_keyverify: publickey RSA signature verified
Mar 18 13:49:04 rhel-9-1-0-20220313-2 sshd[938]: Accepted publickey for root from ::1 port 42288 ssh2: RSA SHA256:UHcLLdAM5BKczf+J/LodXoVe+H8l+ZCljyh0trcX6gk

Comment 2 Dmitry Belyavskiy 2022-06-06 10:25:44 UTC
Ideal solution would be to have a configuration option, but upstream will probably not like it. Maybe use as downstream patch?
The problem is not the ssh-keygen generating the keys, but the ssh/sshd using and accepting these keys.

Comment 22 errata-xmlrpc 2022-11-15 11:21:44 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (openssh bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:8375


Note You need to log in before you can comment on or make changes to this bug.