Transport-level security tradeoffs using MQTT

By Todd Ouska, wolfSSL

The Message Queuing Telemetry Transport protocol, or MQTT, has become a favorite of Internet of Things (IoT) developers, and why not? It’s incredibly lightweight (on the order of a couple Kb for client implementations), has easy-to-use APIs, and is available for free under the Eclipse Public License (EPL). If your connected application is something simple and relatively contained – like remote monitoring the temperature in your living room, for example – that much is probably enough to make you happy.

But what if your application is a little more complex? Say you’re combining multiple sensors, an HVAC system, a little intelligence, and MQTT to automatically adjust the climate in your home based on occupancy, and you’ve also configured remote management into the application so you can manually override instances where your dog tripped the infrared proximity sensor (sorry, Spot). Or maybe after some hard work you’re deploying a similar commercial system and need to update a sensor platform’s firmware to provide more precise measurements. So at what point is “enough” good enough? The answer depends on you and your application.

MQTT is a publish/subscribe protocol, meaning that would-be “clients” in the traditional networking model can act as both publishers of and subscribers to messages related to particular topics. Messages are distributed using the transmission control protocol (TCP), but rather than being indiscriminately broadcast, clients send messages through a central MQTT broker that accepts messages from a publisher and distributes them to the subscriber(s) to that topic at varying quality of service (QoS) levels.

However, in order to keep the protocol as lightweight as possible for resource-constrained IoT edge devices, the MQTT specification offers nothing on top of TCP for security outside of a recommendation that the transport layer security (TLS) protocol be used for applications that require additional levels of authentication. As a result, MQTT communications that rely on TCP alone are unencrypted and susceptible to man-in-the-middle attacks.

To illustrate what this means in more detail, let’s go back to our two “complex” examples from earlier. Say a proximity sensing platform publishes a message to the MQTT broker with the topic “home/occupancy.” The MQTT protocol does allow the use of a username and password for client identification, but these are displayed in text if some form of encryption isn’t used. Therefore, an eavesdropper could potentially impersonate a client subscriber and decrypt a message payload, or even imitate a client publisher and issue fake or modified messages. In terms of the personal home application this could signal to prospective thieves that no one is home, and in the commercial deployment scenario has serious implications on processes like remote firmware updates.

TLS tradeoffs

As mentioned, the MQTT protocol does recommend the use of TLS for more sensitive MQTT implementations, and a network port (port 8883) has even been reserved for this purpose. TLS is the successor of the secure sockets layer (SSL) protocol, and provides an encrypted communication channel over which MQTT messages can be sent. Before the channel is established TLS uses a handshake to pass certificates (or keys) from the publisher to the broker, but also between the broker and subscribers. If successful a secure channel is established, if not, the connection is aborted. Easy enough, right?
Well, maybe not. The downside of using TLS, SSL, and other methods of encryption is that they can add significant overhead, which is probably why you chose to use MQTT in the first place. For example, at wolfSSL we recently released an MQTT client library (wolfMQTT) with a compiled size of 3.6 kB. A TLS handshake alone can consume that much, without accounting for the encryption overhead on the individual packets themselves. For certain resource-constrained embedded devices, particularly those based on small microcontrollers, this added workload can simply consume too much in terms of CPU resources.

Techniques such as session resumption can compensate for some of the connection costs of TLS, and hardware acceleration is also a method for reducing the size penalty for encryption. Another important consideration is selecting an optimized encryption library when securing system communications, and in the case of wolfMQTT, integrating the lightweight wolfSSL embedded SSL/TLS library resulted in a compiled size of 20-30 kB when paired with hardware acceleration.
In the end, the decision when and how to implement security in your MQTT-based IoT system depends on you and your application. If you decide to move forward with transport-layer encryption, some best practices include working with MQTT libraries that are open source and allow you to look under the hood, but also provide documentation and examples of how encryption could be implemented in your application. If you’re a commercial entity using MQTT, make sure to partner with a vendor that has security credentials and also supports the widest range of operating systems and embedded chipsets possible in order to avoid lock-in.

For more, check out our secure firmware update example written in C that demonstrates encrypted communications to and from an MQTT broker using TLS.

Todd Ouska is Co-Founder and CTO of wolfSSL.

wolfSSL
www.wolfssl.com
@wolfSSL
LinkedIn: www.linkedin.com/company/wolfssl
Facebook: www.facebook.com/wolfssl

wolfSSL Adds Secure SSL/TLS Encryption to MQTT IoT Protocol in Lightweight wolfMQTT Library

wolfSSL recently published a press released talking about the release of wolfMQTT, and its use with the wolfSSL embedded SSL/TLS library:

