Claroty’s Team82 can extract cryptographic keys embedded within Siemens SIMATIC PLC, TIA Portal

Claroty’s Team82 can extract cryptographic keys embedded within Siemens SIMATIC PLC, TIA Portal

Claroty’s Team82 research arm has detailed a new method to extract heavily guarded, hardcoded, global private cryptographic keys embedded within the Siemens SIMATIC S7-1200/1500 PLC and TIA Portal product lines. By extracting the PLC’s hardcoded private key, the researchers were able to demonstrate multiple attack scenarios including decryption of all communication between S7 programmable logic controllers (PLCs) and an EWS, decryption of the configured password hash on the PLC, which could be used to gain full access to the PLC, and conduct man-in-the-middle attacks.

The team uncovered and disclosed to Siemens a new and innovative technique targeting these PLC CPUs that enabled its researchers to recover a global hard-coded cryptographic key (CVE-2022-38465) used by each Siemens-affected product line. If extracted by an attacker, the key would give them complete control over every PLC per affected Siemens product line.

“An attacker can use these keys to perform multiple advanced attacks against Siemens SIMATIC devices and the related TIA Portal while bypassing all four of its access level protections,” Team82 wrote in a blog post this week. “A malicious actor could use this secret information to compromise the entire SIMATIC S7-1200/1500 product line in an irreparable way. In addition, an attacker can develop an independent Siemens SIMATIC client (without requiring the TIA Portal) and perform full upload/download procedures, conduct man-in-the-middle attacks, and intercept and decrypt passive OMS+ network traffic.”

Siemens has updated the S7-1200 and S7-1500 PLCs and the TIA Portal and urges users to move to current versions. “This disclosure has led to the introduction of a new TLS management system in TIA Portal v17, ensuring that configuration data and communications between Siemens PLCs and engineering workstations are encrypted and confidential,” Team82 added.

“Using a vulnerability uncovered in previous research (CVE-2020-15782) on Siemens PLCs that enabled us to bypass native memory protections on the PLC and gain read and write privileges in order to remotely execute code, we were able to extract the internal, heavily guarded private key used across the Siemens product lines,” according to Team82. “This new knowledge allowed us to implement the full protocol stack, encrypt and decrypt protected communication, and configurations.”

Siemens’ response to this private disclosure led to an overhaul of the cryptographic schemes protecting its PLC lines, and its TIA Portal engineering workstation application. Siemens acknowledged in a security advisory that existing protections around its hardcoded key are no longer sufficient and invested the resources and time necessary to introduce a dynamic public-key infrastructure (PKI) that eliminates the use of hardcoded keys. 

Close to ten years back, Siemens introduced asymmetric cryptography into the integrated security architecture of its TIA Portal v12 and SIMATIC S7-1200/1500 PLC CPU firmware families. The approach was done to ensure the integrity and confidentiality of devices and user programs and protect device communication within industrial environments. 

Dynamic key management and distribution did not exist then for industrial control systems (ICS), largely because of the operational burden that management systems would put on integrators and users, Team82 said. 

At the time, Siemens decided to rely on fixed cryptographic keys to secure programming and communications between its PLCs and the TIA portal. Since then, however, advances in technology, security research, and a swiftly changing threat landscape have rendered such hardcoded crypto keys an unacceptable risk. A malicious actor who can extract a global, hardcoded key could compromise the entire device product line security irreparably.

Team82 has conducted extensive research into PLC security, working closely with leading vendors to eradicate such practices as hardcoded keys, demonstrate the risk they pose to users’ systems, and improve the overall security of the industrial automation ecosystem.

The asymmetric encryption procedures on the Siemens PLCs provide authentication, a shared derived session key that authenticates a user when communicating with a PLC, and confidentiality that encrypts data during portions of said communication. “We were able to understand the encryption algorithm, which was based on Elliptic Curve asymmetric encryption. We found the curve parameters as well as an added complication: the use of a ‘configuration key’ to further obfuscate and complicate the elliptical multiplication process,” Team82 said.

Eventually, Team82 was able to uncover all the relevant keys involved in the encryption process, including the connection key used for packet integrity verification and authentication, the CPU key used to encrypt configurations, code, and maintain code integrity, and the family key used for the same purposes as the CPU key, when the CPU key is not known.

After reverse engineering one of Siemens SIMATIC [dot]upd firmware S7-1200, which was unencrypted, Team82 learned that the private key does not reside within the firmware files, therefore the researchers would have to extract it somehow directly from the PLC. “In order to retrieve the private key from the PLC, we needed direct memory access (DA) to be able to search for it. To be able to perform DA actions, we searched and found a remote code execution vulnerability on both the 1200/1500 PLC series. The vulnerability (CVE-2020-15782) was triggered through a specific MC7+ function code containing our own crafted shellcode bytecode,” it added.

The vulnerability logic for CVE-2020-15782 uses [REDACTED] opcode, which has no security memory region checks, to copy an internal struct containing a native pointer to a valid memory area to a writable memory area, changes the pointer inside this struct to the desired address, recalculates the CRC that was used to verify this struct (using the CRC32 opcode), and copies the struct back to its original location, now pointing to our desired address, using the [REDACTED] opcode, Team82 said. “At this point, we may use indirect access to the new address in our crafted struct. We could now read or write from any memory address in the PLC. Using this capability, we could override native code and execute any desired native logic,” it added. 

Using the private key Team82 was able to extract, an attacker may gain full control over a PLC. Attacks could allow an attacker with knowledge of the PLC’s private key and encryption algorithm, to retrieve the configured password on the PLC, gaining full control regardless of the protection level configured on the device. The research team assesses that hackers can obtain the configuration and decrypt the password hash, launch man-in-the-middle attacks, and enable passive traffic interception.

Team82 said that if the PLC is in a protection level lower than 3, an attacker can retrieve the configuration from the PLC (Upload procedure) with no special permission required. “Once uploaded, the attacker has the PLC configuration and can use the private key to decrypt the password hash from the uploaded configuration. Using the decrypted password hash the attacker can authenticate to the PLC and gain higher privileges,” it added.

It also added that an attacker with knowledge of the encryption mechanism of the traffic, as well as access to the private key, can impersonate the PLC in a connection. Additionally, an attacker with passive access to capture traffic to a given PLC on the network can intercept configuration reads/writes from the PLC. Using the private key, the attacker can decrypt the configuration and extract the password hash. With the password hash the attacker can authenticate to the controller and write a new configuration, the post added.

Users should update to current versions of the S7-1200 and S7-1500 PLC families, as well as TIA Portal v17, as advised by Siemens, Team82 said. TIA Portal v17 introduces a TLS management system in order to encrypt communication. Siemens also introduced a preactivated PLC configuration password requirement, that ensures all confidential PLC configuration data are protected by default as well as predefined secure PG/HMI communication, which prevents unsecured communication with other partners, and preactivated PLC access protection, that prevents any type of access to the controller unless explicitly configured, it added.

In August, Team82 researchers developed a novel technique called the Evil PLC Attack in which PLCs are weaponized and used to compromise engineering workstations. An attacker with a foothold on an engineering workstation can have access to anything else on the OT network to which an engineer connects that machine, including other PLCs. 

Related