At the BlackHat conference held in Las Vegas at the beginning of August, Israeli researchers presented a series of vulnerabilities they had identified in the “s7 comm plus” protocol used to program Siemens s7-1200 and s7-1500 PLCs.

In particular, these vulnerabilities enable attackers to perform Man In The Middle attacks, even though the protocol implements authenticity mechanisms (HMAC). Above all, they enable an attacker to force a PLC to execute a different program from the one visible to an engineering station.

This type of attack is similar to one step of the Stuxnet attack in which the attackers also modified the program of a Siemens PLC while concealing certain values from supervision.

Presentation of s7comm plus

Siemens PLCs are programmed from engineering stations using a proprietary software called TIA Portal. Previously, this software communicated with the PLC using the s7 protocol. However, the exchange technique has changed considerably over time.

First of all, a new protocol called s7plus was used. Several variants of this protocol were developed, which the researchers named `P2-`, `P2` then `P3`. The main differences between these versions relate to the methods for verifying the authentication and the integrity of the exchanged packets.

  • In the `P2-` version, the first packet the PLC sends to TIA contains a random number stored on 2 bytes which constitutes the session identifier. For the session to be considered valid, this number must be included in the subsequent messages. This is the only mechanism that is implemented. Therefore, the authenticity and the integrity of the messages cannot be verified.
  • In the `P2` version, the message’s integrity is guaranteed by using `HMAC-SHA256` with a session key that is computed sequentially by the PLC and TIA. In concrete terms, this means that the PLC and the engineering station share a list of keys that is used sequentially. This makes it easy for an attacker to pre-compute this list and have the right session key, especially as the list of keys is not associated with the instance of TIA used. In the case of a Man in The Middle attack, the attacker can therefore immediately modify the content of the message, because it is easy to recompute the HMAC field.
  • In the `P3` version, the session key exchange mechanism is much more advanced. However, this version still uses HMAC-SHA256 with a session key, and the authors have raised questions over the strength of the algorithm due ti its unconventional implementation.

The key exchange mechanism operates as follows:

  • TIA sends an initial message to the PLC to initialize the session,
  • The PLC answers with a message containing a 20 byte challenge, along with its firmware version,
  • This firmware version determines which public key is going to be used for the rest of the exchange. TIA will also choose a random number (Key Derivation Key, KDK) that will be combined with the PLC’s challenge to obtain the session key. TIA then sends the PLC the encrypted KDK with the PLC’s public key as well as other information,
  • The PLC checks the information and responds with an approval message to TIA,
  • All subsequent messages then use the session key to guarantee authenticity and integrity.

Observed weaknesses

Two main weaknesses are to be noted in the key exchange mechanism used in P3:

  • Although TIA checks the authenticity of the PLC when the KDK is sent with its public key, the PLC does not check the authenticity of TIA.
  • The exchange mechanism is designed so that all PLCs with the same firmware version can decrypt the KDK sent with the same public key. This means that all PLCs with the same firmware version have the same private key. If the attackers succeed in extracting a PLC’s private key, they will be able to decrypt the KDK value transmitted on the network and so obtain the session key. A Man in The Middleattack is then possible for all PLCs with the same firmware version.

In their paper, the researchers presented a mechanism that makes it possible to force the PLC to execute a different program from the program visible on the engineering station. By analyzing the TIA Portal software, they determined that a program is sent in 2 formats to the PLC:

  • A binary format which is the format executed by the PLC,
  • A textual format (to be more precise, two objects contain two versions of this textual format). When an engineer wants to download the program located on a PLC, this is the version that is returned.

By using a modified TIA station, it is possible to send a binary format that does not correspond to the textual format. As a result, the executed program and the one visible on the engineering station are different.

It is interesting to note that this attack is made easier by the fact that the authentication mechanism is not linked to the different formats (different HMAC for the binary format and textual format). The researchers also underline that although encryption is applied to the different blocks, this in no way prevents the attack. In fact, they did not even need to reverse engineer this mechanism.

Opinion of the Sentryo experts

The enhancement of the s7comm plus protocol clearly illustrates the changes taking place in the industrial environment. Despite implementing increasingly effective security measures, the various s7comm plus versions remain vulnerable for the time being. The non-authentication of engineering stations and the sharing of private keys among PLCs betray a lack of security maturity which is characteristic of industrial environments.

However, some basic measures can be implemented to protect against the attacks that use the disclosed vulnerabilities or at least detect their manifestations:

  • The introduction of a password on the PLC prevents unauthorized users from modifying the PLC’s programs
  • The use of security software designed for the industrial environment, such as ICS Cyber Vision, makes it possible to detect which devices are modifying programs or sending commands to the PLC.

Source: Rogue7: Rogue Engineering-Station attacks on S7Simatic PLCs, E.Biham et al. (