[Bug 4037] New: ssh-keygen -k can generate an unreadable KRL with an oversized bitmap
bugzilla-daemon at mindrot.org
bugzilla-daemon at mindrot.org
Sat Oct 17 21:40:06 AEDT 2026
https://bugzilla.mindrot.org/show_bug.cgi?id=4037
Bug ID: 4037
Summary: ssh-keygen -k can generate an unreadable KRL with an
oversized bitmap
Product: Portable OpenSSH
Version: 10.6p1
Hardware: All
OS: All
Status: NEW
Severity: minor
Priority: P5
Component: ssh-keygen
Assignee: unassigned-bugs at mindrot.org
Reporter: p.nekrasov at fobos-nt.ru
When generating a KRL containing sufficiently sparse revoked serial
numbers, ssh-keygen -k can successfully produce a KRL whose bitmap
exceeds SSHBUF_MAX_BIGNUM. The resulting file is then rejected by
ssh-keygen -Q because sshbuf_get_bignum2_bytes_direct() rejects the
oversized bignum.
Reproduction:
```
awk 'BEGIN{ for (i = 0; i < 2500; i++) printf "serial: %d\n", 1000000 +
i*64 }' > spec.txt
ssh-keygen -t ed25519 -f ca -N '' -C ca
ssh-keygen -k -f revoked.krl -s ca.pub spec.txt
Revoking from spec.txt
ssh-keygen -Qf revoked.krl
Invalid KRL file revoked.krl: bignum is too large
```
Possible fix:
```
diff --git a/krl.c b/krl.c
index 0e2b5f1..f1aabbe 100644
--- a/krl.c
+++ b/krl.c
@@ -557,6 +557,11 @@ put_bitmap(struct sshbuf *buf, struct bitmap
*bitmap)
int r;
len = bitmap_nbytes(bitmap);
+ if (len > SSHBUF_MAX_BIGNUM) {
+ error_f("bitmap too large: %zu > %u bytes",
+ len, (unsigned)SSHBUF_MAX_BIGNUM);
+ return SSH_ERR_INTERNAL_ERROR;
+ }
if ((blob = malloc(len)) == NULL)
return SSH_ERR_ALLOC_FAIL;
if (bitmap_to_string(bitmap, blob, len) != 0) {
```
--
You are receiving this mail because:
You are watching the assignee of the bug.
More information about the openssh-bugs
mailing list