LoRaWAN Security and MQTT: How to Protect an IoT Deployment

LoRaWAN
ProtocolLoRaWANOpen long-range, low-power LPWANView profile security doesn't end with AES-128 encryption. A deployment breaks at its weakest link: a shared key, an exposed gateway, or an open MQTTProtocolMQTTThe standard pub/sub protocol of IoTView profile topic.
An integrator installs 400 temperature sensors across three warehouses for a logistics operator. The devices ship from the factory with the same AppKey, because the batch was configured that way to save time, and they're activated with ABP so commissioning doesn't depend on coverage that day. The rooftop gateway keeps the admin password it came with. Everything works. Two years later, someone pulls the key out of a sensor that fell off a shelf and takes the rest of the system apart from home.
None of that is a LoRaWAN failure. The protocol encrypts well. What fails is everything around it: how keys are generated, who stores them, how the gateway reaches the internet, how data travels from the network server to the platform, and who logs in to that platform.
This guide is for integrators, device manufacturers, and operations teams who already have sensors in the field or are about to. It walks the chain link by link, from the radio to the people, with what to check at each step.
Where IoT Deployment Security Breaks
A typical deployment has six links, and each one fails in its own way:
- The device: it holds the keys and the firmware. If someone opens it, what do they walk away with?
- The radio: the LoRaWAN hop between the sensor and the gateways. The protocol itself encrypts and signs it.
- The gateway: it receives frames and forwards them. It's a computer with an operating system, ports, and passwords.
- The network server: it validates frames, manages session keys, and hands over the data. We cover it in detail in our LoRaWAN Network Server guide.
- The integration: the hop from the network server to the platform, usually over HTTPS or MQTT.
- The platform and its users: dashboards, alarms, the API, and the people who log in every day.
When it comes to LoRaWAN security, teams tend to spend almost all their attention on links 1 and 2, because that's where the cryptography lives. Real incidents show up more often in links 3, 5, and 6, which look much more like ordinary IT: default passwords, open ports, API keys pasted into a URL, and accounts nobody disabled.
LoRaWAN Security on the Device: Unique Keys and OTAA
LoRaWAN encrypts and signs every frame with AES-128. In the 1.0.x versions, which most sensors on the market run, there are two session keys: the NwkSKey, which the network server uses to check that a frame is authentic, and the AppSKey, which encrypts the payload so only the application server can read it. LoRaWAN 1.1 splits the roles further and adds a join server, but the idea is the same. The LoRa Alliance security FAQ is a good summary.
The encryption is solid. When LoRaWAN security fails, it's almost always because of how those keys are handled.
One Root Key per Device
The most important rule is also the one most often skipped: every device needs its own AppKey. If a whole batch shares a key, extracting it from a single unit is enough to impersonate or decrypt all the others. And extracting it from a sensor screwed to a wall, unattended, is easier than it sounds if the key sits unprotected in flash memory.
Ask the manufacturer to inject unique keys during production and to deliver them through a secure channel, not in a spreadsheet attached to an email. If the devices have a secure element (a chip that stores the key and won't let it be read out), even better.
OTAA vs. ABP
There are two ways to activate a LoRaWAN device:
- OTAA (Over-The-Air Activation): the device joins the network through a message exchange, and every join generates fresh session keys.
- ABP (Activation By Personalization): the session keys are written in by hand and never change.
ABP is convenient in a lab, but it causes trouble in the field. With fixed keys, the device relies on frame counters to stop anyone from replaying old messages. When an ABP device reboots and its counter goes back to zero, the network server rejects its frames as replays, and the quick fix you often see is turning that check off. With it off, a captured frame can be resent later and the server will accept it.
Use OTAA by default. If a model only supports ABP, document why, don't disable the frame counter check, and watch for reboots.
Firmware and Updates
A LoRaWAN sensor can spend ten years in the field. During that time, bugs will turn up in its firmware, and without a way to update it they stay there for good. Firmware updates over the air (FUOTA) exist, but they're slow and they drain batteries, so it pays to know before you buy what the manufacturer offers, whether images are signed, and how the update is rolled out across the fleet. We go into more depth in our IoT device management guide.
One more point that gets forgotten: the decoder that turns each model's bytes into values is also code that runs on your data. Keeping it in one place, versioned and tested, as we describe in our guide to LoRaWAN payload decoders, cuts down on errors and surprises.
LoRaWAN Security at the Gateway: The Most Neglected Link
Many people think of a gateway as a repeater, but it's a small Linux computer hanging on a roof or in a server closet, with a web admin interface, remote access, and an internet connection. It can't read the content of frames, because it doesn't have the AppSKey, but it can stop forwarding them, open a door into the network it's connected to, or become a foothold for other attacks.
What to Check on Every Gateway
- Passwords: change the factory one on day one, use a different one per gateway, and keep them in the team's password manager, not on a sticky note.
- Open services: turn off what you don't use (Telnet, password-based SSH, the admin web exposed to the internet).
- Firmware: keep it updated and subscribe to the manufacturer's security advisories.
- Connection to the network server: Semtech's classic packet forwarder runs over UDP, unencrypted and unauthenticated. Modern alternatives such as LoRa Basics Station run over TLS and authenticate the gateway. If your network server and gateways support it, use it.
- Backhaul: a gateway with its own 4G uplink or a VPN doesn't share a network with the customer's systems. In a factory or a hospital, that heads off a lot of arguments with IT.
- Physical security: a locked enclosure, mounted out of easy reach, and, if the model supports it, an alert when the case is opened.
Gateways Need Watching Too
A gateway that stops reporting, or suddenly receives far more frames than usual, is a signal worth checking. Most network servers show each gateway's status and last contact time: someone has to look at it or, better, get an alert when one goes quiet for too long. It's the same logic we describe in secure industrial remote access: first know what's happening without opening doors, and only then go in.
MQTT Security: TLS, Credentials, and Topics
MQTT shows up in two places in an IoTITermIoT (Internet of Things)The IoT (Internet of Things) is the network of physical objects with sensors, software and connectivity that collect and exchange data and act autonomously.View profile project: on devices that publish directly (industrial gateways, Wi-Fi or cellular devices) and in the integration between the network server and the platform. The same rules apply to both. If you need a refresher on how the protocol works, see our MQTT broker guide.
Always Over TLS
Unencrypted MQTT runs on port 1883 in plain text: username, password, and data included. With TLS, usually on port 8883, the connection is encrypted and the client can check that it's talking to the right server. The OASIS MQTT 5.0 specification leaves transport security to TLS, so switching it on is up to you.
A common mistake: the device firmware connects over TLS, but with certificate verification disabled because it caused trouble during testing. The traffic is encrypted, but the device would talk to any server pretending to be yours. Check that verification is on, and that the device knows what to do when the server's certificate is renewed.
One Credential per Device or Integration
As with LoRaWAN keys, a password shared across the fleet turns one compromised device into a fleet-wide problem. Use one credential per device or, at the very least, per integration and per customer, and have a way to change it without sending someone to the field.
Topics and Permissions
In MQTT, whoever can write to a topic can inject fake data, and whoever can read a wildcard (`#`) can read everything. Design your topic structure so each credential publishes only to its own topics, and check what your broker supports for per-topic permissions. Watch out for two useful features that get overlooked: retained messages (`retain`), which are stored and delivered to anyone who subscribes later, and the last will message (`will`), which can carry information you don't want exposed.
The Integration and the People: The Stretch Nobody Reviews
Between the network server and the platform there's a hop that almost never makes it into the diagrams: the integration. It may be an HTTPS webhook the network server calls on every uplink, or an MQTT connection. A few rules for that stretch:
- Always HTTPS, with the authentication key in a header, never in the URL. URLs end up in server logs, proxies, and monitoring tools.
- API keys with just enough scope: one per integration, able to do only what that integration needs, with a plan to rotate it.
- Validate what arrives: an uplink in an impossible format, a value out of range, or a device that doesn't exist gets rejected or flagged, not stored as if nothing happened.
Then there are the people. In a project with an integrator, an end customer, and a maintenance contractor, technicians from several companies pass through the platform over the years. The rules are those of any critical system: everyone with their own account, the minimum permissions for their job, two-factor authentication, single sign-on when the customer's company uses it, a record of who did what, and access removed the same day someone leaves the project. If an integrator runs several customers from one instance, the separation between customers is part of security. We explain it in our multi-tenant architecture guide.
Watch for What Doesn't Fit
LoRaWAN security doesn't end on commissioning day. It's worth setting alarms for unusual patterns:
- Devices sending join requests many times in a row.
- Frame counter or integrity errors on the network server.
- A sensor that suddenly reports every minute when it normally reports every fifteen.
- Gateways that disappear or change location.
- Logins from countries where nobody on the project works.
What the Cyber Resilience Act Brings
For manufacturers, and for anyone selling devices under their own brand in the European Union, security is becoming a legal obligation as well. Regulation (EU) 2024/2847, known as the Cyber Resilience Act, requires products with digital elements to be designed securely, shipped without known default passwords, and kept supplied with security updates over their lifetime. The obligation to report actively exploited vulnerabilities applies from September 2026, and most other obligations from December 2027. If you build or brand sensors, it's worth checking now what applies to you.
How Cloud Studio IoT Handles It
Cloud Studio IoT is a white-label IoT platform for system integrators and device manufacturers. In a LoRaWAN deployment it doesn't replace the network server: data arrives from whichever one the project uses. There are integrations with The Things Stack, LORIOT, ThingPark X, ChirpStackCTermChirpStackChirpStack is an open-source LoRaWAN Network Server to deploy and manage private end-to-end LoRaWAN networks.View profile, Helium, and Orbiwise, and the platform can receive from several at once. LoRaWAN keys stay where they belong, in the network server, and the platform receives data that has already been validated. Our LoRaWAN solutions page explains how it fits together.
For devices that publish directly, each instance has its own MQTT server with TLS on port 8883. The username and password are managed in Gear Manager, under Security > MQTT Configuration, and data comes in on topics such as `{MQTTUserID}/uplink/{DeviceAddress}`. There's also a documented HTTPS API.
On the platform itself, the documented security includes 2048-bit SSL encryption, granular per-user permissions, single sign-on (SSO), native two-factor authentication, continuous vulnerability scanning, separation between customers through permissions, and an audit trail of user actions. Alarms, such as a device that stops reporting, go out by email, SMS, WhatsApp, voice call, or push notification.
When a customer doesn't want data leaving its network, the platform can be installed on-premise and run without internet access, with a network server such as ChirpStack inside the customer's own network. One of our customers came to Cloud Studio IoT after an open-source platform built on Grafana was hacked: having the platform maintained and updated by a dedicated team is a security decision too. The rest of the capabilities are on the IoT platform page.
Conclusion
The LoRaWAN and MQTT security of a deployment depends on its weakest link, and that's rarely the encryption. The essentials:
- A different AppKey per device, delivered through a secure channel, and OTAA by default.
- Gateways treated as computers: their own password, minimal services, up-to-date firmware, and a TLS connection to the network server.
- MQTT always over TLS on 8883, with certificate verification on and one credential per device or integration.
- Integrations over HTTPS, with narrowly scoped API keys kept out of URLs.
- Named accounts, two-factor authentication, least privilege, and same-day offboarding.
- Alarms for what doesn't fit: repeated joins, frame counter errors, and gateways that vanish.
If you're preparing a deployment and want to review the whole chain before the first sensor goes up, talk to the team.
Frequently Asked Questions
Is LoRaWAN secure?
The protocol is: it encrypts and signs every frame with AES-128 and uses counters to block replayed messages. In practice, LoRaWAN security depends on key management, the activation method (OTAA is better), and how gateways, integrations, and users are protected.
What's the security difference between OTAA and ABP?
With OTAA, every time the device joins the network, new session keys are generated. With ABP, the keys are fixed and the device depends on frame counters, which cause problems when it reboots. For deployments that will last years, OTAA is the recommended option.
Can a LoRaWAN gateway read sensor data?
It can't read the content, because it's encrypted with the AppSKey, which the gateway doesn't have. It can stop forwarding frames, or become an entry point into the network it's connected to if it isn't protected. That's why you should change its passwords, close services, and use an encrypted connection to the network server.
Which port does MQTT over TLS use?
The usual port is 8883. Port 1883 is unencrypted MQTT and shouldn't be used outside a lab.
Does every sensor need its own MQTT password?
It's the recommended approach. If the whole fleet shares a credential, a single compromised device can publish fake data on behalf of all of them. At a minimum, use one credential per integration and per customer.
Verwandte Artikel

LoRaWAN Payload Decoder: How to Integrate Any Sensor
A LoRaWAN payload decoder turns the few bytes a sensor sends into values a platform can store, chart, and alarm on. It is where most integrations break.

LoRaWAN Battery Life: How Long It Really Lasts and Why
LoRaWAN battery life is quoted as ten years on most datasheets, yet many sensors die after three, and the gap is almost always in the radio settings.

LoRaWAN Range: What to Expect in Real IoT Deployments
The LoRaWAN range on the datasheet, those 15 kilometers, is true and almost never yours, and the gap between those two numbers gets paid for in the field.
Bereit, Ihr Unternehmen zu transformieren?
Kontaktieren Sie uns und erfahren Sie, wie Cloud Studio IoT Ihnen helfen kann, Ihre Ziele zu erreichen.
