Skip to content

[builders] Patch librdkafka use-after-free in admin coord_request error path#23240

Open
piochelepiotr wants to merge 1 commit intomasterfrom
piotr.wolski/librdkafka-coord-request-uaf-fix
Open

[builders] Patch librdkafka use-after-free in admin coord_request error path#23240
piochelepiotr wants to merge 1 commit intomasterfrom
piotr.wolski/librdkafka-coord-request-uaf-fix

Conversation

@piochelepiotr
Copy link
Copy Markdown
Contributor

Summary

  • Apply upstream fix (confluentinc/librdkafka#5397) as a build-time patch for Linux x86_64 and aarch64
  • Fixes a use-after-free bug in rd_kafka_admin_coord_request() that causes process abort with rd_kafka_enq_once_del_source_return: Assertion 'eonce->refcnt > 0' failed
  • Affects coordinator-targeted Admin API operations: DescribeConsumerGroups, DeleteConsumerGroupOffsets, ListConsumerGroupOffsets, etc.

Motivation

The bug triggers when a coordinator-targeted admin request fails to send (API version mismatch or connection disruption). The error path prematurely frees the eonce object while the caller still holds a reference, leading to use-after-free and assertion failure.

This is not yet included in a released librdkafka version, so we apply it as a patch during the build using the existing install-from-source.sh PATCHES mechanism.

Changes

Test plan

  • Verify Linux x86_64 builder applies the patch and compiles librdkafka successfully
  • Verify Linux aarch64 builder applies the patch and compiles librdkafka successfully
  • Confirm kafka_consumer integration tests pass

🤖 Generated with Claude Code

…or path

Apply upstream fix (confluentinc/librdkafka#5397) for a use-after-free
bug in rd_kafka_admin_coord_request() that causes process abort with
assertion failure on eonce->refcnt. Affects DescribeConsumerGroups,
DeleteConsumerGroupOffsets, ListConsumerGroupOffsets and similar
coordinator-targeted Admin API operations.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

⚠️ Recommendation: Add qa/skip-qa label

This PR does not modify any files shipped with the agent.

To help streamline the release process, please consider adding the qa/skip-qa label if these changes do not require QA testing.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1480f74f91

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

VERSION="${kafka_version}" \
SHA256="14972092e4115f6e99f798a7cb420cbf6daa0c73502b3c52ae42fb5b418eea8f" \
RELATIVE_PATH="librdkafka-{{version}}" \
PATCHES="librdkafka-fix-coord-request-uaf.patch" \
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Apply coordinator UAF patch to all librdkafka builders

This change only wires PATCHES="librdkafka-fix-coord-request-uaf.patch" into the Linux builders, but the same librdkafka source/version is also built in macOS (.builders/images/macos/extra_build.sh) and Windows (.builders/images/windows-x86_64/build_script.ps1). Because the use-after-free is in shared C code, those platform wheels remain vulnerable to the same coordinator-request crash path (send failure followed by rd_kafka_enq_once_del_source_return assertion), so the fix is incomplete unless those builders are patched as well.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It's a pretty rare bug. So going to fix macos via the official librdkafka library release. Doing linux now because it has immediate impact.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant