An ESP32-based access-control device can look simple. A user presents an RFID card, uses a phone over BLE, or requests access through a cloud application. The device checks permission and releases a door. Yet that unlock depends on firmware, credentials, wireless communication, cloud services, authorization logic, wiring and the physical lock.
That is why the first question in an IoT access-control project should not be “Which encryption algorithm should we use?” It should be “What are we protecting, who might attack it, and where are the trust boundaries?”
For an ESP32 or ESP32-S3 product, security starts with architecture. Cryptography, Secure Boot, TLS, credential security and tamper detection are controls that must answer specific threats. If they are added without a threat model, it is easy to secure one path while leaving another exposed.
Figure 1. A practical ESP32 access-control trust chain. Author-created diagram; concepts informed by Espressif platform-security guidance and NIST IoT baseline capabilities [1, 6–8].
A door unlock is a chain of trust
Consider a typical system: an ESP32-S3 communicates with an RFID/NFC reader and perhaps a smartphone over BLE. It connects to a backend using Wi-Fi. The backend manages identities and permissions. Somewhere in the system, a controller activates a relay that unlocks the door.
Treat every transition as a trust decision. Can the device trust its firmware? Can the backend trust this device? Can the device trust the server? Can the reader trust the credential? Can a captured command be replayed? Can someone remove the wall reader and reach the relay?
Security is therefore not a single “secure communication” feature. It is a set of boundaries that must protect the access decision from boot to physical actuation.
Start with the threat model
Before enabling security features, list realistic attacker positions. A remote attacker may intercept traffic, abuse an API or impersonate a device. A nearby attacker may target BLE or RFID. A physical attacker may open the enclosure, access debug pads, read flash or connect directly to wiring.
Physical access matters especially in access control. A door reader is often intentionally placed where an untrusted person can reach it. We should therefore assume that an attacker may eventually touch the enclosure.
The threat model should also include operational failure. What happens if Wi-Fi is unavailable, a certificate expires, a device is compromised or an OTA update fails? Security and reliability are closely connected in a system that controls a physical door.
Figure 2. Threat categories to consider before selecting controls. Author-created diagram; use it as a workshop prompt rather than an exhaustive threat model.
Trust the software before trusting the messages
If an attacker can replace the firmware on an ESP32, the strongest application protocol will not save the system. Modified firmware could bypass authorization or expose decrypted information.
ESP32-S3 provides features that can establish a stronger root of trust. Secure Boot v2 verifies signed bootloader and application images. Flash Encryption protects off-chip flash, while NVS encryption can protect configuration and credentials. Production devices should also be reviewed for unnecessary debug or download interfaces [6–8].
These controls solve different problems. Secure Boot protects authenticity and integrity of executable code. Flash Encryption protects information at rest. NVS protection is useful for secrets and configuration. None replaces the others.
A practical design question is: if someone removes the controller, clips onto the flash chip and accesses the PCB, what useful information or control should they still be able to obtain?
Identity comes before authorization
A common prototype pattern is to give every unit the same API key or shared secret. That becomes dangerous at scale: if one shared secret appears in hundreds of devices, compromising one unit can become a fleet-wide problem.
A stronger strategy is to give each device its own identity and credentials. The backend can authenticate a specific controller, revoke one device without disabling the fleet, rotate credentials and associate logs with an individual unit.
The same principle applies to access credentials. Identifying a card is not the same as authenticating it, and authentication is not the same as authorization. Keeping those concepts separate makes the software easier to review.
Secure the channel, then secure the command
TLS should be a normal part of ESP32-to-cloud communication. HTTPS or MQTT over TLS protects data in transit and authenticates the server when certificates are validated correctly. Mutual authentication may also be appropriate.
For high-value commands such as UNLOCK, think beyond the channel. A message can carry device identity, protocol version, counter, nonce, command data and an authentication tag. AES-GCM or ChaCha20-Poly1305 can provide confidentiality and integrity at message level.
This does not mean replacing TLS. TLS protects a connection. Application-level protection can make an individual command self-verifying and support anti-replay checks.
Physical access changes the architecture
One of the most important lessons in access-control design is that the relay is part of the security boundary.
If the ESP32 reader and door-release relay are both mounted outside the protected area, an attacker may not need to attack TLS, RFID or encryption. They may only need to remove the reader and drive the relay wiring directly.
A stronger architecture separates the exposed reader from the trusted controller. The outside unit reads the credential and communicates with an internal controller over an authenticated link. The internal controller performs or confirms the final authorization and controls the relay on the secure side of the door.
This also means the reader-to-controller protocol must be protected so that replacing the reader with a fake device does not create an easy unlock path.
What We Learned While Working Through This Problem
As we worked through the security architecture for ESP32-based access-control systems, our perspective evolved from focusing on individual security features to evaluating the complete system.
At first, encryption can appear to be the center of the problem: protect the data, use TLS, and secure the communication channel. But when we evaluate an access-control product from an attacker’s perspective, that view is too narrow.
The more useful questions are practical ones. What happens if an encrypted unlock command is replayed? What if an RFID credential can be copied or emulated? What if the firmware is replaced? What if someone physically removes the reader? What happens if a shared device secret is extracted from one controller?
Each of these scenarios represents a different attack path and therefore requires a different control.
This has shaped the way we approach ESP32 security. Secure Boot, Flash Encryption, encrypted NVS, TLS, application-level cryptography, device identity, and physical controller separation should not be treated as isolated features. They protect different points in the same access decision.
Our goal is to understand the threat first, select the appropriate control, configure it correctly for production, and then verify that the implementation remains practical within the memory, latency, power, cost, and maintainability constraints of an embedded product.
Our engineering principle: Do not ask whether the device simply “has security.” Ask whether the complete access decision remains protected when one security layer is attacked, bypassed, compromised, or unavailable.
Standards give us a useful baseline
Standards and guidance reduce the chance that a product team forgets an entire class of security requirements. They do not replace a product-specific threat model, but they provide a disciplined checklist. For an ESP32 access controller, the following five references are particularly useful.
|
Standard / guidance |
What it emphasizes |
Practical ESP32 access-control takeaway |
|
NISTIR 8259A [1] |
Core device capabilities: identification, authorized configuration, data protection, logical access to interfaces, software update and cybersecurity state awareness. |
Plan unique device identity, protect stored data and interfaces, support authenticated updates, and expose useful security state. |
|
ETSI EN 303 645 [2] |
Consumer-IoT baseline covering credentials, vulnerability reporting, updates, secure storage, secure communication and attack-surface reduction. |
Avoid universal credentials, design an update process, protect secrets, minimize unnecessary interfaces and provide a vulnerability path. |
|
ISO/IEC 27402:2023 [3] |
Baseline IoT device requirements supporting security and privacy controls across the device lifecycle. |
Treat secure configuration, documented security capabilities, support periods and lifecycle responsibilities as product requirements. |
|
IEC 62443-4-2 [4] |
Component security through identification/authentication, use control, integrity, confidentiality, restricted flow, event response and availability. |
Useful for higher-assurance controllers: separate privileges, protect integrity, log security events and consider availability under attack. |
|
EN 18031-1:2024 [5] |
Common cybersecurity requirements for internet-connected radio equipment in the European regulatory context. |
For Wi-Fi/BLE products, bring cybersecurity into radio-product design and compliance planning from the beginning, not after firmware is finished. |
Table note: These are engineering summaries, not compliance determinations. Use the official publications and applicable legal/regulatory advice for formal conformity work.
Where to start
Do not start with a long list of cryptographic settings. Draw the access path and mark trust boundaries. Identify components outside the secure area and secrets stored in the device. Decide how devices are identified, how updates are authenticated and what happens when the cloud is unavailable. Then map threats to controls such as Secure Boot, Flash Encryption, secure storage, TLS, authenticated messages and physical controller separation.
That architecture becomes the foundation for the rest of the series. The next step is to go deeper into the ESP32 itself: how Secure Boot, Flash Encryption, eFuse configuration, debug restrictions and secure storage help us decide whether we can trust the device before we trust anything it tells us.
References
[1] NIST IR 8259A, IoT Device Cybersecurity Capability Core Baseline. Official source
[2] ETSI EN 303 645 V3.1.3, Cyber Security for Consumer Internet of Things: Baseline Requirements. Official source
[3] ISO/IEC 27402:2023, Cybersecurity — IoT security and privacy — Device baseline requirements. Official source
[4] IEC 62443-4-2:2019, Security for industrial automation and control systems — Technical security requirements for IACS components. Official source
[5] EN 18031-1:2024, Common security requirements for radio equipment — Part 1: internet connected radio equipment; cited in EU Implementing Decision 2025/138. Official source
[6] Espressif, ESP32-S3 Secure Boot v2, ESP-IDF Programming Guide. Official source
[7] Espressif, ESP32-S3 Flash Encryption, ESP-IDF Programming Guide. Official source
[8] Espressif, ESP32-S3 Non-Volatile Storage / NVS Encryption, ESP-IDF Programming Guide. Official source
[9] NIST IR 8259 Rev. 1 (2026), Foundational Cybersecurity Activities for IoT Product Manufacturers. Official source




