Access Control in the Rfid Network of a Makespace

For the past months I have been participating in a makerspace in Madrid and now is the time to implement some level of access control to the space.

This is one of those opportunities to develop end to end projects.

The challenge

The idea is to install RFID sensor stations around the space in order to provide a second access method to the space while the keys are open and to authenticate access to the machines in a granular manner.

This involves maintaining an access control list or ACL for each RFID station group on the network.

An RFID station group is nothing more than the system composed of the RFID reader and the set of actuators that will react to a RFID reading event.

For example, a door enabled with a RFID reader will publish a message to a MQTT message queue to which the actuators will be subscribed to. On reception, the actuators will activate and open the door.

The question here is how do we authenticate the RFID card.

We could hardcode the access control list inside the RFID reader, which sounds like a terrible idea that would make it difficult to update the state of that ACL and obtain additional logs and metrics. The difficulty increases if we need to manage multiple RFID stations.

This calls for the need of maintaining the state of that ACL on a server in the network that any device can query to know if the RFID card belongs to its corresponding ACL.

The idea would be for:

In addition to this, we need to choose a viable data layer for our access control lists. However, we can manage by using a simple SQLite database for now.

To begin the definition of this architecture, we will use the C4 Model, which provides a way to formally define what we need and what we want to build.

System Context

The system context involves a high level view of what we need to build.

System Context

On this diagram we define the follwing actors.

We also define three systems.

Data model

Regarding the data model, we will begin with something simple. However, this is expected to suffer changes.

Basic Data Model

This data model essentially shows the structure of the ACL tree we need to maintain for all RFID stations in the network.

Our assumptions involve that:

There are some unknowns in this model that we will need to address in the future in order to integrate it with other systems.

For example, the RfidIdentity could contain additional parameters such as the username of the cardholder.

We could also define roles on the system that provide different levels of access control.

We need to define how administrators of the service will log into it. The best solution would involve deploying a centralized solution such as Active Directory or LDAP, which could allow integration of the same user accounts over multiple systems. However, this requires further investigation, as the makespace still does not have such a solution in place.

A simple user and password can be used to assemble the core functionality of the service until a more stable solution is available.

Container Context

Container Context

Here we will focus on two systems, the RfidStation and the RfidApp.

First we will define the simplest one but not the least important, the RfidStation.

The RfidStation will be implemented using inexpensive Arduino hardware and a ESP32, which has a Wi-Fi device to connect to the wireless network for the domotics in the space.

The firmware of the ESP32 is installed via OTA from a ESPHome server in the network, which will allow us to update it without connecting it to the computer. The access to the Wi-Fi network, the MQTT server and the HTTP REST API will be hardcoded in the firmware and not expected to change unless we do it through the OTA in ESPHome.

The RfidStation will have an updated ACL in its temporal memory at all times given these two assumptions:

The RfidStation will check this ACL before sending the MQTT message to the right actuator. In order to avoid brute force attacks there should be an incremental delay after each failed access attempt.

Second is the RfidApp we want to develop.

The RfidApp is composed of three components.

Regarding security of the WebApp interfaces.

Message Queue Protocol

We will need to define the protocol for the messages in que MQTT broker, this will involve the topics themselves and the MQTT messages.

Regarding the MQTT topics, we will define two types.

Regarding the first kind, they will depend on the specific logic of the RfidStation and are outside the scope for this project.

The second kind are topics for each RfidStation and will be defined by the notation “acl-update-rfidstation-[ID]” where the ID will be the ID of the RfidStation. This will assure that for each topic there is only one listener, the RfidStation itself, so that there are no unnecessary forwardings over the network.

It would be nice to have some kind of feedback from the subscriber that a subscription has been achieved.

We will need to define the following messages

We could also implement atomic updates of ACL IDs, but this would imply more complexity and we want to keep the first version simple and stupid, but reliable. Atomic updates would be useful for very long ACL lists that change a lot, but this is not expected to be the case.

We also want a wake-up event published by the RfidStation in the “acl-update-rfidstation-[ID]” topic for logging and debugging purposes.

All the events regarding the MQTT message queue will need to be posted on the Web App to provide feedback to the administrator or be written to a log file in the server.

Use cases for the web interface.

This is a high level view of the objectives that we want to achieve with the web UI. We can get as fancy as we want here, but these objectives need to be achieved.

We will model the web interface as a state machine of the different views.

The web interface is meant to be an administrator console that is able to complete the following tasks.

Ideally we want all these actions to be scriptable in order to easily test the backend and add extensions on the future.

Conclusion

We could go deeper in detail using the C4 model, but I believe that we first need a prototype in order to make further decisions without making too many assumptions. Consider this a first draft that might be subject to changes.

See you in the next one.

whoami

Jaime Romero is a software developer and cybersecurity expert operating in Western Europe.