- 
  Notifications
 
You must be signed in to change notification settings  - Fork 934
 
Handle null group name to prevent segfault in Admin list_consumer_group_offsets() #2118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🎉 All Contributor License Agreements have been signed. Ready to merge. 
Please push an empty commit if you would like to re-run the checks to verify CLA status for all contributors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds defensive NULL checking to prevent a segmentation fault when rd_kafka_group_result_name() returns NULL during error conditions in the list_consumer_group_offsets() admin operation.
Key Changes:
- Added NULL pointer validation for group names returned by librdkafka before passing to Python string conversion functions
 - Proper error handling with resource cleanup (DECREF) when NULL is encountered
 
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
 
 
 
 Copilot
AI
 
 
 
 Oct 31, 2025 
 
 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message 'Received NULL group name from librdkafka' doesn't provide actionable information to users. Consider including guidance such as 'Internal error: received NULL group name from librdkafka. This may indicate a broker communication failure or coordinator unavailability.'
 
 
 src/confluent_kafka/src/Admin.c
 
 Outdated
 
 
 
 
 
 
 Copilot
AI
 
 
 
 Oct 31, 2025 
 
 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using RD_KAFKA_RESP_ERR__INVALID_ARG may be misleading since this is an internal/unexpected error rather than invalid user input. Consider using RD_KAFKA_RESP_ERR__FAIL or RD_KAFKA_RESP_ERR__STATE to better represent an internal error condition.
Quality Gate passed Quality Gate passed
Issues
 0 New issues 
 0 Accepted issues 
Measures
 0 Security Hotspots 
 0.0% Coverage on New Code 
 0.0% Duplication on New Code 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
What
Problem
User reported a segmentation fault when calling
list_consumer_group_offsets()on non-existing consumer groups in v2.10.0. The process crashed instead of raising an exception.Investigation
Normal behavior verified: When calling
list_consumer_group_offsets()on a non-existing group, the API successfully returns an empty list (confluent-kafka-python/src/confluent_kafka/src/Admin.c
Line 5011 in 06c0744
Why the segfault occur (theory): Since the normal "non-existing group" path works correctly, the crash must occur in error scenarios where librdkafka encounters internal failures. Through code analysis, we identified a vulnerability: the C binding passes
rd_kafka_group_result_name()directly toPyUnicode_FromString()without NULL checking (confluent-kafka-python/src/confluent_kafka/src/Admin.c
Line 4539 in 06c0744
rd_kafka_group_result_name()returns NULL (possible in edge cases like network timeouts, coordinator unavailability, broker communication failures, or race conditions in error handling), this causes a NULL pointer dereference inPyUnicode_FromString(), resulting in SIGSEGV.Solution
In
Admin_c_SingleGroupResult_to_py(), add defensive check for NULL group_name.Checklist
References
JIRA: https://confluentinc.atlassian.net/browse/NONJAVACLI-4100
Issue: #1982
Test & Review
Open questions / Follow-ups