CVE-2026-10143
A large SCRAM iteration count from a broker can freeze kafka-python clients.
- CVSS 8.7
- CWE-400
- Resource Management
- Remote
kafka-python prior to 2.3.2 contains a denial-of-service vulnerability in SCRAM authentication handling that allows a malicious or machine-in-the-middle broker to freeze the client event loop by supplying an excessively large iteration count. In scram.py, ScramClient.process_server_first_message() passes the broker-controlled SCRAM iteration count directly to hashlib.pbkdf2_hmac() without validation, blocking producer sends, consumer polls, admin operations, and heartbeats, which can cause consumer group eviction and repeated reconnect failures.
- CWE
- CWE-400
- CVSS base score
- 8.7
- Published
- 2026-06-10
- OWASP
- A04 Insecure Design
- Orthogonal defect classification
- Checking
- Code defect classification
- Missing Check
- Category
- Resource Management
- Subcategory
- Resource Exhaustion
- Accessibility scope
- Remote
- Impact
- Denial of Service (DoS)
- Affected component
- kafka-python
- Fixed by upgrading
- Yes
Solution
Upgrade `kafka-python` to version 2.3.2 or later.
Vulnerable code sample
import hashlib
import base64
def vulnerable_scram_processing(server_first_message, password, hash_name):
"""
This function represents the vulnerable logic from kafka.sasl.scram.py
in versions prior to the fix. It is a simplified example showing the
core of the vulnerability.
"""
# In a real scenario, this message is received from the Kafka broker.
# Example: 'r=...,s=...,i=4096'
parts = {p[0]: p[2:] for p in server_first_message.split(',')}
salt = base64.b64decode(parts.get('s'))
# THE VULNERABILITY IS HERE:
# The iteration count 'i' is read from the broker-controlled message
# and converted to an integer without any validation to check if it is
# an excessively large number.
iterations = int(parts.get('i'))
# This call to pbkdf2_hmac uses the unvalidated iteration count.
# If a malicious broker provides a very large number (e.g., 500,000,000),
# this function will block for a very long time, freezing the client
# and causing a Denial of Service.
salted_password = hashlib.pbkdf2_hmac(
hash_name,
password.encode('utf-8'),
salt,
iterations
)
return salted_passwordPatched code sample
import hashlib
# This code represents the fix for CVE-2023-25194 (mislabeled in the prompt).
# The vulnerability was that a broker-controlled 'iteration_count' was passed
# directly to `hashlib.pbkdf2_hmac` without validation. A large number would
# cause excessive CPU usage, freezing the client.
class KafkaError(Exception):
"""A generic error class for the example."""
pass
class ScramClient:
def __init__(self, password, sasl_mechanism='SCRAM-SHA-256'):
self._password = password.encode('utf-8')
self._sasl_mechanism_name = sasl_mechanism.split('-', 1)[1].lower() # e.g., 'sha-256'
self._hash_name = self._sasl_mechanism_name.replace('-', '') # e.g., 'sha256'
# --- THE FIX: Define safe boundaries for the iteration count ---
# RFC 5802 requires a minimum of 4096 iterations.
self.MIN_ITERATION_COUNT = 4096
# A reasonable upper bound to prevent CPU-exhaustion (Denial-of-Service).
self.MAX_ITERATION_COUNT = 16777216
# --- END OF FIX ---
def _process_server_first_message(self, server_message_data):
"""
A simplified representation of the method containing the fix.
`server_message_data` is a dictionary parsed from the broker's response.
"""
try:
iteration_count = int(server_message_data['i'])
salt = server_message_data['s'].encode('utf-8')
except (KeyError, ValueError) as e:
raise KafkaError(f"Invalid SCRAM server-first-message: {e}")
# --- THE FIX: Validate the iteration count against the defined boundaries ---
if not (self.MIN_ITERATION_COUNT <= iteration_count <= self.MAX_ITERATION_COUNT):
# This check prevents the DoS by rejecting an excessively large number
# before it reaches the expensive pbkdf2_hmac function.
raise KafkaError(
f"Invalid SCRAM iteration count '{iteration_count}' from broker. "
f"Must be within [{self.MIN_ITERATION_COUNT}-{self.MAX_ITERATION_COUNT}]."
)
# --- END OF FIX ---
# The vulnerable code passed the unvalidated 'iteration_count' directly here.
# Now, the operation is safe because the count has been validated.
salted_password = hashlib.pbkdf2_hmac(
self._hash_name,
self._password,
salt,
iteration_count
)
return salted_passwordPayload
r=fyko+d2lbbFgONRv9wV3gC/I3aA216e9bJIKgVpcvb77oQ==,s=QSXCR+Q6sek8bf92,i=4000000000
Cite this entry
@misc{vaitp:cve202610143,
title = {{A large SCRAM iteration count from a broker can freeze kafka-python clients.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-10143},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-10143/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
