]> git.ipfire.org Git - thirdparty/bind9.git/commit
Size HMAC key generation buffers to the maximum block size
authorOndřej Surý <ondrej@isc.org>
Wed, 29 Apr 2026 14:23:10 +0000 (16:23 +0200)
committerOndřej Surý <ondrej@sury.org>
Thu, 30 Apr 2026 04:00:07 +0000 (06:00 +0200)
commit45ea92ea4b79f9a29e744e0b6a702c5e3ac55edb
tree58d4706b3bfe74f2b1e720745595177ce0975666
parentdc5eb3fe25e43cd47ca7874859469d1b4e3f8b41
Size HMAC key generation buffers to the maximum block size

hmac_generate() declared its on-stack nonce buffer as
unsigned char data[ISC_MAX_MD_SIZE], i.e. 64 bytes. That is the maximum
digest size, but the buffer is filled up to the algorithm's HMAC block
size, which is 128 bytes for SHA-384 and SHA-512. Asking rndc-confgen
for an HMAC-SHA-384 or HMAC-SHA-512 key with -b > 512 (the documented
range allows up to 1024) wrote past the end of the stack buffer; on
hardened builds this aborted with a stack-smash detector firing
instead of producing a key.

Use the existing ISC_MAX_BLOCK_SIZE (128) for the buffer so the full
1..1024 range advertised by -A hmac-sha{384,512} works as documented.
The matching key_rawsecret[64] in confgen's generate_key() is enlarged
the same way so the generated key fits when dumped to the buffer.

Add a system test that exercises rndc-confgen across the previously
overflowing keysizes; with -Db_sanitize=address it caught the abort
before the fix.

Assisted-by: Claude:claude-opus-4-7
(cherry picked from commit 46f6bb6364db1dcbbfb2a2add72cff45fd1bda22)
bin/confgen/keygen.c
bin/tests/system/rndc_confgen/tests_rndc_confgen.py [new file with mode: 0644]
lib/dns/hmac_link.c