Closed (fixed)
Project:
SSH Key
Version:
4.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
13 May 2026 at 20:57 UTC
Updated:
27 May 2026 at 22:55 UTC
Jump to comment: Most recent
RSA SSH keys remain widely used, but keys below 2048 bits are considered weak by modern standards (NIST
SP 800-131A, OpenSSH defaults). The SshKey field currently accepts any well-formed RSA key regardless of
modulus length. Administrators who want to enforce a minimum bit length must add their own validation or
rely on the SSH server to reject weak keys downstream.
Add a per-field setting min_rsa_bits (default 2048) that the validator enforces when an
incoming key uses the ssh-rsa algorithm:
SshKeyItem::defaultFieldSettings() and the field-settings form (aSshKeyItem::getConstraints() as a constraint option.$minRsaBits property on SshKeyConstraint.SshKeyConstraintValidator::validate(), when the parsed algorithm isssh-rsa, read the modulus from the base64-decoded payload, compute its bit length, and emit aUtils (e.g. getRsaModulusBitLength()) so the parsing logicBit length is computable from the public key alone — RSA public-key payloads carry the modulus as an SSH
mpint after the algorithm string and public exponent. No new dependency required.
Comments
Comment #3
colanImplemented on 4.x as commit 5def9e8.
SshKeyConstraintValidatornow enforces a per-fieldmin_rsa_bitssetting (default 2048) whenever the incoming algorithm isssh-rsa. The bit length is read viaphpseclib3\Crypt\PublicKeyLoader::load(), which is already a hard dependency of this module — no new mpint-parsing code path and no additional Composer requirement.SshKeyItem::getConstraints()falls back todefaultFieldSettings()when the saved setting is missing, so existing fields predating this change pick up the 2048 floor without anhook_update_N.Unit tests cover the helper (
Utils::getRsaModulusBitLength()for 2048-bit, 1024-bit, Ed25519, and garbage payloads) and the validator (acceptance at the threshold, rejection below it, andmin_rsa_bits = 0skipping the check).