“3.6 kB MQTT client implementation easily integrates with the wolfSSL embedded SSL library for resource-constrained Internet of Things devices and connected applications.

wolfSSL, a leading provider of security and connectivity solutions for the embedded, machine-to-machine (M2M), and Internet of Things (IoT) markets, has announced the release of wolfMQTT, a client implementation of the Message Queuing Telemetry Transport (MQTT) protocol that provides lightweight, portable, and secure publish/subscribe messaging for developers of connected applications. Developed from scratch and written in native C, wolfMQTT has a compiled size of only 3.6 kB and is available for use under commercial or open source (GPLv 2) licenses.

By design, MQTT relies solely on the transmission control protocol (TCP) to limit overhead in resource-constrained embedded devices, but offers no provisions for security or encryption. Based on the MQTT v3.1.1 specification and supporting quality of service (QoS) levels 0-2, wolfMQTT provides SSL/TLS (Secure Sockets Layer/Transport Layer Security) encryption through the wolfSSL library, adding as little as 20-30 kB when paired with hardware acceleration to prevent eavesdropping and man-in-the-middle attacks. In addition, techniques like TLS session resumption can further reduce connection costs for sensor devices or other platforms with limited resources.”

You can read the entire article here. If you would like more information about running wolfMQTT or wolfSSL in your environment, please contact us at facts@wolfssl.com

Reference: http://www.prweb.com/releases/2016/02/prweb13221670.htm

Secure Email Client with Freescale KSDK + wolfSSL + FRDM-K64F

Are you interested in having a secure email client on your Freescale Kinetis device? How about one that uses wolfSSL too!

A member of the Freescale/NXP community (Denis Shimizu) recently adapted the original SMTP protocol implementation that is included with KSDK 1.3 to add in secure connections using the wolfSSL lightweight SSL/TLS library.

The example software is currently ported to the FRDM-K64F Kinetis board, but can be implemented on other boards as well. This demo sends an email using the GMail SMTP server (smtp.gmail.com, port 465) through a secure SSL/TLS channel.

For the details and code, please visit the following page on the Freescale/NXP Community website:
https://community.NXP.com/docs/DOC-329650

wolfSSL has been ported to the Freescale Coldfire and Kinetis processors, and can take advantage of the hardware cryptography offered by the CAU, and mmCAU.

Overview of Testing in wolfSSL

The security of wolfSSL products is always on our mind and holds high importance.  Conducting regular, diligent, and well-planned testing helps maintain wolfSSL’s robustness and security.  We strive to write and maintain clean, readable, and understandable code.

Like the halting problem, we know it is impossible to test every single possible path through the software, but we practice an approach that is focused on lowering risk of failure. In addition to extensive automated testing, we make sure that we specifically test well-known use cases. This post outlines some of our internal testing process.

  1. API Unit Testing:  We have unit tests in place that test API functions for correct behavior. This helps maintain library consistency across releases and as the code evolves.  It helps us to deliver a high quality well tested API to our end users with each software release.  API unit tests are run with each “make check” of wolfSSL.
  2. Cipher Suite Testing: wolfSSL supports an extensive list of cipher suites, which are all tested with every “make check” using the wolfSSL example client and example server.  Each cipher suite is tested not only in the default configuration, but also in non-blocking mode and with client authentication both turned on/off.
  3. Algorithm Testing: The security of our SSL/TLS implementation depends on the correctness and robustness of our underlying cryptography library, wolfCrypt.  We test all algorithms using NIST test vectors in addition to running our CAVP test harness used for our FIPS 140-2 validations.  We also test on both big and little endian platforms for portability.
  4. Benchmark Testing: We engage in another ever expanding universe of benchmark testing, where we look at sizing, transmission rates, connection speeds, and cryptography performance.  A version of our benchmark suite is included in every download for users to enjoy!
  5. Static Analysis: We do static analysis on our entire codebase using not only one, but multiple different static analysis tools.  We currently use Coverity Scan, clang scan-build, and Facebook infer.  These tools help us to automatically find bugs including ones on low-traffic code paths.
  6. Detecting Memory Errors:  We mitigate memory errors by using valgrind on a regular and automated basis.  This helps find memory errors including invalid access, use of undefined values, incorrect freeing of dynamic memory, and memory leaks.
  7. Interop Testing: We test for interoperability with other Open Source TLS implementations, including OpenSSL, BoringSSL, and GnuTLS.  This helps us to catch any protocol implementation errors in either wolfSSL or the implementation being tested against.  We also test outside of a closed environment by connecting to servers in the real world running unknown SSL/TLS implementations.
  8. Real World Builds: We build with a series of `real` applications, like cURL, wget, pppd, OpenSSH, stunnel, lighttpd, etc.  For some of our customers with top level support, we build new releases with their application.
  9. Compiler Testing: We have users who compile wolfSSL with a variety of different compilers.  As such, we test compiling wolfSSL with many different compilers and toolchains including gcc/g++, clang, icc, Visual Studio, CodeWarrior, KDS, LPCXpresso, MPLAB XC, TI CCS, Keil, IAR, Cygwin, MinGW, CrossWorks, Arduino, Wind River Workbench, and more.
  10. Peer Review: More eyes on a codebase reduces bugs that end up in a final product.  Internally, we operate using a “Fork and Pull Request” model.  This means that every commit that makes it into our master branch has been reviewed and tested by at least two separate engineers.
  11. Third Party Testing: Our code is regularly reviewed by university researchers, customer and user security teams, FIPS and certification labs, and our Open Source user base.  This helps put more eyes on our code and product architecture.
  12. Fuzz Testing: We test using several different software fuzzers, including an in-memory fuzzer and a network fuzzer.  This bombards the program with invalid, unexpected, and random data that then allows for observing if there is potential memory leaks or logic errors.  This allows us to catch bugs that could turn into potential vulnerabilities if released in a final release.
  13. Continuous Integration (CI): Leveraging Jenkins, we run tests on each commit submitted to the wolfSSL code repository.  Tests run on each commit include testing of our FIPS build, numerous build options (customer/user/common), running valgrind, and doing static analysis with scan-build.
  14. Nightly Test Cycle: Each night we run extended tests that last longer than the typical ones during the work day.  These are more in-depth than our CI testing and puts results in our engineers’ inboxes each morning.  Some tests included in our nightly cycle include extended build option testing on multiple platforms with multiple compilers, and extended fuzz testing.

If you have specific questions about how we test, please contact us at facts@wolfssl.com.  If you would like us to include your SSL/TLS or crypto implementation in our interop testing, please let us know!  Likewise, if you would like to include wolfSSL in your own test framework, we would be happy to discuss.

wolfSSL 2015 Annual Report

Hello wolfSSL stakeholders!  2015 was another fantastic year of progress for wolfSSL, and as we strive to provide transparency for our customers, users, employees, and open source community, we are again reporting on our progress for the year.  It was a good year!  We accomplished a lot in building towards our goals.  

Our goals at the start of 2015 included:

1. Continued build out of our community of open source users and customers,
2. Continuous enhancement of our massive test rigs,
3. Enhancing and extending our FIPS 140-2 support and FIPS user base,
4. Making wolfSSL even easier to do business with than before,
5. Maintaining our lightning fast response to fixing bugs,
6. Extending our support for open source projects like cURL, OpenSSH, wpa_supplicant, devkitPro, and others,
7. Forming new industry partnerships, and extending our existing partnerships, and
8. Growing and building our engineering team and its capabilities.

We are pleased to report that we made dramatic progress on all of these 2015 goals!  We have:

1. Grown our open source user base and our commercial customer base dramatically,
2. Doubled the number of tests in our test rigs,
3. Added a host of new FIPS customers,
4. Maintained our responsiveness,
5. Nearly doubled our engineering horsepower.

We feel really good about the year, as 2015 sets the stage for further success in 2016.  This year, we plan to continue more of the same, and come into the year with a wealth of confidence that we can do it again!  Our stage is well set as the leading provider of cryptography and embedded SSL/TLS for the emerging IoT and appliance markets.

The rest of this note is a more detailed summary of our 2015 progress.  Thank you for your support, and again, never hesitate to contact us at facts@wolfssl.com, as we’re here to help.  

wolfSSL Technical Progress

A total of seven wolfSSL releases were delivered in 2015, each with bug fixes, enhancements, and new feature additions.  Highlights of these releases included:

1. wolfSSL name change from CyaSSL, including new wolfSSL and wolfCrypt API
2. FIPS validation of the wolfCrypt cryptography module for iOS, Android, Windows, Linux, and FreeRTOS
3. New algorithms: Curve25519, Ed25519, IDEA
4. Enhanced benchmarking with cycle counts and throughput
5. Reduced memory usage for ECC (heap) and post handshake memory (less than 1kB)
6. Intel Assembly Enhancements for RNG, SHA-2, and public key algorithms as well as support for AES-NI with AES-GCM
7. Security fixes: RC4 and SSL 3.0 disabled by default, AEAD ciphers enabled by default, static key cipher suites disabled by default
8. New “Max Strength” build with TLS 1.2, AEAD, and Perfect Forward Secrecy
9. Server side session ticket support
10. Support for Texas Instruments hardware cryptography
11. DTLS fragmentation, duplicate message, and retransmission fixes
12. Addition of QSH (Quantum-Safe Hybrid) handshake extension
13. Addition of SRP (Secure Remote Password) support in wolfCrypt
14. Support for new Freescale I/O and KSDK updates
15. Enhanced certificate generation with support for new extensions and SHA-512 certificate signing request generation
16. ALPN extension support added for HTTP/2 connections
17. SSL/TLS Sniffer enhancements with addition of AES-GCM, reassembly fixes, additional stats
18. Addition of a pluggable crypto architecture for RSA
19. Addition of a single-shot hash and signature/verify API
20. New C# wrapper to support wolfSSL use by C# programs
21. Addition of OCSP Stapling support

wolfSSL Porting Progress

1. Platform support updates: PIC32MZ, TI-RTOS, PowerPC, FreeRTOS, VxWorks, Cavium NITROX
2. IDE/Compiler support updates: XCode, Freescale CodeWarrior, Rowley Crossworks, Keil MDK5-ARM, NXP LPCXpresso
3. Improved support for PicoTCP
4. OpenSSH compatibility
5. Updated stunnel compatibility
6. Updated lighttpd compatibility

wolfSSL Events and Tradeshows

The wolfSSL team participated in a total of 12 events in 2015, including:
1. FOSDEM (Brussels, Belgium)
2. Embedded World (Nuremberg, Germany)
3. RSA USA (San Francisco, CA)
4. ESC Boston (Boston, MA)
5. Big Sky DevCon (Bozeman, MT)
6. Freescale Technology Forum (Austin, TX)
7. O’Reilly SOLID (San Francisco, CA)
8. ESC Silicon Valley (Santa Clara, CA)
9. Black Hat USA (Las Vegas, NV)
10. Microchip MASTERS (Phoenix, AZ)
11. ESC Minneapolis (Minneapolis, MN)
12. ARM TechCon (Santa Clara, CA)
13. Embedded Technology (Yokohama, Japan)

In summary, we had a great year!  2015 was successful for us on multiple fronts, and we look forward to serving our customers and community with ever more secure and functional software in 2016!  As always, your feedback is welcome at facts@wolfssl.com!

wolfSSL Users SAFE from Recent OpenSSL Vulnerabilities (DH Primes, SSLv2)

OpenSSL recently released patches for two vulnerabilities [1] – one related to how OpenSSL generates Diffie-Hellman prime values and the other that potentially allowed a malicious client to negotiate old SSLv2 ciphers that had been disabled on the server.  Since both of these are OpenSSL implementation vulnerabilities, wolfSSL users are SAFE.

For reference, the two OpenSSL vulnerabilities that were patched were:

CVE 2016-0701
CVE 2015-3197

[1] http://openssl.org/news/secadv/20160128.txt

Top Seven Reasons to use the wolfSSL patch in MySQL instead of yaSSL or OpenSSL

1.  You want more robust security.

2.  You want to avoid the steady stream of security updates required by using OpenSSL.

3.  You are paranoid, and want to use quantum safe crypto.

4.  You are performance driven, and want to leverage the latest hardware crypto, or tune in progressive ciphers.

5.  You want direct support for the crypto you use in MySQL or MariaDB.

6.  You need FIPS 140-2 support for your MySQL install.

7.  You want to use ChaCha/Poly.

You can check out the patch here.  If you have questions or need support, then give us a call at +1 425 245 8247 or email us at facts@wolfssl.com.

wolfSSL with ChaCha20-Poly1305 Cipher Suites

We have recently updated our ChaCha20-Poly1305 cipher suites. The ChaCha20-Poly1305 AEAD cipher suites are performant and use low amounts of memory, making it a good fit for IoT devices. This recent update allows for interoperability with the current OpenSSL, GnuTLS, and BoringSSL libraries when using ChaCha20-Poly1305 in a TLS connection and continues interoperability with libraries using the older version of RFCs like LibreSSL and the www.google.com server. For connection with the older RFC there has been an addition of ChaCha20-Poly1305 cipher suites ending with “-OLD” for example ECDHE-RSA-CHACHA20-POLY1305-OLD.

This most recent addition to the wolfSSL embedded SSL/TLS library is on our GitHub account located at https://github.com/wolfSSL/wolfssl and will be coming to the wolfSSL website https://wolfssl.com/download in our next release, scheduled for the end of February.

For any questions contact us at facts@wolfssl.com.