Skip to content
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

Security Regression: Mosquitto client connects without verifying broker CA file #2133

Open
becz opened this issue Mar 12, 2021 · 2 comments
Open

Comments

@becz
Copy link

becz commented Mar 12, 2021

Follow-up to #2130

The provided fix does not entirely fix the issue.

I run further tests with new library 1.6.14 and observed further "unexpected connect" which is not present with library 1.4.15

I did the following in conjunction with the example project provided in #2130

  1. Use broker with tls enabled and without client authentication (like test.mosquitto.org:8883)

  2. Create empty ca file on client side (e.g. touch InvalidCa.crt)

  3. Start example project (NameOfBinary PathToCaFile)
    --- observe library does not connect --- (OK)

  4. Write valid certificate for the broker into InvalidCa.crt
    --- observe library connected to broker --- (OK)

  5. Make sure library disconnects (e.g. switch ethernet off for a while)

  6. Write certificate of "other broker" into InvalidCa.crt (CommonName of certificate does not match host we are connecting to)

  7. Make sure library can connect (e.g. switch ethernet on)
    --- observe library connected to broker --- (UNEXPECTED)

Output of example program:

library version: 1.6.14
mosquitto_tls_set returned: 0 (No error.)
Log: Error: Unable to load CA certificates, check cafile "caInvalid.crt".
mosquitto_connect_async returned: 8 (A TLS error occurred.)
mosquitto_loop_start returned: 0 (No error.)
Log: Error: Unable to load CA certificates, check cafile "caInvalid.crt".
Log: Error: Unable to load CA certificates, check cafile "caInvalid.crt".
Log: Error: Unable to load CA certificates, check cafile "caInvalid.crt".
Log: Error: Unable to load CA certificates, check cafile "caInvalid.crt".
Log: Error: Unable to load CA certificates, check cafile "caInvalid.crt".   

--> Write valid certificate data to caInvalid.crt

Log: Client myLoopTest sending CONNECT
Log: Client myLoopTest received CONNACK (0)
Connected!

--> Disconnect client from broker (e.g. switch ethernet off for a while)

Disconnected! (7)

--> Write certificate of "other broker" into InvalidCa.crt and enable connection to broker

Log: Client myLoopTest sending CONNECT
Log: Client myLoopTest received CONNACK (0)
Connected!

best regards,
Benjamin

@ralight
Copy link
Contributor

ralight commented Mar 25, 2021

I don't believe this is a security regression. The client still validates the server certificate using the original CA certificate, so the connection is still valid. It will also trust an additional CA certificate when you add the second certificate.

@mm-ark
Copy link

mm-ark commented Mar 26, 2021

The "original CA certificate" was actually overwritten in step 6. So after step 6 the "other broker certificate" in not the second but the only one within InvalidCa.crt library 1.4.15 does not connect after step 6, so expectation is same for library 1.6.14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants