public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/freeipa] f44: Backport upstream fixes
@ 2026-10-01 17:51 Alexander Bokovoy
0 siblings, 0 replies; only message in thread
From: Alexander Bokovoy @ 2026-10-01 17:51 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/freeipa
Branch : f44
Commit : a4d4a62446af173f6bb3769d129ae64250b4c092
Author : Alexander Bokovoy <abokovoy@redhat.com>
Date : 2026-10-01T20:13:39+03:00
Stats : +361/-1 in 4 file(s)
URL : https://src.fedoraproject.org/rpms/freeipa/c/a4d4a62446af173f6bb3769d129ae64250b4c092?branch=f44
Log:
Backport upstream fixes
- Fixes: CVE-2026-14612 - potential buffer overflow in ipa-otpd
- Fix potential buffer overvlow in ipa-join
- Fix potential NUL pointer dereference in ipa-kdb
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
---
diff --git a/freeipa-CVE-2026-14612.patch b/freeipa-CVE-2026-14612.patch
new file mode 100644
index 0000000..6ead66b
--- /dev/null
+++ b/freeipa-CVE-2026-14612.patch
@@ -0,0 +1,285 @@
+From 59b6b7c4ae0307c37c6636a6e44ba5c2a8929571 Mon Sep 17 00:00:00 2001
+From: Alexander Bokovoy <abokovoy@redhat.com>
+Date: Fri, 3 Jul 2026 18:38:27 +0300
+Subject: [PATCH] CVE-2026-14612: ipa-otpd/oauth2: fix memory safety and error
+ handling bugs
+
+Fix several pre-existing bugs in the OAuth2 device code flow:
+
+- Use-after-free: otpd_queue_item_free() was called before the retry
+ check in oauth2_on_child_writable(). On EAGAIN, the freed saved_item
+ would be dereferenced on the next callback invocation.
+
+- CVE-2026-14612: buffer overflow: read() into a 10240-byte buffer could
+ return exactly 10240 bytes, causing buf[10240]='\0' to write past the
+ end. Use sizeof(buf)-1 instead.
+
+- Memory leaks: saved_item was leaked on strndup failure and on
+ child_ctx allocation failure. The done: label now cleans up
+ saved_item, pipe fds, and child_ctx on error paths.
+
+- NULL dereference: ipaidpSub was dereferenced without a NULL check in
+ check_access_token_reply().
+
+- verto_add_child() return was not checked for NULL, leading to a NULL
+ dereference on verto_set_private().
+
+- set_fd_nonblocking() return values were silently ignored; a failure
+ would leave pipes in blocking mode, hanging the daemon.
+
+- Off-by-one in memchr length calculation for second newline.
+
+- Avoid logging full oidc_child output (may contain tokens); log byte
+ count instead.
+
+- Fix error message for reader event (was copy-pasted as "writer").
+
+- Fix uninitialized loop variable in disabled debug block.
+
+Fixes: CVE-2026-14612
+Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
+Reviewed-By: Rafael Guterres Jeffman <rjeffman@redhat.com>
+Reviewed-By: David Hanina <dhanina@redhat.com>
+Reviewed-By: Carla Martinez <carlmart@redhat.com>
+---
+ daemons/ipa-otpd/oauth2.c | 95 ++++++++++++++++++++++++++++++++-------
+ 1 file changed, 80 insertions(+), 15 deletions(-)
+
+diff --git a/daemons/ipa-otpd/oauth2.c b/daemons/ipa-otpd/oauth2.c
+index 0eb43b237..1fb07141a 100644
+--- a/daemons/ipa-otpd/oauth2.c
++++ b/daemons/ipa-otpd/oauth2.c
+@@ -31,7 +31,10 @@
+ #include <unistd.h>
+ #include <fcntl.h>
+ #include <sys/random.h>
++#include <signal.h>
++#include <string.h>
+ #include <sys/uio.h>
++#include <sys/wait.h>
+
+ #include "internal.h"
+
+@@ -125,8 +128,6 @@ static void oauth2_on_child_writable(verto_ctx *vctx, verto_ev *ev)
+ idx++;
+ io = writev(verto_get_fd(ev), iov, idx);
+ }
+- otpd_queue_item_free(child_ctx->saved_item);
+-
+ if (io < 0) {
+ switch (errno) {
+ #if defined(EWOULDBLOCK) && (!defined(EAGAIN) || EAGAIN - EWOULDBLOCK != 0)
+@@ -146,6 +147,14 @@ static void oauth2_on_child_writable(verto_ctx *vctx, verto_ev *ev)
+ otpd_log_err(errno, "Failed to send to child");
+ }
+
++ if (child_ctx->item->idp.ipaidpClientSecret != NULL) {
++ explicit_bzero(child_ctx->item->idp.ipaidpClientSecret,
++ strlen(child_ctx->item->idp.ipaidpClientSecret));
++ }
++ if (child_ctx->saved_item != NULL) {
++ otpd_queue_item_free(child_ctx->saved_item);
++ child_ctx->saved_item = NULL;
++ }
+ verto_del(ev);
+ }
+
+@@ -173,6 +182,7 @@ static int handle_device_code_reply(struct child_ctx *child_ctx,
+
+ state_item->oauth2.device_code_reply = strdup(dc_reply);
+ if (state_item->oauth2.device_code_reply == NULL) {
++ ret = ENOMEM;
+ otpd_log_req(child_ctx->item->req, "Failed to copy device code reply.");
+ goto done;
+ }
+@@ -188,6 +198,7 @@ static int handle_device_code_reply(struct child_ctx *child_ctx,
+
+ state_item->oauth2.state.data = strdup(dc_reply);
+ if (state_item->oauth2.state.data == NULL) {
++ ret = ENOMEM;
+ otpd_log_req(child_ctx->item->req,
+ "Failed to copy device code reply to krad.");
+ goto done;
+@@ -242,6 +253,12 @@ static int check_access_token_reply(struct child_ctx *child_ctx,
+ {
+ int ret;
+
++ if (child_ctx->item->user.ipaidpSub == NULL) {
++ otpd_log_req(child_ctx->item->req,
++ "Missing ipaidpSub for access token verification");
++ return EPERM;
++ }
++
+ if (strlen(child_ctx->item->user.ipaidpSub) != len
+ || memcmp(child_ctx->item->user.ipaidpSub, buf, len) != 0) {
+ return EPERM;
+@@ -279,17 +296,22 @@ static void oauth2_on_child_readable(verto_ctx *vctx, verto_ev *ev)
+ child_ctx->item->rsp = NULL;
+ child_ctx->item->sent = 0;
+
+- io = read(verto_get_fd(ev), buf, 10240);
++ io = read(verto_get_fd(ev), buf, sizeof(buf) - 1);
+ if (io < 0) {
+ otpd_log_err(errno, "Failed to read from child");
+ goto done;
+ }
+
+- if (io >= 0) {
+- buf[io] = '\0';
+- otpd_log_req(child_ctx->item->req, "Received: [%s]", buf);
++ if (io == 0) {
++ otpd_log_req(child_ctx->item->req,
++ "oidc_child closed stdout without producing output");
++ verto_del(ev);
++ goto done;
+ }
+
++ buf[io] = '\0';
++ otpd_log_req(child_ctx->item->req, "Received: [%zu bytes]", (size_t)io);
++
+ verto_del(ev);
+
+ if (child_ctx->oauth2_state == OAUTH2_GET_DEVICE_CODE) {
+@@ -302,7 +324,7 @@ static void oauth2_on_child_readable(verto_ctx *vctx, verto_ev *ev)
+ if (rad_reply != NULL) {
+ *rad_reply = '\0';
+ rad_reply++;
+- end = memchr(rad_reply, '\n', io - (rad_reply - 1 - buf));
++ end = memchr(rad_reply, '\n', io - (rad_reply - buf));
+ if (end == NULL) {
+ otpd_log_req(child_ctx->item->req, "Missing second new-line.");
+ goto done;
+@@ -328,6 +350,7 @@ static void oauth2_on_child_readable(verto_ctx *vctx, verto_ev *ev)
+ }
+
+ done:
++ explicit_bzero(buf, sizeof(buf));
+ otpd_queue_push(&ctx.stdio.responses, child_ctx->item);
+ verto_set_flags(ctx.stdio.writer, VERTO_EV_FLAG_PERSIST |
+ VERTO_EV_FLAG_IO_ERROR |
+@@ -387,16 +410,20 @@ int oauth2(struct otpd_queue_item **item, enum oauth2_state oauth2_state)
+
+ saved_item = calloc(sizeof(struct otpd_queue_item), 1);
+ if (saved_item == NULL) {
+- otpd_log_req((*item)->req, "No matching saved state found");
+- return EINVAL;
++ otpd_log_req((*item)->req,
++ "Failed to allocate saved state item");
++ krb5_free_data_contents(NULL, &data_state);
++ return ENOMEM;
+ }
+ saved_item->oauth2.device_code_reply = strndup(data_state.data,
+ data_state.length);
++ krb5_free_data_contents(NULL, &data_state);
+ if (saved_item->oauth2.device_code_reply == NULL) {
+ otpd_log_req((*item)->req, "Failed to copy device code reply");
+- return EINVAL;
++ free(saved_item);
++ saved_item = NULL;
++ return ENOMEM;
+ }
+- krb5_free_data_contents(NULL, &data_state);
+ }
+
+ child_ctx = calloc(sizeof(struct child_ctx), 1);
+@@ -406,6 +433,7 @@ int oauth2(struct otpd_queue_item **item, enum oauth2_state oauth2_state)
+ }
+ child_ctx->item = (*item);
+ child_ctx->saved_item = saved_item;
++ saved_item = NULL; /* ownership transferred to child_ctx */
+ child_ctx->oauth2_state = oauth2_state;
+
+ otpd_log_req((*item)->req, "oauth2 start: %s",
+@@ -466,7 +494,7 @@ int oauth2(struct otpd_queue_item **item, enum oauth2_state oauth2_state)
+ }
+
+ #if 0
+- for (int i; args[i]; i++) {
++ for (int i = 0; args[i]; i++) {
+ otpd_log_req((*item)->req, "oidc_child exec: %s", args[i]);
+ }
+ #endif
+@@ -501,11 +529,21 @@ int oauth2(struct otpd_queue_item **item, enum oauth2_state oauth2_state)
+ exit(EXIT_FAILURE);
+ } else if (child_pid > 0) { /* parent */
+ close(pipefd_to_child[0]);
+- set_fd_nonblocking(pipefd_to_child[1]);
++ pipefd_to_child[0] = -1;
++ ret = set_fd_nonblocking(pipefd_to_child[1]);
++ if (ret != 0) {
++ otpd_log_err(ret, "Failed to set write pipe non-blocking");
++ goto done;
++ }
+ child_ctx->write_to_child = pipefd_to_child[1];
+
+ close(pipefd_from_child[1]);
+- set_fd_nonblocking(pipefd_from_child[0]);
++ pipefd_from_child[1] = -1;
++ ret = set_fd_nonblocking(pipefd_from_child[0]);
++ if (ret != 0) {
++ otpd_log_err(ret, "Failed to set read pipe non-blocking");
++ goto done;
++ }
+ child_ctx->read_from_child = pipefd_from_child[0];
+
+ child_ctx->write_ev = verto_add_io(ctx.vctx, VERTO_EV_FLAG_PERSIST |
+@@ -519,6 +557,8 @@ int oauth2(struct otpd_queue_item **item, enum oauth2_state oauth2_state)
+ otpd_log_err(ret, "Unable to initialize oauth2 writer event");
+ goto done;
+ }
++ /* verto owns the fd now (IO_CLOSE_FD) */
++ pipefd_to_child[1] = -1;
+ verto_set_private(child_ctx->write_ev, child_ctx, NULL);
+
+ child_ctx->read_ev = verto_add_io(ctx.vctx, VERTO_EV_FLAG_PERSIST |
+@@ -529,14 +569,29 @@ int oauth2(struct otpd_queue_item **item, enum oauth2_state oauth2_state)
+ child_ctx->read_from_child);
+ if (child_ctx->read_ev == NULL) {
+ ret = ENOMEM;
+- otpd_log_err(ret, "Unable to initialize oauth2 writer event");
++ otpd_log_err(ret, "Unable to initialize oauth2 reader event");
++ verto_del(child_ctx->write_ev);
++ child_ctx->write_ev = NULL;
+ goto done;
+ }
++ /* verto owns the fd now (IO_CLOSE_FD) */
++ pipefd_from_child[0] = -1;
+ verto_set_private(child_ctx->read_ev, child_ctx, NULL);
+
+ child_ctx->child_ev = verto_add_child(ctx.vctx, VERTO_EV_FLAG_NONE,
+ oauth2_on_child_exit, child_pid);
++ if (child_ctx->child_ev == NULL) {
++ ret = ENOMEM;
++ otpd_log_err(ret, "Unable to initialize oauth2 child event");
++ verto_del(child_ctx->read_ev);
++ verto_del(child_ctx->write_ev);
++ kill(child_pid, SIGKILL);
++ waitpid(child_pid, NULL, 0);
++ goto done;
++ }
+ verto_set_private(child_ctx->child_ev, child_ctx, free_child_ctx);
++ /* child_ctx is now owned by verto via free_child_ctx */
++ child_ctx = NULL;
+
+ } else { /* error */
+ ret = errno;
+@@ -548,6 +603,16 @@ int oauth2(struct otpd_queue_item **item, enum oauth2_state oauth2_state)
+ done:
+ if (ret == 0) {
+ *item = NULL;
++ } else {
++ if (saved_item != NULL) {
++ free(saved_item->oauth2.device_code_reply);
++ free(saved_item);
++ }
++ if (pipefd_to_child[0] >= 0) close(pipefd_to_child[0]);
++ if (pipefd_to_child[1] >= 0) close(pipefd_to_child[1]);
++ if (pipefd_from_child[0] >= 0) close(pipefd_from_child[0]);
++ if (pipefd_from_child[1] >= 0) close(pipefd_from_child[1]);
++ free(child_ctx);
+ }
+
+ return ret;
+--
+2.55.0
+
diff --git a/freeipa-ipa-join-increase-argv-array-suze-for-ipa-getkeytab.patch b/freeipa-ipa-join-increase-argv-array-suze-for-ipa-getkeytab.patch
new file mode 100644
index 0000000..2624766
--- /dev/null
+++ b/freeipa-ipa-join-increase-argv-array-suze-for-ipa-getkeytab.patch
@@ -0,0 +1,31 @@
+From 8ef907327b569b3cc9c782881ee95de8ef7b180c Mon Sep 17 00:00:00 2001
+From: David Hanina <dhanina@redhat.com>
+Date: Mon, 31 Aug 2026 14:43:32 +0200
+Subject: [PATCH] ipa-join: increase argv array size for ipa-getkeytab
+
+Make room for an additional argument by enlarging the argv array
+from 12 to 13 elements.
+
+Fixes: https://codeberg.org/freeipa/freeipa/issues/10044
+Signed-off-by: David Hanina <dhanina@redhat.com>
+Reviewed-By: Sudhir Menon <sumenon@redhat.com>
+---
+ client/ipa-join.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/client/ipa-join.c b/client/ipa-join.c
+index a8d4a82cc..7c16919a4 100644
+--- a/client/ipa-join.c
++++ b/client/ipa-join.c
+@@ -1196,7 +1196,7 @@ join(const char *server, const char *hostname, const char *bindpw, const char *b
+ }
+
+ if (childpid == 0) {
+- char *argv[12];
++ char *argv[13];
+ char *path = "/usr/sbin/ipa-getkeytab";
+ int arg = 0;
+ int err;
+--
+2.55.0
+
diff --git a/freeipa-ipa-kdb-fix-NULL-pointer-dereference-when-freeing-cr.patch b/freeipa-ipa-kdb-fix-NULL-pointer-dereference-when-freeing-cr.patch
new file mode 100644
index 0000000..3713bdd
--- /dev/null
+++ b/freeipa-ipa-kdb-fix-NULL-pointer-dereference-when-freeing-cr.patch
@@ -0,0 +1,36 @@
+From dbe1e198b9fc15727599d9ac1409ef00240e98be Mon Sep 17 00:00:00 2001
+From: David Hanina <dhanina@redhat.com>
+Date: Mon, 31 Aug 2026 14:43:16 +0200
+Subject: [PATCH] ipa-kdb: fix NULL pointer dereference when freeing credential
+ type values
+
+Guard the loop that frees individual `cvals` entries with a NULL check
+before dereferencing the array.
+
+Fixes: https://codeberg.org/freeipa/freeipa/issues/10045
+Signed-off-by: David Hanina <dhanina@redhat.com>
+Reviewed-By: Sudhir Menon <sumenon@redhat.com>
+---
+ daemons/ipa-kdb/ipa_kdb.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/daemons/ipa-kdb/ipa_kdb.c b/daemons/ipa-kdb/ipa_kdb.c
+index 531ee223e..36be5e5a2 100644
+--- a/daemons/ipa-kdb/ipa_kdb.c
++++ b/daemons/ipa-kdb/ipa_kdb.c
+@@ -437,8 +437,10 @@ int ipadb_get_enc_salt_types(struct ipadb_context *ipactx,
+
+ done:
+ ldap_value_free_len(vals);
+- for (i = 0; i < c && cvals[i]; i++) {
+- free(cvals[i]);
++ if (cvals) {
++ for (i = 0; i < c && cvals[i]; i++) {
++ free(cvals[i]);
++ }
+ }
+ free(cvals);
+ return ret;
+--
+2.55.0
+
diff --git a/freeipa.spec b/freeipa.spec
index e1d54a6..7f2636e 100644
--- a/freeipa.spec
+++ b/freeipa.spec
@@ -211,7 +211,7 @@
Name: %{package_name}
Version: %{IPA_VERSION}
-Release: 2%{?rc_version:.%rc_version}%{?dist}
+Release: 3%{?rc_version:.%rc_version}%{?dist}
Summary: The Identity, Policy and Audit system
License: GPL-3.0-or-later
@@ -237,6 +237,9 @@ Source2: gpgkey-B40A78FBA576C4A3FC7D7BBC359FAF777296F653.asc
Patch0: freeipa-version-upgrade-fedora-only.patch
Patch1: freeipa-pr-8557.patch
Patch2: freeipa-pr-8558.patch
+Patch3: freeipa-CVE-2026-14612.patch
+Patch4: freeipa-ipa-join-increase-argv-array-suze-for-ipa-getkeytab.patch
+Patch5: freeipa-ipa-kdb-fix-NULL-pointer-dereference-when-freeing-cr.patch
# RHEL spec file only: START: Change branding to IPA and Identity Management
# Moved branding logos and background to redhat-logos-ipa-80.4:
@@ -1976,6 +1979,11 @@ fi
%endif
%changelog
+* Thu Oct 01 2026 Alexander Bokovoy <abokovoy@redhat.com> - 4.13.4-3
+- Fixes: CVE-2026-14612 - potential buffer overflow in ipa-otpd
+- Fix potential buffer overvlow in ipa-join
+- Fix potential NUL pointer dereference in ipa-kdb
+
* Sat Sep 19 2026 Alexander Bokovoy <abokovoy@redhat.com> - 4.13.4-2
- Update post-4.13.4-release patches
- Rebuild against Samba 4.25.0-RC2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-01 17:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-01 17:51 [rpms/freeipa] f44: Backport upstream fixes Alexander Bokovoy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox