CVE-2026-14612: ipa-otpd/oauth2: fix memory safety and error handling…#8473
Open
abbra wants to merge 1 commit into
Open
CVE-2026-14612: ipa-otpd/oauth2: fix memory safety and error handling…#8473abbra wants to merge 1 commit into
abbra wants to merge 1 commit into
Conversation
rjeffman
reviewed
Jul 3, 2026
rjeffman
left a comment
Member
There was a problem hiding this comment.
Overall, looks good to me, but I have just one question before ack-ing.
carma12
reviewed
Jul 6, 2026
… 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>
rjeffman
reviewed
Jul 8, 2026
Comment on lines
+588
to
+589
| kill(child_pid, SIGKILL); | ||
| waitpid(child_pid, NULL, 0); |
Member
There was a problem hiding this comment.
This is the only place where kill+waitpid is used in the new code before goto done;. Shouldn't the kill+waitpid idiom be used before goto done for every exit path after creating the child fork to prevent zombies?
(Playing by rusted memory here - pun intended - as I haven't fork-ed anything in many, many years.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
… 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
Summary by Sourcery
Harden the OAuth2 device code flow in ipa-otpd by fixing memory safety issues, improving error handling, and tightening child process I/O handling and logging.
Bug Fixes:
Enhancements: