Basics of Design • CC Blog • Research & Design Hub

No Blues with Bluetooth! Bluetooth Cybersecurity Basics

Written by Robert Lacoste

Since cyber hacking is more of a threat than ever, Robert dives into the Bluetooth Security Manager in Part 6 of his series on Bluetooth. Previously, he wrote about Bluetooth Low Energy protocol in Part 4, and in Part 5, he wrote on GATT for Circuit Cellar’s September issue. In this issue, Robert examines attacks on confidentiality, authenticity and integrity and describes ways to combat man-in-the-middle attacks.


  • What are the main Bluetooth security risks?
  • How does BLE ensure confidentiality, authenticity, and integrity?
  • What is the role of the BLE Security Manager?
  • How is a secure connection established in BLE?
  • How does BLE prevent man-in-the-middle attacks?
  • Bluetooth Low Energy (BLE)
  • AES encryption
  • Diffie-Hellman key exchange
  • NFC for Out-of-Band communication
  • BLE Security Manager
  • GATT protocol
  • BLE pairing protocols
  • MAC Integrity Code (MIC)

Welcome back to the world of Bluetooth. In my previous articles, I presented the overall Bluetooth Low Energy (BLE) protocol. I explained how a BLE connection between two devices can be established (“No Blues with Bluetooth, Part 4: Let’s Connect with BLE.” Circuit Cellar 409, August 2024) [1] and what kind of information can be exchanged through this connection (“No Blues with Bluetooth, Part 5: GATT explained.” Circuit Cellar 410, September 2024) [2].

Do you now have all the information needed to understand BLE? Well, almost. I am sure you remember the BLE protocol stack. If not, just have a look at Figure 1. I already presented all entities on this diagram except one–the Security Manager (SM). As its name implies, it ensures that the BLE communication is “safe,” that is, safe enough for a given application.

Bluetooth Low Energy, BLE security, wireless encryption, man in the middle protection, IoT device security, BLE key sharing, secure pairing, BLE Security Manager, cyber threat defense, embedded systems
Bluetooth Low Energy, BLE security, wireless encryption, man in the middle protection, IoT device security, BLE key sharing, secure pairing, BLE Security Manager, cyber threat defense, embedded systems

Cyber hacking is more than a risk, and Bluetooth is now used for a multitude of sensitive applications, so this topic is more than crucial. Next, let’s have a look at how security is managed in BLE.

SECURITY RISKS

Before delving into the BLE Security Manager, it may be useful to go back to some security basics. Let’s take the example of a door lock that’s designed to be opened with your smartphone (Figure 2). For sure, many such products exist on the market. What are the cyber security risks in such a case, especially since a wireless link is used?

Figure 2
The key risks on a communication link.
Figure 2
The key risks on a communication link.

Confidentiality: The first and most obvious is confidentiality. If someone can spy on the communication and decode the information, then it is not safe. The spy could, for example, install a spying device nearby and know who is entering your house and when. This would be a good way to plan a burglary.

Authenticity: The second risk is authenticity. If nothing is built in to prevent such an attack, then the burglar can use his own smartphone, or perhaps a specifically designed device, to emulate your legitimate smartphone. If this is done correctly, and if the door lock doesn’t have enough authenticity protection, then he may be able to open the door.

Integrity: The third main risk is integrity. It is possible that an attacker could modify the content of a legitimate message, and the change isn’t noticed. If integrity protection is not high enough, then the burglar may just find out that a “close door” message may be changed into a “stay open” message by toggling a given bit in the frame and recalculating a checksum.

CRYPTO TO THE RESCUE

There are, of course, plenty of other risks in a communication link, but the above three are probably the most serious. The designer of any protocol therefore needs to prevent them. Standard protocols, such as Bluetooth, Wi-Fi, include such protections. Such protocols are designed to be adequate for the vast majority of needs, however, some built-in protections may not be enough for very sensitive applications.

Security is included in a protocol by using cryptographic algorithms. As you probably know, such algorithms include encryption/decryption and secure checksum calculations. They are based on secret keys, and they are supposed to be mathematically safe.

Let’s first assume that a secret key is already known by the two communicating devices and by no one else. With such an assumption, implementing security protection is easy. Have a look at Figure 3, where I show one method of providing protection against the three risks. I assume that a secret key is already known by the sender and receiver. The sender can then use this key to cipher the message prior to transmission. This will ensure confidentiality, because nobody is supposed to be able to decipher the message without knowing the key.

Figure 3
When a secret key is shared between two devices, security is easy!
Figure 3
When a secret key is shared between two devices, security is easy!

To provide authentication and integrity protection, the sender can also use a cryptographic algorithm to calculate a hash code, which can be described as a super checksum calculated using the secret key. The idea is that no one can recalculate a correct hash code without knowing the key. BLE calls this hash code Mac Integrity Code (MIC). A MIC ensures integrity — if anyone changes a bit of the message then he will not be able to recalculate the MIC, because he doesn’t have the key. The recipient will then recalculate the MIC, detect the error, and ignore the frame if it is corrupted. Similarly, a MIC can also provide authentication protection, simply by adding the sender identification (MAC address for example) in the calculation of the MIC. Only the legitimate sender has the key and can calculate the MIC.

BACK TO BLE

In the previous parts of this series, I presented the generic format of a BLE radio frame (Figure 4). As a reminder, this type of frame starts with a 1-byte preamble and 4-byte access code, followed by a 2-byte layer-two header, a payload of up to 255 bytes, and a 3-byte CRC. The payload can be either a GAP frame (advertising, connection request, and so on, shown on the right side of the illustration), or a link-layer frame when a connection is established (left side). A link-layer frame has up to 251 bytes of data followed by a 4-byte MIC. Now you know what this MIC stands for: It provides security protection for the communication. Four additional bytes in each message is not negligible in terms of battery usage, but it is reasonable for security protection.

Figure 4
The BLE frame format. When connected, a 4-byte Mac Integrity Code is included for integrity and authentication control.
Figure 4
The BLE frame format. When connected, a 4-byte Mac Integrity Code is included for integrity and authentication control.

Figure 4 also illustrates a very important point of the BLE frame. The MIC is present only on the left side of the figure, which means it exists only after a connection was established. There is no MIC on the right side, which means that is not present during the GAP advertising and connection establishment phase. This is, in fact, also visible on the BLE protocol stack (Figure 1), where the security manager is on top of L2CAP, so it doesn’t exist before connection establishment.

What does this imply? Simply that there isn’t any security in BLE during the advertising and connection establishment phase. Anybody can detect a device and even ask to connect. The connection will always be established if the device is “connectable”, and this will be done prior to any security check. However, the security manager will then jump into action and will check if the connection is legitimate. If not, the connection will simply be broken before any application-level exchange, thereby avoiding any risk.

SECRET KEY SHARING

BLE can provide strong security protection, but this requires sharing a secret key between the two communicating devices. And sharing such a secret in a safe way is not obvious. This is, in fact, the same issue for any communication protocol. Going back to the door lock example, how can a secret be shared with a smartphone, without creating a security risk?

Through the Air: The first way is to send the secrete key through the air. But this must be done with a non-ciphered communication, since no key is available. This is risky especially if the connection between the lock and the smartphone is established in an unsafe environment.

Pin Code: A second solution is to ask the user to transfer the key. This is indeed a common solution, called pin code. Usually, the pin code is pre-programmed in the lock and communicated to the user in the user manual or on a label. The legitimate user is then the only one expected to know this secret (assuming the pin code is not 0000 or 1234) and can enter it on the smartphone. We are familiar with this method, because many Bluetooth devices use pin codes. But it is boring! Users want plug and play. Furthermore, pin codes are short, so security is limited.

Out-of-Band: A third solution, also supported by Bluetooth, is to communicate the secret using something other than BLE. This method, called Out-of-Band communication (OOB), is often implemented through near-field communication (NFC). Assume that the lock includes an NFC tag, programmed with a secret key. By putting the smartphone very close to the lock, it could read it and get the secret in a quasi-magical way. This isn’t 100% safe either, since NFC can be read from a distance, but it is easy for the user as long as the smartphone is also an NFC reader. The OOB method can also be implemented using something other than NFC, for example, by scanning a hidden QR code or using an infrared communication link.

Asymmetric Encryption: Fourth, there is a way to communicate a secret safely, even through an unprotected communication channel. For that, mathematicians have invented very clever ciphering methods called “asymmetric encryption (Figure 5). What is it? With classic encryption algorithms like the ubiquitous AES or DES, the same key is used for encryption and decryption. This key must be shared, and this is complicated.

Figure 5
Symmetric encryption uses the same key for encryption and decryption, as opposed to the more sophisticated asymmetric encryption methods.
Figure 5
Symmetric encryption uses the same key for encryption and decryption, as opposed to the more sophisticated asymmetric encryption methods.

Asymmetric encryption algorithms don’t have such problems : Two different keys are jointly generated—one for encryption and one for decryption. Furthermore, there is no way to calculate one using the other. Classic examples of asymmetric encryption algorithms include the Rivest-Shamir-Adleman (RSA) and Diffie-Hellman (DH) methods. Going back to our example, the lock could broadcast its encryption key, which is then named “public key.” Anyone can use it to encrypt a message for the lock, but only the lock can decrypt it, because the decrypt key isn’t public. As I will explain, this method is supported in some versions of BLE.

MAN IN THE MIDDLE

But wait! If we use an asymmetric encryption algorithm, then security is guaranteed, right? Not exactly. There is one last issue—the risk of a “man-in-the-middle attack” (MITM). This attack is illustrated in its most basic form in Figure 6.

Figure 6
An example of a man-in-the-middle (MITM) attack
Figure 6
An example of a man-in-the-middle (MITM) attack

Imagine that a burglar knows that you are installing an amazing new door lock in your house. He could buy the same lock, use his own smartphone, and stay close to your house. When the physical installation is finished, you will try to connect your smartphone to your lock. The manual may state something like, “Launch the application on the smartphone, press a button on the lock, and click on the connect button on the app.” But nothing prevents the burglar from pressing the same button on his fake (duplicate) lock, and at the same time try to connect to your own lock using his smartphone.

Even if asymmetric encryption is in place, nothing will prevent your smartphone from connecting to the wrong lock, except maybe radio signal strength, but this is easily bypassed with high-gain antennas. Now the burglar has a fake lock connected to your smartphone, and can drive your real lock using his own smartphone. If you test your lock he could easily emulate the action, but he could also open your house when you are out.

Unfortunately, protection against man-in-the-middle attack is always tricky if there isn’t any previously-shared secret key. Basically, algorithms are never enough. There must be a physical human confirmation that the communication is taking place between two legitimate devices. I will explain in a minute how this is managed in BLE, but think about it. There is no way to prevent such attack without a human check as long as no secret keys are preprogrammed on both devices.

SECURITY MANAGER

Now it is time to go back to BLE. Figure 7 illustrates when the Security Manager enters into action. First, you know that there is an advertising and connection establishment phase in BLE. The link layer is then activated, and both devices exchange packets at regular intervals. The SM then starts executing the “pairing phase.” Pairing is an exchange of security features between the two devices. I will explain it a little later.

Figure 7
The BLE Security Manager is launched just after connection establishment.
Figure 7
The BLE Security Manager is launched just after connection establishment.

After the pairing, the SM goes to phase II. Here it decides which security features are required, checks authentication, and shares a first secret key between the two devices. The link can then be fully encrypted. I will not go into the details, but the security manager then goes to a phase III, where it will generate and exchange more secret keys. Anyway, since phase III is already using an encrypted link, the security is already ensured, so the most important step is phase II.

Phase II also takes care of MITM prevention. How? Here it is important to keep in mind that BLE is designed for “interoperability.” This usually means that a peripheral is designed to be connected to any kind of central device, and vice-versa. Moreover, both devices may have different versions of BLE or may support different optional features. So the BLE pairing process is a negotiation.

First, OOB will be used if both devices support it. Second, the distribution of the first secret key will be done differently, based on the BLE version of the devices. In versions 4.0 and 4.1, only one distribution method was supported, called Legacy Encryption (Figure 8). In this method, the first secret key is sent over the air without any protection. This means that the link is secured unless someone spies during the pairing phase. Since version 4.2, an alternative method is supported—”Secure Connection.” This one uses a Diffie-Hellman asymmetric encryption algorithm, so even the pairing phase is secure—provided that both devices are 4.2 or above, and each supports this feature. Indeed, Secure Connection is an optional feature, even if nearly all post-4.2 devices support it.

Figure 8
BLE 4.2 does support, optionally, a far safer security mode.
Figure 8
BLE 4.2 does support, optionally, a far safer security mode.
MITM PROTECTION

There must be protection against the man-in-the-middle attacks. As mentioned, this requires human verification. The issue is that some devices don’t have buttons or displays, so this might not be possible. To cope with all situations, the BLE Security Manager implements a very flexible solution. During the pairing phase, both devices indicate their characteristics through a message exchange (Figure 9). Do they have a display, a keyboard, or may be just a yes/no button? Do they have a way to use OOB? Is MITM protection mandatory or not? Do they support Secure Connection?

Figure 9
Through the pairing process, each device discovers the characteristics of the other one.
Figure 9
Through the pairing process, each device discovers the characteristics of the other one.

This is clearly specified in the Bluetooth Core Specification [3], which I encourage you to look through. Based on this information, the Security Manager will decide. If both devices can live without MITM protection, then a method called “Just Works” can be used. Basically there will be no manual interaction, so no protection against MITM either. However, the link will be safe only once it has been established.

But if MITM protection is required, then the I/O characteristics will be checked and a decision will be made based on complex rules (Table 1). For example, if one of the devices has a display and the other has a keyboard, then a check code can be displayed and keyed in by the user on the second device. A man in the middle will not see the display and will be rejected. Similarly, if the two devices have just a display and a button, then a method called “numeric comparison” will be used. A pseudo random value will be displayed on the two devices and the user will be asked to check and confirm, and so on.

TABLE 1
The decision matrix used by the Security Manager to try to provide MITM protection.
TABLE 1
The decision matrix used by the Security Manager to try to provide MITM protection.

Finally, if MITM protection is required but no way can be found to ensure it (for example, if one of the devices has just a button), then the connection will simply shut down.

IS IT SECURE?

At this point, you might be wondering if BLE is really secure. That subject could be discussed for days, but in a nutshell, there is general agreement that the answer is something like “yes…if.” “Yes,” the Bluetooth Special Interest Group has done a great job, and the security features of BLE are first class. But this is true only “if” the designer implements BLE safely.

What does this mean? First you must ensure that your product supports LE Secure Connection (which isn’t mandatory even in Bluetooth 5.X). But your code must also ensure that the connection is rejected if the other device doesn’t support it, or at least warns the user.

Second you usually must have a way to prevent MITM attacks. Unfortunately, this will require some kind of user involvement, so the products will need buttons, LEDs, displays, or out-of-band communication.

The only other solution is to warn the user to do the initial pairing in a very safe environment (not in a public place), or to accept the risk of an MITM attack. By the way, there are good open-source hacking tools for trying to break an MITM protection [4] [5], so you can even test your design to see if it is secure or not. I also encourage you to look at a video on YouTube that shows an actual MITM attack on a door lock [6].

Is this everything? No, there are also some security risks caused by possible bugs in the actual BLE stack implementation. Even if the specification is correct, developers are humans, and could have inadvertently introduced flaws in the stack code. The last large work on this subject for Bluetooth was documented in 2020 through the “SweynTooth” group [7]. Dozens of bugs were identified in the stacks of several leading vendors. This isn’t particularly dramatic, but only as long as you have a way to update the firmware of the devices in the field. So, planning to have a firmware upgrade mechanism is always an excellent idea for security.

There is one remaining security risk. Secret keys can be physically accessed on a device or bypassed using a multitude of methods, such as side-channel attacks. I will not expound on this subject, since I’m far from an expert. But as readers of this magazine, you are lucky to have a real expert nearby. I encourage you to read the numerous articles published on this subject in Circuit Cellar by our great columnist, Colin O’Flynn.

STAY TUNED

Here we are. I think I have now presented the full BLE stack from bottom to top, at least for the features available since its first version, Bluetooth 4.0. I have also presented a key feature introduced in 4.2–Secure Connections.

However, BLE is an evolving subject. After these basics, I plan to devote one last article to the newest BLE versions–5.0, 5.1, 5.2, 5.4, and last but not least, 5.4 with LE audio. You will see that BLE started as a simple alternative to Bluetooth “classic,” but is maturing into a powerful but complex protocol. Later, I will continue with more hardware-oriented subjects.

So, stay connected and secure with Bluetooth! 

REFERENCES
[1] Robert Lacoste. “No Blues with Bluetooth, Part 4: Let’s connect with BLE.” Circuit Cellar 409, August 2024
[2] Robert Lacoste. “No Blues with Bluetooth, Part 5: GATT explained.” Circuit Cellar 410, September 2024.
[3] – Bluetooth Core Specification v.5.4 https://www.bluetooth.com
[4] – securing/gattacker–A Node.js package for BLE (Bluetooth Low Energy) security assessment using Man in the Middle and other attacks. https://github.com/securing/gattacker
[5] — Exploiting Bluetooth Low Energy using Gattacker for IoT – Step-by-Step Guide:
https://blog.attify.com/hacking-bluetooth-low-energy
[6]- Bluetooth Smart lock interception and spoofing:

Bluetooth Smart lock interception and spoofing

[7]- Ionut Arghire. “SweynTooth: Bluetooth Vulnerabilities Expose Many Devices to Attacks.”
Security Week,  February 14, 2020
https://www.securityweek.com/sweyntooth-bluetooth-vulnerabilities-expose-many-devices-attacks

PUBLISHED IN CIRCUIT CELLAR MAGAZINE • NOVEMBER 2024 #412 – Get a PDF of the issue

— ADVERTISMENT—

—Advertise Here—

Keep up-to-date with our FREE Weekly Newsletter!

Don't miss out on upcoming issues of Circuit Cellar.


Note: We’ve made the Dec 2022 issue of Circuit Cellar available as a free sample issue. In it, you’ll find a rich variety of the kinds of articles and information that exemplify a typical issue of the current magazine.

Would you like to write for Circuit Cellar? We are always accepting articles/posts from the technical community. Get in touch with us and let's discuss your ideas.

Sponsor this Article
Founder at  | + posts

Robert Lacoste lives in France, between Paris and Versailles. He has more than 30 years of experience in RF systems, analog designs and high-speed electronics. Robert has won prizes in more than 15 international design contests. In 2003 he started a consulting company, ALCIOM, to share his passion for innovative mixed-signal designs. Robert is now an R&D consultant, mentor and trainer. Robert’s bimonthly Darker Side column has been published in Circuit Cellar since 2007. You can reach him at askrobert@lacoste.link.

Supporting Companies

Upcoming Events


Copyright © KCK Media Corp.
All Rights Reserved

Copyright © 2026 KCK Media Corp.

No Blues with Bluetooth! Bluetooth Cybersecurity Basics

by Robert Lacoste time to read: 14 min