confluentinc / librdkafka

The Apache Kafka C/C++ library
Other
277 stars 3.15k forks source link

Some components use `strcmp` which is vulnerable to timing attacks #4639

Open HRsGIT opened 8 months ago

HRsGIT commented 8 months ago

Description

Some components in librdkafka use strcmp to validate a password, signature or key, which is vulnerable to timing attacks that make brute force attacks for such credentials more likely to be successful. For example, consider lines 842 and 567 in rdkafka_sasl_scram.c. A similar issue occurred with Apache Kafka, which has been assigned CVE-2021-38153. Patch in Apache Kafka image Code in ibrdkafka image

Checklist

IMPORTANT: We will close issues where the checklist has not been completed.

Please provide the following information:

emasab commented 6 months ago

I think it's very difficult to find a timing based brute force attack to guess ServerSignatureB64 from this. Even if the connecting broker is a Mallory. because the ServerSignatureB64 is calculated from AuthMessage that contains the client salt, that it's random. So ServerSignatureB64 changes at every connection attempt. Connection attempts start from a backoff of 100ms and reach a maximum of 10s.

Given that, I don't know if some kind of cryptographical analysis can be applied on top of this, could you explain how an attack would look like. Not a generic timing attack but for this specific field? The fix would be to compare all the bytes in the signature instead of stopping at first one that differs.