Difference between revisions of "Empirische Untersuchung zur M2M-Authentifizierung"

From Embedded Lab Vienna for IoT & Security
Jump to navigation Jump to search
(Created page with " Die M2M-Authentifizierung (Machine-to-Machine) ist ein entscheidender Aspekt in der Internet der Dinge (IoT), da sie es Geräten ermöglicht, sichere Kommunikation miteinander zu führen. In dieser empirischen Untersuchung wurden verschiedene Authentifizierungsprotokolle untersucht, darunter LDAP, SAML, OAuth2 und Kerberos. == LDAP == LDAP (Lightweight Directory Access Protocol) ist ein weit verbreitetes Verzeichnisdienstprotokoll, das zum Speichern und Abrufen von In...")
 
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:


Die M2M-Authentifizierung (Machine-to-Machine) ist ein entscheidender Aspekt in der Internet der Dinge (IoT), da sie es Geräten ermöglicht, sichere Kommunikation miteinander zu führen. In dieser empirischen Untersuchung wurden verschiedene Authentifizierungsprotokolle untersucht, darunter LDAP, SAML, OAuth2 und Kerberos.
Machine-to-machine (M2M) authentication is a crucial aspect of the Internet of Things (IoT) as it enables devices to communicate securely with each other. In this empirical study, various authentication protocols were investigated, including LDAP, SAML, OAuth2 and Kerberos.
 
Code parts for this project can be found on [https://git.fh-campuswien.ac.at/c2110475053/wfp2_m2m GitLab].


== LDAP ==
== LDAP ==


LDAP (Lightweight Directory Access Protocol) ist ein weit verbreitetes Verzeichnisdienstprotokoll, das zum Speichern und Abrufen von Informationen verwendet wird. Es kann jedoch komplex sein, insbesondere wenn es um die Einrichtung geht. Trotzdem bietet es eine robuste und flexible Lösung für die Authentifizierung.
LDAP (Lightweight Directory Access Protocol) is a widely used directory access protocol that is used to store and retrieve information. However, it can be complex, especially when it comes to setup. Nevertheless, it offers a robust and flexible solution for authentication.
 
To set up the LDAP server, [https://computingforgeeks.com/install-and-configure-openldap-server-ubuntu/ this] instructions were used. However, as the creation of a group or user with .ldif files is very error-prone, it is recommended to install an Apache2 server and manage the accounts via the GUI (see [https://computingforgeeks.com/install-and-configure-ldap-account-manager-on-ubuntu/ Link]). No password can be added to a user account via the GUI, which is why an additional [https://ubuntu.com/server/docs/service-ldap-usage CLI tool] is required. Unfortunately, the standard configuration leads to many bugs, which is why it must be replaced by [https://ubuntuforums.org/archive/index.php/t-1488232.html this].
 
* Note: If .ldif files are to be read in with the command <code>ldapadd -x -D cn=admin,dc=example,dc=com -W -f example.ldif</code> and the error message "ldapadd: attributeDescription "dn": (possible missing newline after line 5, entry "ou=people,dc=wfp2,dc=example,dc=com"?)" is displayed, the problem is the lines between the entries that are supposedly empty. A space or several spaces lead to this problem. Instead, \n\n is provided between the account configurations.
 
To use public key authentication, a key pair must first be generated. Once the key pair has been generated, it can be added to the LDAP server using the <code>ldapadd</code> command. The private key remains on the device, while the public key is stored on the LDAP server. During authentication, the public key is then checked against the private key on the device.


Zum Aufsetzen des LDAP Servers wurde [https://computingforgeeks.com/install-and-configure-openldap-server-ubuntu/ diese] Anleitung verwendet. Da allerdings das Anlegen einer Gruppe beziehungsweise eines Nutzers mit .ldif-Dateien sehr fehleranfällig ist, ist es empfehlenswert einen Apache2 Server zu installieren und die Accounts über die GUI zu managen (siehe [https://computingforgeeks.com/install-and-configure-ldap-account-manager-on-ubuntu/ Link]). Allerdings lässt sich einem erstellten Nutzeraccount kein Passwort über die GUI hinzufügen, weshalb zusätzlich ein weiters [https://ubuntu.com/server/docs/service-ldap-usage CLI-Tool] notwendig ist. Bei diesem führt die Standardkonfiguration leider zu vielen Bugs, weshalb diese durch [https://ubuntuforums.org/archive/index.php/t-1488232.html diese] ersetzt werden muss.
There are three different types of authentication in LDAP:


Interessant ist, dass ein nicht authentifizierter Nutzer mit dem Befehl <code>ldapsearch -x -LLL -H ldap://ldap.wfp2.example.com -b dc=wfp2,dc=example,dc=com dn</code> alle Einträge des LDAP Servers abrufen und so die Struktur der Gruppen und deren Nutzer einsehen kann. Hier muss angemerkt werden, dass ein DNS Server mit der Domaine <code>wfp2-example.com</code> aufgesetzt wurde.  
* Anonymous Authentication Mechanism of Simple Bind is used for anonymous authentication of a client. This can be useful if data should be accessible to all users. With the command <code>ldapsearch -x -LLL -H ldap://ldap.wfp2.example.com -b dc=wfp2,dc=example,dc=com dn</code>, for example, all entries of the LDAP server can be retrieved, allowing the structure of the groups and users to be viewed. It should be noted here that a DNS server with the domain <code>wfp2-example.com</code> has been set up.


[[File:Ldap_unauthorized_access_to_usernames.png|500px|thumb|right|ldapsearch]]
[[File:Ldap_unauthorized_access_to_usernames.png|500px|thumb|right|ldapsearch]]


Im Gegensatz zu dem oben angeführten Befehl kann mit <code>ldapwhoami -x -H ldap://ldap.wfp2.example.com -D "cn=ubuntumachine1001,ou=people,dc=wfp2,dc=example,dc=com" -W</code> ein User in der CLI authentifiziert und anschließend autorisiert werden. Bei diesem Befehl ist zusätzlich anzumerken, dass der Parameter -W eine Eingabe des Passwortes in extra anfordert. Wird stattdessen -w verwendet, so kann das Passwort direkt in dem Befehl angegeben werden (-w <Passwort>).
* In contrast to the above command, <code>ldapwhoami -x -H ldap://ldap.wfp2.example.com -D "cn=ubuntumachine1001,ou=people,dc=wfp2,dc=example,dc=com" -W</code> can be used to authenticate and then authorize a user in the CLI. With this command, it should also be noted that the -W parameter requires the password to be entered in extra. If -w is used instead, the password can be specified directly in the command (-w <password>). This authentication is called "Name/Password Authentication Mechanism of Simple Bind".
 
* The third group "Unauthenticated Authentication Mechanism of Simple Bind" allows only one user name to be entered. In this case, the password field remains empty.


[[File:ldap_authorization_cli.png|500px|thumb|right|ldapwhoami]]
[[File:ldap_authorization_cli.png|500px|thumb|right|ldapwhoami]]


Mit dem Befehl <code>ldapsearch -x -H ldap://ldap.wfp2.example.com -D "cn=ubuntumachine1001,ou=people,dc=wfp2,dc=example,dc=com" -W -b "dc=wfp2,dc=example,dc=com"</code> fragt der User ubuntumachine1001 alle verfügbaren LDAP Accounts ab. Anzumerken ist hier, dass ubuntumachine1001 kein Admin-User ist.
With the command <code>ldapsearch -x -H ldap://ldap.wfp2.example.com -D "cn=ubuntumachine1001,ou=people,dc=wfp2,dc=example,dc=com" -W -b "dc=wfp2,dc=example,dc=com"</code> the user ubuntumachine1001 queries all available LDAP accounts. It should be noted here that ubuntumachine1001 is not an admin user.


[[File:Ldapsearch_teilausschnitt.png|500px|thumb|right|ldapsearch]]
[[File:Ldapsearch_teilausschnitt.png|500px|thumb|right|ldapsearch]]


Eine M2M Authentifizierung mittels LDAP mithilfe eines Passwortes ist also möglich, ist allerdings nicht zu empfehlen. LDAP bietet auch die Möglichkeit einen User mithilfe eines asymmetrischen Schlüssels zu authentifizieren. Ebenfalls unterstützt das Protokoll  Challenge-Response-Verfahren.
An M2M authentication using LDAP with the help of a password is therefore possible, but is not recommended. LDAP also provides the ability to authenticate a user using an asymmetric key. The protocol also supports challenge-response procedures.


Bezüglich der Sicherheit von LDAP ist anzumerken, dass mit hoher Wahrscheinlichkeit der Apache2 Server die größte Schachstelle aufweist. Da Usernamen unautorisiert ausgelesen werden können, kann hier mit Brute-Force-Verfahren gearbeitet werden.
Regarding the security of LDAP, it should be noted that with a high probability the Apache2 server has the largest chess site. Since usernames can be read out without authorization, brute force methods can be used here.


== SAML ==


== SAML ==
SAML (Security Assertion Markup Language) is an XML-based standard used for authentication and authorization. It has been found that SAML is difficult to set up, especially when it comes to creating your own SAML identity provider. Since this did not work with the help of various [https://shibboleth.atlassian.net/wiki/spaces/SP3/pages/2067398689 online instructions], [https://auth0.com/de Auth0] was used as an alternative. Auth0 is a cloud-based identity management service that offers a user-friendly interface and supports all common authentication methods (password, token, challenge-response, public-key-crypto).


SAML (Security Assertion Markup Language) ist ein XML-basiertes Standard, der zur Authentifizierung und Autorisierung verwendet wird. Es wurde festgestellt, dass SAML schwer einzurichten ist, besonders wenn es darum geht, einen eigenen SAML Identity Provider zu erstellen. Da dies auch mithilfe von diversen [https://shibboleth.atlassian.net/wiki/spaces/SP3/pages/2067398689 Online-Anleitungen] nicht funktioniert hat wurde als Alternative [https://auth0.com/de Auth0] verwendet. Auth0 ist ein Cloud-basierter Identitätsverwaltungsdienst, welcher eine benutzerfreundliche Oberfläche bietet und alle gängigen Authentifizierungsmethoden (Passwort, Token, Challenge-Response, Public-Key-Crypto) unterstützt.
An X.509 certificate is used for public key authentication in SAML. The private key remains (as usual) on the client device while the certificate is issued and deposited by the SAML Identity Provider. During authentication, the certificate is then checked against the private key on the device.


Anmerkung 1: Bei einer Token basierten Authentifizierung müssen verschiedene Parameter (client_id, client_secret, audience, grant_type) übermittelt werden. Da diese - wie ein Passwort - auf der Maschine gespeichert werden müssen, ist neben der höheren Sicherheit gegenüber Brute-Force-Angriffen kein Mehrwert vorhanden.
Note 1: For token-based authentication, several parameters (client_id, client_secret, audience, grant_type) must be passed. Since these have to be stored on the machine - like a password - there is no added value apart from the higher security against brute force attacks.


[[File:Saml_settings.png|500px|thumb|right|SAML settings]]
[[File:Saml_settings.png|500px|thumb|right|SAML settings]]


Anmerkung 2: Die Konfiguration von SAML ist langwierig, da durch die verschiedenen Schlüssel und Endpoints sehr viele Fehlerquellen vorhanden sind. Zusätzlich werden in jedem Request beziehungsweise in jedem Response sehr viele Daten mitgegeben, welche in einer Produktions-Umgebung aus Sicherheitsgründen verarbeitet werden sollten.  
Note 2: The configuration of SAML is tedious, as there are many sources of error due to the different keys and endpoints. In addition, a lot of data is provided in each request or response, which should be processed in a production environment for security reasons.


[[File:Saml_response.png|500px|thumb|right|SAML response]]
[[File:Saml_response.png|500px|thumb|right|SAML response]]


== OAuth2 ==
OAuth2 is an authorization framework that allows users to securely share their access to their data with third-party applications. In this context, GitHub and Auth0 were used as authorization servers. It was not possible to host the authorization server locally because there were no open source libraries available. Compared to SAML, OAuth2 is very user-friendly. Setting up the server was very quick and easy with GitHub and Auth0.
However, GitHub has the disadvantage that only the credentials for existing GitHub accounts can be used. For machine-to-machine (M2M) authentication, this means that only one password authentication is possible. Auth0, as with SAML, allows all common authentication options to be used.
In OAuth2, public key authentication is achieved by using JWT (JSON Web Tokens). A JWT contains a header that contains information about the algorithm used, and a body that contains the actual data. The header and body are then signed with the device's private key. When verifying the validity of the token, the token is verified with the public key of the device.
== mTLS ==
mTLS (Mutual Transport Layer Security) is a method of mutual authentication that ensures that both parties exchanging information are who they claim to be by verifying that they both have the correct private key.
In detail, mTLS works very similar to the TLS protocol. However, there is an additional step before the key exchange. The client sends its public key and certificate to the server, which identifies it from the server to confirm that the request comes from a known client and has the private key that corresponds to the client's shared public key.


== OAuth2 ==
In contrast to TLS, an internal certification authority is required to implement mTLS. This is provided by the X.509 Certificates for all clients and servers, so that each certificate has the same root certificate. Authentication is based on this match. The root certificate is self-signed in this case. The advantage of mTLS is that various attacks, such as on-path attacks, credential stuffing, are unsuccessful.


OAuth2 ist ein Autorisierungsframework, das es Benutzern ermöglicht, ihren Zugang zu ihren Daten auf sichere Weise mit Drittanbieter-Anwendungen zu teilen. In diesem Fall wurde im ersten Fall GitHub und im zweiten Fall Auth0 als Autorisierungsserver verwendet. Den Autorisierungsserver lokal zu hosten war nicht möglich, da es keine Open-Source Bibliotheken gibt. Im Vergleich zu SAML ist OAuth2 sehr benutzerfreundlich. Das Aufsetzen des Servers hat bei GitHub als auch Auth0 sehr schnell und einfach funktioniert. GitHub hat allerdings den Nachteil, dass nur die Zugangsdaten für vorhandene GitHub-Konten verwendet werden können. Dies bedeutet für eine M2M Authentifizierung, dass nur eine Passwort Authentifizierung möglich ist. Bei Auth0 können - wie bei SAML - alle gängigen Authentifizierungsmöglichkeiten verwendet werden.  
mTLS provides more security than TLS because it verifies the identity of both the server and the client. However, it is more compute-intensive than TLS, making it less suitable for scenarios where lower latency is a priority over Zero Trust security.


== Kerberos ==
== Kerberos ==


Kerberos ist ein Netzwerkauthentifizierungsprotokoll, das auf einem Ticket-Granting-Ticket-System basiert. Obwohl es für das Windows Active Directory entwickelt wurde, ist es in Ubuntu einfach zum einrichten und zum verwenden. Kerberos verlangt allerdings die Verwendung von Domain-Namen. es werden keine IP Adressen akzeptiert, weshalb zusätzlich ein DNS-Server aufzusetzen ist.
Kerberos is a network authentication protocol based on a ticket-granting ticket system originally designed for Windows Active Directory. Kerberos can be easily set up and used in Ubuntu. However, it is important to note that Kerberos requires the use of domain names (for a "simple" configuration), which is why a DNS server must be set up in addition. For a configuration without DNS server, see [https://stackoverflow.com/questions/53290348/how-to-setup-kerberos-realm-without-domain-name Link] (not tested).


Für die Konfiguration vom Kerbers Server wurden die Schritte in [https://ubuntu.com/server/docs/service-kerberos dieser] Anleitung durchgeführt. Der Client benötigt [https://ubuntu.com/server/docs/service-kerberos-workstation-auth diese] Library, um ein Ticket beantragen zu können. Mit dem Befehl <code>kinit <username></code> kann ein Ticket vom Kerberos Key Distribution Center (KDC) beantragt und mit <code>klist</code> angezeigt werden.
For the configuration of the Kerbers server, the steps in [https://ubuntu.com/server/docs/service-kerberos of this] manual were carried out. The client requires [https://ubuntu.com/server/docs/service-kerberos-workstation-auth this] library to be able to request a ticket. With the command <code>kinit <username></code> a ticket can be requested from the Kerberos Key Distribution Center (KDC) and displayed with <code>klist</code>.


Offiziell unterstützt Kerberos nur eine Passwort-Authentifizierung. Mit zusätzlichen "Plug-In"s lässt sich dies um ein [//https://github.com/fuhry/kcrap Challenge-Response-Verfahren] oder eine [https://ieeexplore.ieee.org/document/6149941 Public-Key Cryptography] erweitern.  
Officially, Kerberos only supports password authentication. With additional "plug-ins" this can be extended by a [https://github.com/fuhry/kcrap Challenge-Response-Process] or a [https://ieeexplore.ieee.org/document/6149941 Public-Key Cryptography].


Bezüglich Kerberos ist auch zu erwähnen, dass es das Tool [https://github.com/ropnop/kerbrute Kerbrute] gibt, welches Kerberos Account auslesen und mithilfe von beispielsweise Dictionary-Attacks Passwörter auslesen kann. Allerdings kann Kerberos so konfiguriert werden, dass nach einer bestimmten Anzahl an Falscheingaben der Account gesperrt wird.
With regard to Kerberos, it should also be mentioned that there is the tool [https://github.com/ropnop/kerbrute Kerbrute], which can read Kerberos accounts and read passwords using dictionary attacks, for example. However, Kerberos can be configured so that the account is blocked after a certain number of incorrect entries.


Finally, it is important to note that Kerberos is only used for authentication and not for managing user groups, Linux UIDs and GIDs, home directories, etc. Therefore, another network source is normally used for this information, such as an LDAP or Windows server. In addition, Kerberos user principals must be manually added to the Kerberos server so that they can log in. This can be done with the <code>kadmin.local</code> commands.


== Fwknop ==
== Fwknop ==


[https://www.cipherdyne.org/fwknop/ Fwknop (Firewall Knocking Operation)] ist ein Tool, das es ermöglicht, den Zugriff auf einen Server zu steuern, indem es "knocks" an den Server sendet, um einen temporären Port öffnen zu lassen. Dies ist besonders nützlich in Umgebungen, in denen Zero Trust-Prinzipien angewendet werden. fwknop ist im Gegensatz zu vielen anderen Servicen ein Programm, welches keinen Port benötigt, weshalb es gegenüber Schwachstellen von außen sehr gut geschützt ist.  
[https://www.cipherdyne.org/fwknop/ Fwknop (Firewall Knocking Operation)] is a tool that allows you to control access to a server by sending "knocks" to the server to open a temporary port. This is particularly useful in environments where Zero Trust principles are applied. Unlike many other services, fwknop is a program that does not require a port, which is why it is very well protected against external vulnerabilities.  


Der sogenannte "knock" besteht dabei aus genau einem IPv4 Packet, welches zum Server geschickt und von diesem gedroppt wird, da keine entsprechende FW-Regel vorhanden ist. fwknop nimmt dieses gedroppte Packet und überprüft, ob die zur Verfügung gestellten Schlüssel gültig sind. Sind diese gültig, wird eine IP-Tables Regel für eine bestimmte Zeit (z.B. 5sec) geöffnet, in welcher der Client Zeit hat sich mit dem Service zu verbinden. Der Nachteil von fwknop ist, dass durch die begrenzte Anzahl an Byte in einem IPV4 Packet Schlüssel wie RSA4096 neben den anderen Parametern keinen Platz haben.
The so-called "knock" consists of exactly one IPv4 packet, which is sent to the server and dropped by it, because there is no corresponding FW rule. fwknop takes this dropped package and checks if the provided keys are valid. If these are valid, an IP-Tables rule is opened for a certain time (e.g. 5sec), in which the client has time to connect to the service. The disadvantage of fwknop is that due to the limited number of bytes in an IPV4 packet, keys such as RSA4096 do not have space among the other parameters.


Für die M2M Kommunikation ist dieses Tool grundsätzlich eine tolle Idee. Allerdings muss auch gesagt werden, dass fwknop nicht mehr weiter entwickelt wurde, weshalb es nur auf Ubuntu16 Maschinen funktioniert.
This tool is basically a great idea for M2M communication. However, it must also be said that fwknop has not been further developed, which is why it only works on Ubuntu16 machines.


== Zusammenfassung ==
== Summary ==


Diese empirische Untersuchung hat gezeigt, dass es viele verschiedene Möglichkeiten zur Authentifizierung in M2M-Umgebungen gibt, jede mit ihren eigenen Vor- und Nachteilen. Es ist wichtig, die spezifischen Anforderungen und Bedingungen Ihrer Umgebung zu berücksichtigen, um die beste Lösung für Ihre Bedürfnisse zu finden.
This empirical study has shown that there are many different ways to authenticate in M2M environments, each with its own advantages and disadvantages. It is important to consider the specific requirements and conditions of your environment in order to find the best solution for your needs.


{| class="wikitable" style="border: 2px solid #000000;"
{| class="wikitable" style="border: 2px solid #000000;"
|-
|-
! Protokoll
! Protocoll
! Einrichtungskomplexität
! Setup-Complexity
! Sicherheitslücken
! Security gaps
! Benutzerfreundlichkeit
! User-friendliness
! Authentifizierungsmethoden
! Authentication methods
! Kommentare
! Comments
|-
|-
| LDAP
| LDAP
| Mittel
| Average
| nmap <LDAP Server> hat ausschließlich Schwachstellen beim Apache Server (2.4.52) gefunden
| nmap <LDAP Server> has only found vulnerabilities in the Apache server (2.4.52)
| CLI ist nicht benutzerfreundlich / Weboberfläche ist benutzerfreundlich
| CLI is not user-friendly / web interface is user-friendly
| Passwörter, Challenge/Response-Verfahren, Public-Key-Kryptografie
| Passwords, challenge/response procedure, public key cryptography
| Funktioniert gut, wenn es einmal funktioniert
| Works well when it works once
|-
|-
|rowspan="2" | SAML
|rowspan="2" | SAML
| Mittel
| Average
| Nicht relevant
| Not applicable
| Hohe Benutzerfreundlichkeit
| High user-friendliness
| Passwörter, Challenge/Response-Verfahren, Public-Key-Kryptografie
| Passwords, Challenge/Response Methods, Public Key Cryptography
| Einrichtung des Identity Providers über Auth0 hat schnell und problemlos funktioniert
| Setting up the identity provider via Auth0 worked quickly and easily
|-
|-
| Hoch
| High
| N/A
| N/A
| N/A
| N/A
| N/A
| N/A
| der Versuch den Identity Provider lokal zu hosten wurde nach vielen Fehlversuchen aufgegeben
| the attempt to host the identity provider locally was abandoned after many failed attempts
|-
|-
| OAuth2
| OAuth2
| Niedrig
| Low
| Nicht relevant
| Not applicable
| Benutzerfreundlich
| User-friendly
| Passwörter, Challenge/Response-Verfahren, Public-Key-Kryptografie
| Passwords, Challenge/Response Methods, Public Key Cryptography
| Einfache Einrichtung, wenn GitHub oder Auth0 als Autorisierungsserver verwendet werden
| Simple setup when using GitHub or Auth0 as authorization server
|-
|-
| Kerberos
| Kerberos
| Niedrig
| Low
| Kerbrute (Brute-Force-Angriffe)
| Kerbrute (brute force attacks)
| Benutzerfreundlich
| User-friendly
| Passwörter
| Passwords
| Einfache Einrichtung, aber speziell für Windows Active Directory entwickelt
| Simple setup, but designed specifically for Windows Active Directory
|-
|-
| Fwknop
| Fwknop
| Mittel
| Average
| N/A
| N/A
| Benutzerfreundlich
| User-friendly
| Passwörter, Public-Key-Kryptografie mit Schlüsseln bis 2048 Bit
| Passwords, public key cryptography with keys up to 2048 bit
| Einfache Einrichtung, aber nur in Ubuntu16 funktioniert
| Simple setup, but only works in Ubuntu16
|}
|}


Felder, welche mit "Nicht relevant" markiert wurden, bedeuten, dass die Verantwortung bei den externen Identity Providern und nicht bei den internen Service Providern liegt.


== References ==
Fields marked "Not applicable" indicate that the responsibility lies with the external identity providers and not with the internal service providers.
 
=== Use-Case 1 - all machines have the same rights and are managed by a group ===


<references>
Using mTLS (Mutual TLS) for authentication between machines is a good idea as long as no external services are used. However, if external services are used, the certificates must be compatible to ensure successful communication.


S. T. F. Al-Janabi and M. A. -s. Rasheed, "Public-Key Cryptography Enabled Kerberos Authentication," 2011 Developments in E-systems Engineering, Dubai, United Arab Emirates, 2011, pp. 209-214, doi: 10.1109/DeSE.2011.16.
The Zero Trust principle and Port Knocking are also suitable methods for controlling access to the machines. Access to the machines is only possible after a certain security process has been successfully completed.
keywords: {Servers;Authentication;Public key cryptography;Prototypes;authentication;Kerberos;public-key cryptography;PKINIT;PKCROSS;PKTAPP},


author "title" [url]</ref>
=== Use-Case 2 - Machines are located in different locations and are managed by different groups ===


In this case, it is recommended to use SAML or OAuth2 to manage the identity and access rights of the machines. Both protocols allow a fine-grained configuration of the rights.


</references>
While SAML is often considered more secure due to its XML-based structure and wide use, OAuth can offer advantages due to its simplicity and ease of use, especially when it comes to managing user privileges.


The choice between SAML and OAuth2 depends on the specific requirements and available resources.


[[Category:Documentation]]
[[Category:Documentation]]

Latest revision as of 21:32, 29 January 2024

Machine-to-machine (M2M) authentication is a crucial aspect of the Internet of Things (IoT) as it enables devices to communicate securely with each other. In this empirical study, various authentication protocols were investigated, including LDAP, SAML, OAuth2 and Kerberos.

Code parts for this project can be found on GitLab.

LDAP

LDAP (Lightweight Directory Access Protocol) is a widely used directory access protocol that is used to store and retrieve information. However, it can be complex, especially when it comes to setup. Nevertheless, it offers a robust and flexible solution for authentication.

To set up the LDAP server, this instructions were used. However, as the creation of a group or user with .ldif files is very error-prone, it is recommended to install an Apache2 server and manage the accounts via the GUI (see Link). No password can be added to a user account via the GUI, which is why an additional CLI tool is required. Unfortunately, the standard configuration leads to many bugs, which is why it must be replaced by this.

  • Note: If .ldif files are to be read in with the command ldapadd -x -D cn=admin,dc=example,dc=com -W -f example.ldif and the error message "ldapadd: attributeDescription "dn": (possible missing newline after line 5, entry "ou=people,dc=wfp2,dc=example,dc=com"?)" is displayed, the problem is the lines between the entries that are supposedly empty. A space or several spaces lead to this problem. Instead, \n\n is provided between the account configurations.

To use public key authentication, a key pair must first be generated. Once the key pair has been generated, it can be added to the LDAP server using the ldapadd command. The private key remains on the device, while the public key is stored on the LDAP server. During authentication, the public key is then checked against the private key on the device.

There are three different types of authentication in LDAP:

  • Anonymous Authentication Mechanism of Simple Bind is used for anonymous authentication of a client. This can be useful if data should be accessible to all users. With the command ldapsearch -x -LLL -H ldap://ldap.wfp2.example.com -b dc=wfp2,dc=example,dc=com dn, for example, all entries of the LDAP server can be retrieved, allowing the structure of the groups and users to be viewed. It should be noted here that a DNS server with the domain wfp2-example.com has been set up.
ldapsearch
  • In contrast to the above command, ldapwhoami -x -H ldap://ldap.wfp2.example.com -D "cn=ubuntumachine1001,ou=people,dc=wfp2,dc=example,dc=com" -W can be used to authenticate and then authorize a user in the CLI. With this command, it should also be noted that the -W parameter requires the password to be entered in extra. If -w is used instead, the password can be specified directly in the command (-w <password>). This authentication is called "Name/Password Authentication Mechanism of Simple Bind".
  • The third group "Unauthenticated Authentication Mechanism of Simple Bind" allows only one user name to be entered. In this case, the password field remains empty.
ldapwhoami

With the command ldapsearch -x -H ldap://ldap.wfp2.example.com -D "cn=ubuntumachine1001,ou=people,dc=wfp2,dc=example,dc=com" -W -b "dc=wfp2,dc=example,dc=com" the user ubuntumachine1001 queries all available LDAP accounts. It should be noted here that ubuntumachine1001 is not an admin user.

ldapsearch

An M2M authentication using LDAP with the help of a password is therefore possible, but is not recommended. LDAP also provides the ability to authenticate a user using an asymmetric key. The protocol also supports challenge-response procedures.

Regarding the security of LDAP, it should be noted that with a high probability the Apache2 server has the largest chess site. Since usernames can be read out without authorization, brute force methods can be used here.

SAML

SAML (Security Assertion Markup Language) is an XML-based standard used for authentication and authorization. It has been found that SAML is difficult to set up, especially when it comes to creating your own SAML identity provider. Since this did not work with the help of various online instructions, Auth0 was used as an alternative. Auth0 is a cloud-based identity management service that offers a user-friendly interface and supports all common authentication methods (password, token, challenge-response, public-key-crypto).

An X.509 certificate is used for public key authentication in SAML. The private key remains (as usual) on the client device while the certificate is issued and deposited by the SAML Identity Provider. During authentication, the certificate is then checked against the private key on the device.

Note 1: For token-based authentication, several parameters (client_id, client_secret, audience, grant_type) must be passed. Since these have to be stored on the machine - like a password - there is no added value apart from the higher security against brute force attacks.

SAML settings

Note 2: The configuration of SAML is tedious, as there are many sources of error due to the different keys and endpoints. In addition, a lot of data is provided in each request or response, which should be processed in a production environment for security reasons.

SAML response

OAuth2

OAuth2 is an authorization framework that allows users to securely share their access to their data with third-party applications. In this context, GitHub and Auth0 were used as authorization servers. It was not possible to host the authorization server locally because there were no open source libraries available. Compared to SAML, OAuth2 is very user-friendly. Setting up the server was very quick and easy with GitHub and Auth0.

However, GitHub has the disadvantage that only the credentials for existing GitHub accounts can be used. For machine-to-machine (M2M) authentication, this means that only one password authentication is possible. Auth0, as with SAML, allows all common authentication options to be used.

In OAuth2, public key authentication is achieved by using JWT (JSON Web Tokens). A JWT contains a header that contains information about the algorithm used, and a body that contains the actual data. The header and body are then signed with the device's private key. When verifying the validity of the token, the token is verified with the public key of the device.

mTLS

mTLS (Mutual Transport Layer Security) is a method of mutual authentication that ensures that both parties exchanging information are who they claim to be by verifying that they both have the correct private key.

In detail, mTLS works very similar to the TLS protocol. However, there is an additional step before the key exchange. The client sends its public key and certificate to the server, which identifies it from the server to confirm that the request comes from a known client and has the private key that corresponds to the client's shared public key.

In contrast to TLS, an internal certification authority is required to implement mTLS. This is provided by the X.509 Certificates for all clients and servers, so that each certificate has the same root certificate. Authentication is based on this match. The root certificate is self-signed in this case. The advantage of mTLS is that various attacks, such as on-path attacks, credential stuffing, are unsuccessful.

mTLS provides more security than TLS because it verifies the identity of both the server and the client. However, it is more compute-intensive than TLS, making it less suitable for scenarios where lower latency is a priority over Zero Trust security.

Kerberos

Kerberos is a network authentication protocol based on a ticket-granting ticket system originally designed for Windows Active Directory. Kerberos can be easily set up and used in Ubuntu. However, it is important to note that Kerberos requires the use of domain names (for a "simple" configuration), which is why a DNS server must be set up in addition. For a configuration without DNS server, see Link (not tested).

For the configuration of the Kerbers server, the steps in of this manual were carried out. The client requires this library to be able to request a ticket. With the command kinit <username> a ticket can be requested from the Kerberos Key Distribution Center (KDC) and displayed with klist.

Officially, Kerberos only supports password authentication. With additional "plug-ins" this can be extended by a Challenge-Response-Process or a Public-Key Cryptography.

With regard to Kerberos, it should also be mentioned that there is the tool Kerbrute, which can read Kerberos accounts and read passwords using dictionary attacks, for example. However, Kerberos can be configured so that the account is blocked after a certain number of incorrect entries.

Finally, it is important to note that Kerberos is only used for authentication and not for managing user groups, Linux UIDs and GIDs, home directories, etc. Therefore, another network source is normally used for this information, such as an LDAP or Windows server. In addition, Kerberos user principals must be manually added to the Kerberos server so that they can log in. This can be done with the kadmin.local commands.

Fwknop

Fwknop (Firewall Knocking Operation) is a tool that allows you to control access to a server by sending "knocks" to the server to open a temporary port. This is particularly useful in environments where Zero Trust principles are applied. Unlike many other services, fwknop is a program that does not require a port, which is why it is very well protected against external vulnerabilities.

The so-called "knock" consists of exactly one IPv4 packet, which is sent to the server and dropped by it, because there is no corresponding FW rule. fwknop takes this dropped package and checks if the provided keys are valid. If these are valid, an IP-Tables rule is opened for a certain time (e.g. 5sec), in which the client has time to connect to the service. The disadvantage of fwknop is that due to the limited number of bytes in an IPV4 packet, keys such as RSA4096 do not have space among the other parameters.

This tool is basically a great idea for M2M communication. However, it must also be said that fwknop has not been further developed, which is why it only works on Ubuntu16 machines.

Summary

This empirical study has shown that there are many different ways to authenticate in M2M environments, each with its own advantages and disadvantages. It is important to consider the specific requirements and conditions of your environment in order to find the best solution for your needs.

Protocoll Setup-Complexity Security gaps User-friendliness Authentication methods Comments
LDAP Average nmap <LDAP Server> has only found vulnerabilities in the Apache server (2.4.52) CLI is not user-friendly / web interface is user-friendly Passwords, challenge/response procedure, public key cryptography Works well when it works once
SAML Average Not applicable High user-friendliness Passwords, Challenge/Response Methods, Public Key Cryptography Setting up the identity provider via Auth0 worked quickly and easily
High N/A N/A N/A the attempt to host the identity provider locally was abandoned after many failed attempts
OAuth2 Low Not applicable User-friendly Passwords, Challenge/Response Methods, Public Key Cryptography Simple setup when using GitHub or Auth0 as authorization server
Kerberos Low Kerbrute (brute force attacks) User-friendly Passwords Simple setup, but designed specifically for Windows Active Directory
Fwknop Average N/A User-friendly Passwords, public key cryptography with keys up to 2048 bit Simple setup, but only works in Ubuntu16


Fields marked "Not applicable" indicate that the responsibility lies with the external identity providers and not with the internal service providers.

Use-Case 1 - all machines have the same rights and are managed by a group

Using mTLS (Mutual TLS) for authentication between machines is a good idea as long as no external services are used. However, if external services are used, the certificates must be compatible to ensure successful communication.

The Zero Trust principle and Port Knocking are also suitable methods for controlling access to the machines. Access to the machines is only possible after a certain security process has been successfully completed.

Use-Case 2 - Machines are located in different locations and are managed by different groups

In this case, it is recommended to use SAML or OAuth2 to manage the identity and access rights of the machines. Both protocols allow a fine-grained configuration of the rights.

While SAML is often considered more secure due to its XML-based structure and wide use, OAuth can offer advantages due to its simplicity and ease of use, especially when it comes to managing user privileges.

The choice between SAML and OAuth2 depends on the specific requirements and available resources.