Skip to content

Add bounds check on KRB5KDF constant length to prevent buffer overflow#421

Merged
padelsbach merged 1 commit into
wolfSSL:masterfrom
ColtonWilley:wp_fix_krb5kdf_constant_bounds
Jul 1, 2026
Merged

Add bounds check on KRB5KDF constant length to prevent buffer overflow#421
padelsbach merged 1 commit into
wolfSSL:masterfrom
ColtonWilley:wp_fix_krb5kdf_constant_bounds

Conversation

@ColtonWilley

@ColtonWilley ColtonWilley commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary

wp_kdf_krb5kdf_derive passes ctx->constantSz to n_fold, which does XMEMCPY(block, constant, constant_len) into the fixed 16-byte stack buffer block[AES_BLOCK_SIZE]. A constant longer than the block size overflows the stack (and triggers a size_t underflow in a later XMEMSET). n_fold's documented precondition requires constant_len <= blocksize, but the caller never enforced an upper bound. OpenSSL's KRB5KDF guards against this; we now do too.

Changes

  • src/wp_krb5kdf.c: reject constantSz > AES_BLOCK_SIZE before calling n_fold.
  • test/test_krb5kdf.c: negative test with an oversized constant; runs against both wolfProvider and OpenSSL (both must reject).

Testing

Full suite passes; test_krb5kdf confirms both providers reject the oversized constant.

Fixes fenrir F-4076

@padelsbach
padelsbach merged commit ecdd878 into wolfSSL:master Jul 1, 2026
74 of 75 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants