lf-lang / lingua-franca

Intuitive concurrent programming in any language
https://www.lf-lang.org
Other
235 stars 63 forks source link

Authentication and communication security in federated execution #1146

Closed hokeun closed 1 year ago

hokeun commented 2 years ago

Motivation

The current implementation of federated execution lacks authentication and encryption mechanisms to prevent adversarial federates from joining the federation or sending malicious messages (e.g., bad tags or bad sensor readings) to RTI or other federates.

Goals

  1. Authentication: To authenticate a federate properly when the federate joins a federation.
  2. Communication security: To ensure confidentiality and integrity (+ message authenticity) of the network messages between RTI and federates as well as among federates.

Approach

Target property for configuring authentication

target C {
    auth: Hmac
};

Target property for configuring communication security for network messages

target C {
    communication-security: {
        key-distribution: FederationID,
        encryption: AES-128-CBC,
        message-authentication: HmacSHA256
    }
};

RTI Command-line Arguments

-a, --auth <string>

-s, --security <string>
-e, --encryption  <string>
-m, --message-authentication  <string>

Future Work

How can we handle a scenario where some federates join without a security mechanism while other federates have to use secure authentication? For example, some bare-iron federates like sensor nodes for which we can filter the bogus sensor nodes even if they join a federation without secure authentication, and other federates like controllers which require secure authentication in the same federation.

hokeun commented 2 years ago

During a discussion, @soyerefsane suggested having TLS as an option as well. So we will try to get to that as well.

Jakio815 commented 2 years ago

This is worked on https://github.com/lf-lang/lingua-franca/tree/auth. I linked a branch on this issue.

My branch currently uses target C { auth: true } option to include OpenSSL libraries, and use HMAC authentications between the RTI and the federate. It randomly creates nonce and creates a HMAC tag, and they process a 3 step handshake starting from the RTI.

For test, First build the RTI.

// org.lflang\src\lib\c\reactor-c\core\federated\RTI\
mkdir build && cd build
cmake -DAUTH=ON ../
make
sudo make install

Next, I made a simple test .lf file for test.

./gradlew runlfc --args test/C/src/federated/SimpleFederatedAuth.lf
./test/C/bin/SimpleFederatedAuth 

RTI does not include OpenSSL libraries when -DAUTH=ON is not commanded. It is set OFF on default. runlfc command also does not include OpenSSL libraries if target C { auth: true } is not coded.

hokeun commented 2 years ago

Relevant branches that are currently being worked on to add HMAC-based simple authentication of federates:

Lingua-Franca: https://github.com/lf-lang/lingua-franca/tree/auth Reactor-c: https://github.com/lf-lang/reactor-c/tree/security