diff --git a/Adjust-build-configuration.patch b/Adjust-build-configuration.patch index 68ecf50be6550131535dc4a34c69a2aa704d409c..45c0b48bc175f0d0e3fc276e689f44a652d80e77 100644 --- a/Adjust-build-configuration.patch +++ b/Adjust-build-configuration.patch @@ -56,7 +56,7 @@ index 3e4af6c02..2b20c3fda 100644 # Use objdump -x to examine the fields of the library # UNDEF_CHECK is suppressed by --enable-asan - LDCOMBINE='$(CC) -shared -fPIC -Wl,-h,$(LIBPREFIX)$(LIBBASE)$(SHLIBSEXT) $(UNDEF_CHECK)' -+ LDCOMBINE='$(CC) -shared -fPIC -Wl,-h,$(LIBPREFIX)$(LIBBASE)$(SHLIBSEXT) $(UNDEF_CHECK) -Wl,-z,relro -Wl,--warn-shared-textrel' ++ LDCOMBINE='$(CC) -shared -fPIC $(LDFLAGS) -Wl,-h,$(LIBPREFIX)$(LIBBASE)$(SHLIBSEXT) $(UNDEF_CHECK) -Wl,-z,relro -Wl,--warn-shared-textrel' UNDEF_CHECK='-Wl,--no-undefined' # $(EXPORT_CHECK) runs export-check.pl when in maintainer mode. LDCOMBINE_TAIL='-Wl,--version-script binutils.versions $(EXPORT_CHECK)' @@ -65,7 +65,7 @@ index 3e4af6c02..2b20c3fda 100644 PROFFLAGS=-pg PROG_RPATH_FLAGS='$(RPATH_FLAG)$(PROG_RPATH)' - CC_LINK_SHARED='$(CC) $(PROG_LIBPATH) $(PROG_RPATH_FLAGS) $(CFLAGS) $(LDFLAGS)' -+ CC_LINK_SHARED='$(CC) $(PROG_LIBPATH) $(PROG_RPATH_FLAGS) $(CFLAGS) -pie -Wl,-z,relro -Wl,-z,now $(LDFLAGS)' ++ CC_LINK_SHARED='$(CC) $(LDFLAGS) $(PROG_LIBPATH) $(PROG_RPATH_FLAGS) $(CFLAGS) -pie -Wl,-z,relro -Wl,-z,now' + INSTALL_SHLIB='${INSTALL} -m755' CC_LINK_STATIC='$(CC) $(PROG_LIBPATH) $(CFLAGS) $(LDFLAGS)' CXX_LINK_SHARED='$(CXX) $(PROG_LIBPATH) $(PROG_RPATH_FLAGS) $(CXXFLAGS) $(LDFLAGS)' diff --git a/Fix-krb5_cccol_have_content-bad-pointer-free.patch b/Fix-krb5_cccol_have_content-bad-pointer-free.patch deleted file mode 100644 index ef56eccca6a99efb78a735518c3a0ac569ac5849..0000000000000000000000000000000000000000 --- a/Fix-krb5_cccol_have_content-bad-pointer-free.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 635c8cca65b745476d07c1f5ff701445db25c10d Mon Sep 17 00:00:00 2001 -From: Ilya Gladyshev -Date: Wed, 30 Aug 2023 21:19:59 +0100 -Subject: [PATCH] Fix krb5_cccol_have_content() bad pointer free - -krb5_cccol_have_content() calls krb5_cc_get_principal() within a loop, -and frees the resulting principal on success or failure. Set princ to -null before each call to ensure we don't free a dangling pointer. - -[ghudson@mit.edu: rewrote commit message; moved assignment for greater -clarity] - -ticket: 9103 -tags: pullup -target_version: 1.21-next -target_version: 1.20-next ---- - src/lib/krb5/ccache/cccursor.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/src/lib/krb5/ccache/cccursor.c b/src/lib/krb5/ccache/cccursor.c -index 4bcb66b71..926873f2a 100644 ---- a/src/lib/krb5/ccache/cccursor.c -+++ b/src/lib/krb5/ccache/cccursor.c -@@ -249,6 +249,7 @@ krb5_cccol_have_content(krb5_context context) - save_first_error(context, ret, &errsave); - if (ret || cache == NULL) - break; -+ princ = NULL; - ret = krb5_cc_get_principal(context, cache, &princ); - save_first_error(context, ret, &errsave); - if (!ret) --- -2.33.0 - diff --git a/backport-CVE-2024-37370-CVE-2024-37371-Fix-vulnerabilities-in-GSS-message-token-handling.patch b/backport-CVE-2024-37370-CVE-2024-37371-Fix-vulnerabilities-in-GSS-message-token-handling.patch deleted file mode 100644 index 8687020883bff86891725d0f9297f516b935dc01..0000000000000000000000000000000000000000 --- a/backport-CVE-2024-37370-CVE-2024-37371-Fix-vulnerabilities-in-GSS-message-token-handling.patch +++ /dev/null @@ -1,536 +0,0 @@ -From b0a2f8a5365f2eec3e27d78907de9f9d2c80505a Mon Sep 17 00:00:00 2001 -From: Greg Hudson -Date: Fri, 14 Jun 2024 10:56:12 -0400 -Subject: [PATCH] Fix vulnerabilities in GSS message token handling - -In gss_krb5int_unseal_token_v3() and gss_krb5int_unseal_v3_iov(), -verify the Extra Count field of CFX wrap tokens against the encrypted -header. Reported by Jacob Champion. - -In gss_krb5int_unseal_token_v3(), check for a decrypted plaintext -length too short to contain the encrypted header and extra count -bytes. Reported by Jacob Champion. - -In kg_unseal_iov_token(), separately track the header IOV length and -complete token length when parsing the token's ASN.1 wrapper. This -fix contains modified versions of functions from k5-der.h and -util_token.c; this duplication will be cleaned up in a future commit. - -CVE-2024-37370: - -In MIT krb5 release 1.3 and later, an attacker can modify the -plaintext Extra Count field of a confidential GSS krb5 wrap token, -causing the unwrapped token to appear truncated to the application. - -CVE-2024-37371: - -In MIT krb5 release 1.3 and later, an attacker can cause invalid -memory reads by sending message tokens with invalid length fields. - -ticket: 9128 (new) -tags: pullup -target_version: 1.21-next - -Reference: https://github.com/krb5/krb5/commit/b0a2f8a5365f2eec3e27d78907de9f9d2c80505a -Conflict: src/tests/gssapi/t_invalid.c - ---- - src/lib/gssapi/krb5/k5sealv3.c | 5 + - src/lib/gssapi/krb5/k5sealv3iov.c | 3 +- - src/lib/gssapi/krb5/k5unsealiov.c | 80 +++++++++- - src/tests/gssapi/t_invalid.c | 233 +++++++++++++++++++++++++----- - 4 files changed, 275 insertions(+), 46 deletions(-) - -diff --git a/src/lib/gssapi/krb5/k5sealv3.c b/src/lib/gssapi/krb5/k5sealv3.c -index e881eee..d3210c1 100644 ---- a/src/lib/gssapi/krb5/k5sealv3.c -+++ b/src/lib/gssapi/krb5/k5sealv3.c -@@ -400,10 +400,15 @@ gss_krb5int_unseal_token_v3(krb5_context *contextptr, - /* Don't use bodysize here! Use the fact that - cipher.ciphertext.length has been adjusted to the - correct length. */ -+ if (plain.length < 16 + ec) { -+ free(plain.data); -+ goto defective; -+ } - althdr = (unsigned char *)plain.data + plain.length - 16; - if (load_16_be(althdr) != KG2_TOK_WRAP_MSG - || althdr[2] != ptr[2] - || althdr[3] != ptr[3] -+ || load_16_be(althdr+4) != ec - || memcmp(althdr+8, ptr+8, 8)) { - free(plain.data); - goto defective; -diff --git a/src/lib/gssapi/krb5/k5sealv3iov.c b/src/lib/gssapi/krb5/k5sealv3iov.c -index 333ee12..f8e90c3 100644 ---- a/src/lib/gssapi/krb5/k5sealv3iov.c -+++ b/src/lib/gssapi/krb5/k5sealv3iov.c -@@ -402,9 +402,10 @@ gss_krb5int_unseal_v3_iov(krb5_context context, - if (load_16_be(althdr) != KG2_TOK_WRAP_MSG - || althdr[2] != ptr[2] - || althdr[3] != ptr[3] -+ || load_16_be(althdr + 4) != ec - || memcmp(althdr + 8, ptr + 8, 8) != 0) { - *minor_status = 0; -- return GSS_S_BAD_SIG; -+ return GSS_S_DEFECTIVE_TOKEN; - } - } else { - /* Verify checksum: note EC is checksum size here, not padding */ -diff --git a/src/lib/gssapi/krb5/k5unsealiov.c b/src/lib/gssapi/krb5/k5unsealiov.c -index 3ce2a90..6a6585d 100644 ---- a/src/lib/gssapi/krb5/k5unsealiov.c -+++ b/src/lib/gssapi/krb5/k5unsealiov.c -@@ -25,6 +25,7 @@ - */ - - #include "k5-int.h" -+#include "k5-der.h" - #include "gssapiP_krb5.h" - - static OM_uint32 -@@ -247,6 +248,73 @@ cleanup: - return retval; - } - -+/* Similar to k5_der_get_value(), but output an unchecked content length -+ * instead of a k5input containing the contents. */ -+static inline bool -+get_der_tag(struct k5input *in, uint8_t idbyte, size_t *len_out) -+{ -+ uint8_t lenbyte, i; -+ size_t len; -+ -+ /* Do nothing if in is empty or the next byte doesn't match idbyte. */ -+ if (in->status || in->len == 0 || *in->ptr != idbyte) -+ return false; -+ -+ /* Advance past the identifier byte and decode the length. */ -+ (void)k5_input_get_byte(in); -+ lenbyte = k5_input_get_byte(in); -+ if (lenbyte < 128) { -+ len = lenbyte; -+ } else { -+ len = 0; -+ for (i = 0; i < (lenbyte & 0x7F); i++) { -+ if (len > (SIZE_MAX >> 8)) { -+ k5_input_set_status(in, EOVERFLOW); -+ return false; -+ } -+ len = (len << 8) | k5_input_get_byte(in); -+ } -+ } -+ -+ if (in->status) -+ return false; -+ -+ *len_out = len; -+ return true; -+} -+ -+/* -+ * Similar to g_verify_token_header() without toktype or flags, but do not read -+ * more than *header_len bytes of ASN.1 wrapper, and on output set *header_len -+ * to the remaining number of header bytes. Verify the outer DER tag's length -+ * against token_len, which may be larger (but not smaller) than *header_len. -+ */ -+static gss_int32 -+verify_detached_wrapper(const gss_OID_desc *mech, size_t *header_len, -+ uint8_t **header_in, size_t token_len) -+{ -+ struct k5input in, mech_der; -+ gss_OID_desc toid; -+ size_t len; -+ -+ k5_input_init(&in, *header_in, *header_len); -+ -+ if (get_der_tag(&in, 0x60, &len)) { -+ if (len != token_len - (in.ptr - *header_in)) -+ return G_BAD_TOK_HEADER; -+ if (!k5_der_get_value(&in, 0x06, &mech_der)) -+ return G_BAD_TOK_HEADER; -+ toid.elements = (uint8_t *)mech_der.ptr; -+ toid.length = mech_der.len; -+ if (!g_OID_equal(&toid, mech)) -+ return G_WRONG_MECH; -+ } -+ -+ *header_in = (uint8_t *)in.ptr; -+ *header_len = in.len; -+ return 0; -+} -+ - /* - * Caller must provide TOKEN | DATA | PADDING | TRAILER, except - * for DCE in which case it can just provide TOKEN | DATA (must -@@ -267,8 +335,7 @@ kg_unseal_iov_token(OM_uint32 *minor_status, - gss_iov_buffer_t header; - gss_iov_buffer_t padding; - gss_iov_buffer_t trailer; -- size_t input_length; -- unsigned int bodysize; -+ size_t input_length, hlen; - int toktype2; - - header = kg_locate_header_iov(iov, iov_count, toktype); -@@ -298,15 +365,14 @@ kg_unseal_iov_token(OM_uint32 *minor_status, - input_length += trailer->buffer.length; - } - -- code = g_verify_token_header(ctx->mech_used, -- &bodysize, &ptr, -1, -- input_length, 0); -+ hlen = header->buffer.length; -+ code = verify_detached_wrapper(ctx->mech_used, &hlen, &ptr, input_length); - if (code != 0) { - *minor_status = code; - return GSS_S_DEFECTIVE_TOKEN; - } - -- if (bodysize < 2) { -+ if (hlen < 2) { - *minor_status = (OM_uint32)G_BAD_TOK_HEADER; - return GSS_S_DEFECTIVE_TOKEN; - } -@@ -314,7 +380,7 @@ kg_unseal_iov_token(OM_uint32 *minor_status, - toktype2 = load_16_be(ptr); - - ptr += 2; -- bodysize -= 2; -+ hlen -= 2; - - switch (toktype2) { - case KG2_TOK_MIC_MSG: -diff --git a/src/tests/gssapi/t_invalid.c b/src/tests/gssapi/t_invalid.c -index fb8fe55..d1f019f 100644 ---- a/src/tests/gssapi/t_invalid.c -+++ b/src/tests/gssapi/t_invalid.c -@@ -36,31 +36,41 @@ - * - * 1. A pre-CFX wrap or MIC token processed with a CFX-only context causes a - * null pointer dereference. (The token must use SEAL_ALG_NONE or it will -- * be rejected.) -+ * be rejected.) This vulnerability also applies to IOV unwrap. - * -- * 2. A pre-CFX wrap or MIC token with fewer than 24 bytes after the ASN.1 -+ * 2. A CFX wrap token with a different value of EC between the plaintext and -+ * encrypted copies will be erroneously accepted, which allows a message -+ * truncation attack. This vulnerability also applies to IOV unwrap. -+ * -+ * 3. A CFX wrap token with a plaintext length fewer than 16 bytes causes an -+ * access before the beginning of the input buffer, possibly leading to a -+ * crash. -+ * -+ * 4. A CFX wrap token with a plaintext EC value greater than the plaintext -+ * length - 16 causes an integer underflow when computing the result length, -+ * likely causing a crash. -+ * -+ * 5. An IOV unwrap operation will overrun the header buffer if an ASN.1 -+ * wrapper longer than the header buffer is present. -+ * -+ * 6. A pre-CFX wrap or MIC token with fewer than 24 bytes after the ASN.1 - * header causes an input buffer overrun, usually leading to either a segv - * or a GSS_S_DEFECTIVE_TOKEN error due to garbage algorithm, filler, or -- * sequence number values. -+ * sequence number values. This vulnerability also applies to IOV unwrap. - * -- * 3. A pre-CFX wrap token with fewer than 16 + cksumlen bytes after the ASN.1 -+ * 7. A pre-CFX wrap token with fewer than 16 + cksumlen bytes after the ASN.1 - * header causes an integer underflow when computing the ciphertext length, - * leading to an allocation error on 32-bit platforms or a segv on 64-bit - * platforms. A pre-CFX MIC token of this size causes an input buffer - * overrun when comparing the checksum, perhaps leading to a segv. - * -- * 4. A pre-CFX wrap token with fewer than conflen + padlen bytes in the -+ * 8. A pre-CFX wrap token with fewer than conflen + padlen bytes in the - * ciphertext (where padlen is the last byte of the decrypted ciphertext) - * causes an integer underflow when computing the original message length, - * leading to an allocation error. - * -- * 5. In the mechglue, truncated encapsulation in the initial context token can -+ * 9. In the mechglue, truncated encapsulation in the initial context token can - * cause input buffer overruns in gss_accept_sec_context(). -- * -- * Vulnerabilities #1 and #2 also apply to IOV unwrap, although tokens with -- * fewer than 16 bytes after the ASN.1 header will be rejected. -- * Vulnerabilities #2 and #5 can only be robustly detected using a -- * memory-checking environment such as valgrind. - */ - - #include "k5-int.h" -@@ -98,16 +108,24 @@ struct test { - }; - - /* Fake up enough of a CFX GSS context for gss_unwrap, using an AES key. */ -+static void * -+ealloc(size_t len) -+{ -+ void *ptr = calloc(len, 1); -+ -+ if (ptr == NULL) -+ abort(); -+ return ptr; -+} -+ -+/* Fake up enough of a CFX GSS context for gss_unwrap, using an AES key. -+ * The context takes ownership of subkey. */ - static gss_ctx_id_t --make_fake_cfx_context() -+make_fake_cfx_context(krb5_key subkey) - { - gss_union_ctx_id_t uctx; - krb5_gss_ctx_id_t kgctx; -- krb5_keyblock kb; -- -- kgctx = calloc(1, sizeof(*kgctx)); -- if (kgctx == NULL) -- abort(); -+ kgctx = ealloc(sizeof(*kgctx)); - kgctx->established = 1; - kgctx->proto = 1; - if (g_seqstate_init(&kgctx->seqstate, 0, 0, 0, 0) != 0) -@@ -116,15 +134,10 @@ make_fake_cfx_context() - kgctx->sealalg = -1; - kgctx->signalg = -1; - -- kb.enctype = ENCTYPE_AES128_CTS_HMAC_SHA1_96; -- kb.length = 16; -- kb.contents = (unsigned char *)"1234567887654321"; -- if (krb5_k_create_key(NULL, &kb, &kgctx->subkey) != 0) -- abort(); -+ kgctx->subkey = subkey; -+ kgctx->cksumtype = CKSUMTYPE_HMAC_SHA1_96_AES128; - -- uctx = calloc(1, sizeof(*uctx)); -- if (uctx == NULL) -- abort(); -+ uctx = ealloc(sizeof(*uctx)); - uctx->mech_type = &mech_krb5; - uctx->internal_ctx_id = (gss_ctx_id_t)kgctx; - return (gss_ctx_id_t)uctx; -@@ -138,9 +151,7 @@ make_fake_context(const struct test *test) - krb5_gss_ctx_id_t kgctx; - krb5_keyblock kb; - -- kgctx = calloc(1, sizeof(*kgctx)); -- if (kgctx == NULL) -- abort(); -+ kgctx = ealloc(sizeof(*kgctx)); - kgctx->established = 1; - if (g_seqstate_init(&kgctx->seqstate, 0, 0, 0, 0) != 0) - abort(); -@@ -162,9 +173,7 @@ make_fake_context(const struct test *test) - if (krb5_k_create_key(NULL, &kb, &kgctx->enc) != 0) - abort(); - -- uctx = calloc(1, sizeof(*uctx)); -- if (uctx == NULL) -- abort(); -+ uctx = ealloc(sizeof(*uctx)); - uctx->mech_type = &mech_krb5; - uctx->internal_ctx_id = (gss_ctx_id_t)kgctx; - return (gss_ctx_id_t)uctx; -@@ -194,9 +203,7 @@ make_token(unsigned char *token, size_t len, gss_buffer_t out) - - assert(mech_krb5.length == 9); - assert(len + 11 < 128); -- wrapped = malloc(len + 13); -- if (wrapped == NULL) -- abort(); -+ wrapped = ealloc(len + 13); - wrapped[0] = 0x60; - wrapped[1] = len + 11; - wrapped[2] = 0x06; -@@ -207,6 +214,18 @@ make_token(unsigned char *token, size_t len, gss_buffer_t out) - out->value = wrapped; - } - -+/* Create a 16-byte header for a CFX confidential wrap token to be processed by -+ * the fake CFX context. */ -+static void -+write_cfx_header(uint16_t ec, uint8_t *out) -+{ -+ memset(out, 0, 16); -+ store_16_be(KG2_TOK_WRAP_MSG, out); -+ out[2] = FLAG_WRAP_CONFIDENTIAL; -+ out[3] = 0xFF; -+ store_16_be(ec, out + 4); -+} -+ - /* Unwrap a superficially valid RFC 1964 token with a CFX-only context, with - * regular and IOV unwrap. */ - static void -@@ -238,6 +257,134 @@ test_bogus_1964_token(gss_ctx_id_t ctx) - free(in.value); - } - -+static void -+test_cfx_altered_ec(gss_ctx_id_t ctx, krb5_key subkey) -+{ -+ OM_uint32 major, minor; -+ uint8_t tokbuf[128], plainbuf[24]; -+ krb5_data plain; -+ krb5_enc_data cipher; -+ gss_buffer_desc in, out; -+ gss_iov_buffer_desc iov[2]; -+ -+ /* Construct a header with a plaintext EC value of 3. */ -+ write_cfx_header(3, tokbuf); -+ -+ /* Encrypt a plaintext and a copy of the header with the EC value 0. */ -+ memcpy(plainbuf, "truncate", 8); -+ memcpy(plainbuf + 8, tokbuf, 16); -+ store_16_be(0, plainbuf + 12); -+ plain = make_data(plainbuf, 24); -+ cipher.ciphertext.data = (char *)tokbuf + 16; -+ cipher.ciphertext.length = sizeof(tokbuf) - 16; -+ cipher.enctype = subkey->keyblock.enctype; -+ if (krb5_k_encrypt(NULL, subkey, KG_USAGE_INITIATOR_SEAL, NULL, -+ &plain, &cipher) != 0) -+ abort(); -+ -+ /* Verify that the token is rejected by gss_unwrap(). */ -+ in.value = tokbuf; -+ in.length = 16 + cipher.ciphertext.length; -+ major = gss_unwrap(&minor, ctx, &in, &out, NULL, NULL); -+ if (major != GSS_S_DEFECTIVE_TOKEN) -+ abort(); -+ (void)gss_release_buffer(&minor, &out); -+ -+ /* Verify that the token is rejected by gss_unwrap_iov(). */ -+ iov[0].type = GSS_IOV_BUFFER_TYPE_STREAM; -+ iov[0].buffer = in; -+ iov[1].type = GSS_IOV_BUFFER_TYPE_DATA; -+ major = gss_unwrap_iov(&minor, ctx, NULL, NULL, iov, 2); -+ if (major != GSS_S_DEFECTIVE_TOKEN) -+ abort(); -+} -+ -+static void -+test_cfx_short_plaintext(gss_ctx_id_t ctx, krb5_key subkey) -+{ -+ OM_uint32 major, minor; -+ uint8_t tokbuf[128], zerobyte = 0; -+ krb5_data plain; -+ krb5_enc_data cipher; -+ gss_buffer_desc in, out; -+ -+ write_cfx_header(0, tokbuf); -+ -+ /* Encrypt a single byte, with no copy of the header. */ -+ plain = make_data(&zerobyte, 1); -+ cipher.ciphertext.data = (char *)tokbuf + 16; -+ cipher.ciphertext.length = sizeof(tokbuf) - 16; -+ cipher.enctype = subkey->keyblock.enctype; -+ if (krb5_k_encrypt(NULL, subkey, KG_USAGE_INITIATOR_SEAL, NULL, -+ &plain, &cipher) != 0) -+ abort(); -+ -+ /* Verify that the token is rejected by gss_unwrap(). */ -+ in.value = tokbuf; -+ in.length = 16 + cipher.ciphertext.length; -+ major = gss_unwrap(&minor, ctx, &in, &out, NULL, NULL); -+ if (major != GSS_S_DEFECTIVE_TOKEN) -+ abort(); -+ (void)gss_release_buffer(&minor, &out); -+} -+ -+static void -+test_cfx_large_ec(gss_ctx_id_t ctx, krb5_key subkey) -+{ -+ OM_uint32 major, minor; -+ uint8_t tokbuf[128] = { 0 }, plainbuf[20]; -+ krb5_data plain; -+ krb5_enc_data cipher; -+ gss_buffer_desc in, out; -+ -+ /* Construct a header with an EC value of 5. */ -+ write_cfx_header(5, tokbuf); -+ -+ /* Encrypt a 4-byte plaintext plus the header. */ -+ memcpy(plainbuf, "abcd", 4); -+ memcpy(plainbuf + 4, tokbuf, 16); -+ plain = make_data(plainbuf, 20); -+ cipher.ciphertext.data = (char *)tokbuf + 16; -+ cipher.ciphertext.length = sizeof(tokbuf) - 16; -+ cipher.enctype = subkey->keyblock.enctype; -+ if (krb5_k_encrypt(NULL, subkey, KG_USAGE_INITIATOR_SEAL, NULL, -+ &plain, &cipher) != 0) -+ abort(); -+ -+ /* Verify that the token is rejected by gss_unwrap(). */ -+ in.value = tokbuf; -+ in.length = 16 + cipher.ciphertext.length; -+ major = gss_unwrap(&minor, ctx, &in, &out, NULL, NULL); -+ if (major != GSS_S_DEFECTIVE_TOKEN) -+ abort(); -+ (void)gss_release_buffer(&minor, &out); -+} -+ -+static void -+test_iov_large_asn1_wrapper(gss_ctx_id_t ctx) -+{ -+ OM_uint32 minor, major; -+ uint8_t databuf[10] = { 0 }; -+ gss_iov_buffer_desc iov[2]; -+ -+ /* -+ * In this IOV array, the header contains a DER tag with a dangling eight -+ * bytes of length field. The data IOV indicates a total token length -+ * sufficient to contain the length bytes. -+ */ -+ iov[0].type = GSS_IOV_BUFFER_TYPE_HEADER; -+ iov[0].buffer.value = ealloc(2); -+ iov[0].buffer.length = 2; -+ memcpy(iov[0].buffer.value, "\x60\x88", 2); -+ iov[1].type = GSS_IOV_BUFFER_TYPE_DATA; -+ iov[1].buffer.value = databuf; -+ iov[1].buffer.length = 10; -+ major = gss_unwrap_iov(&minor, ctx, NULL, NULL, iov, 2); -+ if (major != GSS_S_DEFECTIVE_TOKEN) -+ abort(); -+ free(iov[0].buffer.value); -+} -+ - /* Process wrap and MIC tokens with incomplete headers. */ - static void - test_short_header(gss_ctx_id_t ctx) -@@ -387,9 +534,7 @@ try_accept(void *value, size_t len) - gss_ctx_id_t ctx = GSS_C_NO_CONTEXT; - - /* Copy the provided value to make input overruns more obvious. */ -- in.value = malloc(len); -- if (in.value == NULL) -- abort(); -+ in.value = ealloc(len); - memcpy(in.value, value, len); - in.length = len; - (void)gss_accept_sec_context(&minor, &ctx, GSS_C_NO_CREDENTIAL, &in, -@@ -424,11 +569,23 @@ test_short_encapsulation() - int - main(int argc, char **argv) - { -+ krb5_keyblock kb; -+ krb5_key cfx_subkey; - gss_ctx_id_t ctx; - size_t i; - -- ctx = make_fake_cfx_context(); -+ kb.enctype = ENCTYPE_AES128_CTS_HMAC_SHA1_96; -+ kb.length = 16; -+ kb.contents = (unsigned char *)"1234567887654321"; -+ if (krb5_k_create_key(NULL, &kb, &cfx_subkey) != 0) -+ abort(); -+ -+ ctx = make_fake_cfx_context(cfx_subkey); - test_bogus_1964_token(ctx); -+ test_cfx_altered_ec(ctx, cfx_subkey); -+ test_cfx_short_plaintext(ctx, cfx_subkey); -+ test_cfx_large_ec(ctx, cfx_subkey); -+ test_iov_large_asn1_wrapper(ctx); - free_fake_context(ctx); - - for (i = 0; i < sizeof(tests) / sizeof(*tests); i++) { --- -2.33.0 - diff --git a/fix-leak-in-KDC-NDR-encoding.patch b/fix-leak-in-KDC-NDR-encoding.patch deleted file mode 100644 index cca5d25e5fb990e3986c4d276a0be42190c96053..0000000000000000000000000000000000000000 --- a/fix-leak-in-KDC-NDR-encoding.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 0c2de238b5bf1ea4578e3933a604c7850905b8be Mon Sep 17 00:00:00 2001 -From: Greg Hudson -Date: Tue, 5 Mar 2024 17:38:49 -0500 -Subject: [PATCH] Fix leak in KDC NDR encoding - -If the KDC tries to encode a principal containing encode invalid UTF-8 -sequences for inclusion in a PAC delegation info buffer, it will leak -a small amount of memory in enc_wchar_pointer() before failing. Fix -the leak. - -(cherry picked from commit 7d0d85bf99caf60c0afd4dcf91b0c4c683b983fe) - -ticket: 9115 -version_fixed: 1.21.3 - ---- - src/kdc/ndr.c | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -diff --git a/src/kdc/ndr.c b/src/kdc/ndr.c -index 48395ab..d438408 100644 ---- a/src/kdc/ndr.c -+++ b/src/kdc/ndr.c -@@ -96,14 +96,13 @@ enc_wchar_pointer(const char *utf8, struct encoded_wchars *encoded_out) - size_t utf16len, num_wchars; - uint8_t *utf16; - -- k5_buf_init_dynamic(&b); -- - ret = k5_utf8_to_utf16le(utf8, &utf16, &utf16len); - if (ret) - return ret; - - num_wchars = utf16len / 2; - -+ k5_buf_init_dynamic(&b); - k5_buf_add_uint32_le(&b, num_wchars + 1); - k5_buf_add_uint32_le(&b, 0); - k5_buf_add_uint32_le(&b, num_wchars); --- -2.27.0 - diff --git a/kadmin.service b/kadmin.service index ffaf7a1c510220a2c8556e1cc5d1658a9172d074..ff8b210daa5624c2054e1c8579b0a99c2d5e5111 100644 --- a/kadmin.service +++ b/kadmin.service @@ -5,6 +5,17 @@ After=syslog.target network.target network-online.target AssertPathExists=!/var/kerberos/krb5kdc/kpropd.acl [Service] +# https://en.opensuse.org/openSUSE:Security_Features#Systemd_hardening_effort +ProtectSystem=full +ProtectHome=true +PrivateDevices=true +ProtectHostname=true +ProtectClock=true +ProtectKernelTunables=true +ProtectKernelModules=true +ProtectKernelLogs=true +ProtectControlGroups=true +RestrictRealtime=true Type=forking PIDFile=/var/run/kadmind.pid EnvironmentFile=-/etc/sysconfig/kadmin diff --git a/kprop.service b/kprop.service index 0cf89aeee1a4e7dc830d6313379f60a7198259e2..1a5c41afb5b6aaaa0471d34116a568e4f0dbc3f7 100644 --- a/kprop.service +++ b/kprop.service @@ -5,6 +5,17 @@ After=syslog.target network.target network-online.target AssertPathExists=/var/kerberos/krb5kdc/kpropd.acl [Service] +# https://en.opensuse.org/openSUSE:Security_Features#Systemd_hardening_effort +ProtectSystem=full +ProtectHome=true +PrivateDevices=true +ProtectHostname=true +ProtectClock=true +ProtectKernelTunables=true +ProtectKernelModules=true +ProtectKernelLogs=true +ProtectControlGroups=true +RestrictRealtime=true Type=forking EnvironmentFile=-/etc/sysconfig/kprop ExecStart=/usr/sbin/kpropd diff --git a/krb5-1.21.2.tar.gz.asc b/krb5-1.21.2.tar.gz.asc deleted file mode 100644 index e4a3f6dd527540fcc429c2eba8990892f5f4ee5b..0000000000000000000000000000000000000000 --- a/krb5-1.21.2.tar.gz.asc +++ /dev/null @@ -1,16 +0,0 @@ ------BEGIN PGP SIGNATURE----- - -iQIzBAABCgAdFiEExEk8tzn0qJ+YUsvCDLoIV1+Dct8FAmTbET4ACgkQDLoIV1+D -ct8zBQ/+LugwKy9Y9b3lVaLxPM/qxntLi4Bq5C2GVQ+bED7YCvUiL8aIzJbuTVpf -GLWLtVuf6vxKz2V17JKOluVMqRDBZDexHZv9EvVjhanqMpvV32tSa60HF4e7lER+ -3iP/bIjSi2U9ixOcNICNnK2DeFGY601C1KT4cLs3H76pfb1miPItm7p79UNicz1o -V6KgG0J5F4ktYiTonb0TXYdCAvY/3ROEYwmmRpCjtkBCzTdr9tVXU0n6Yc0wsfBD -AXkyqlUhisMWxqGrLZMnkIx3LA83nMHG8nY/doqOYzKuE9a4cBe69+Bl6e9NRY7G -ysD2J1cZ2imCYoalUcxrLfnd3fwPpcrlnuwH5DKJtcJGEUNwydjyWZeMl87pbhb1 -lOggcn8DL6l3vqBpkTBE4IQw3s+B1+BylpjXBsvzxGYHerpffIqsHzHywguiJutT -bkP5ktjZ0QHAZ6PYA6NleGjPbBg/Jeywg1Mjrx+2IdBAYnS0KtTSa72Zqqb8eGmQ -iCVpy9gK7zX7UCLm33M6HVtC9ffJ4vajcShk25u8uKuomTQgK3lGoN0wX55OE+sO -AkMSuFxPNsNheMI53Zjutc4NzEscy09G8VxHwGqcEwD+NF7+2GpPuOq9ot9nH+Jd -xoVYjhqxeb5Uq6lgp0B8sILLqwg1+gEXWdA+rR5Tx+ykv8HESxg= -=aMVp ------END PGP SIGNATURE----- diff --git a/krb5-1.21.2.tar.gz b/krb5-1.21.3.tar.gz similarity index 51% rename from krb5-1.21.2.tar.gz rename to krb5-1.21.3.tar.gz index e454cd55a1a0d154c572e12e3a3b4f83015f0f97..6c964377dd09bf980daaf5b63eee79930d1cf1b0 100644 Binary files a/krb5-1.21.2.tar.gz and b/krb5-1.21.3.tar.gz differ diff --git a/krb5-1.21.3.tar.gz.asc b/krb5-1.21.3.tar.gz.asc new file mode 100644 index 0000000000000000000000000000000000000000..b7201355f3917226ef745864d2f8ded4b116e2c1 --- /dev/null +++ b/krb5-1.21.3.tar.gz.asc @@ -0,0 +1,16 @@ +-----BEGIN PGP SIGNATURE----- + +iQIzBAABCgAdFiEExEk8tzn0qJ+YUsvCDLoIV1+Dct8FAmZ8eHkACgkQDLoIV1+D +ct//gw//bmvy6zXbKL6epNaExVgRdqzfQWm6WqeyGNxg59BQyJwsRsArsQRbSTZl +uUExbV4HDTI/SemnYT8MfNOUtGZBCcAMYUr79Zmwi9S2pc30ZHIGcOf5E7HvIj6y +ZZUvddoxWvxpruCuJHb9dP4ZUPE0iU2rJnLsXR/H4E574WlrWBjXu3gimLen7+yg +aCLxIvw6lk4f/X8l+aqbK+haWHwMnca+kWSPbmL2iblHVqmoJVEmWhy7/9WjiT5S +5HhDJIObO2qn1pbE1ZTQqfGOfFgOUVxTl2myMxX1RXEDVFzdLDdnoUJRt4o4GG27 +Y0WfLtmN6NisVF91dkl2+F7js+xVI3m9uZnpeccKO2Uq6BQRrfOMWUAHVKMUJZjh +h0GMeTzOhw7qGKitAiuhauyDMMTgMx78bC0DpLYtq24fp7BSvD0jNZnfjUXVCk8D +al9cfxC5m843aKiJ01Of13PziZsTQFz/TUsOrcpx4h7+qY7nldrovkQBiyVbbtn4 +MncYq8d84G/0vsbJ/6ftJ6Y+OL20jyzfC5xgmKtK/y1D987aum2BSudISUCylOOt +j5/KiTRe0rWUjBNtoCjrtw4xlSbygmjuiE/xtcow0CHXDtMjlo8PrDi8W+xccBv2 +zQ2B+e9ywkF4uC/M91s/bVSMkOtxv2JCoUUHOMF4ku5vzKSOhyk= +=TH0A +-----END PGP SIGNATURE----- diff --git a/krb5.spec b/krb5.spec index d0040b71c234446ea6cba118d7e75a52112024c8..97119801280787f6392a31fded323b627743a134 100644 --- a/krb5.spec +++ b/krb5.spec @@ -2,8 +2,8 @@ %global WITH_DIRSRV 1 Name: krb5 -Version: 1.21.2 -Release: 13 +Version: 1.21.3 +Release: 1 Summary: The Kerberos network authentication protocol License: MIT URL: http://web.mit.edu/kerberos/www/ @@ -26,17 +26,14 @@ Patch2: Adjust-build-configuration.patch Patch3: netlib-and-dns.patch Patch4: fix-debuginfo-with-y.tab.c.patch Patch5: Remove-3des-support.patch -Patch6: Fix-krb5_cccol_have_content-bad-pointer-free.patch Patch7: Do-not-reload-a-modified-profile-data-object.patch Patch8: backport-Fix-unimportant-memory-leaks.patch Patch9: backport-Remove-klist-s-defname-global-variable.patch Patch10: backport-Fix-two-unlikely-memory-leaks.patch Patch11: backport-Allow-modifications-of-empty-profiles.patch -Patch12: fix-leak-in-KDC-NDR-encoding.patch Patch13: backport-Fix-more-non-prototype-functions.patch Patch14: backport-Fix-Python-regexp-literals.patch Patch15: backport-Handle-empty-initial-buffer-in-IAKERB-initiator.patch -Patch16: backport-CVE-2024-37370-CVE-2024-37371-Fix-vulnerabilities-in-GSS-message-token-handling.patch Patch17: backport-Change-krb5_get_credentials-endtime-behavior.patch Patch18: backport-Fix-memory-leak-in-PAC-checksum-verification.patch Patch19: fix-libkadm5-parameter-leak.patch @@ -332,6 +329,10 @@ make -C src check || : %{_mandir}/man8/* %changelog +* Sat Dec 07 2024 Funda Wang - 1.21.3-1 +- update to 1.21.3 +- harden systemd services based on openSUSE + * Wed Dec 04 2024 wangjiang - 1.21.2-13 - backport upstream patches diff --git a/krb5.yaml b/krb5.yaml index d4a87f43990b6b9768a08c133530b5c057a9a5a5..143eb916d1815fa79fc6f7524a2f5e681ac3edae 100644 --- a/krb5.yaml +++ b/krb5.yaml @@ -1,4 +1,4 @@ version_control: github src_repo: krb5/krb5 tag_prefix: ^krb5- -seperator: . +separator: . diff --git a/krb5kdc.service b/krb5kdc.service index 3dd3c707da803a28b07477f8f938192cd823d61f..af41e8fb1f086476e9143e17d6da1a36b3dde963 100644 --- a/krb5kdc.service +++ b/krb5kdc.service @@ -4,6 +4,17 @@ Wants=network-online.target After=syslog.target network.target network-online.target [Service] +# https://en.opensuse.org/openSUSE:Security_Features#Systemd_hardening_effort +ProtectSystem=full +ProtectHome=true +PrivateDevices=true +ProtectHostname=true +ProtectClock=true +ProtectKernelTunables=true +ProtectKernelModules=true +ProtectKernelLogs=true +ProtectControlGroups=true +RestrictRealtime=true Type=forking PIDFile=/var/run/krb5kdc.pid EnvironmentFile=-/etc/sysconfig/krb5kdc