2167
Example 1:
Consider a device that checks a passcode to unlock the screen.
Example Language: (Bad)
As each character of the PIN number is entered, a correct character exhibits one current pulse shape while an incorrect
character exhibits a different current pulse shape.
PIN numbers used to unlock a cell phone should not exhibit any characteristics about themselves.
This creates a side channel. An attacker could monitor the pulses using an oscilloscope or other
method. Once the first character is correctly guessed (based on the oscilloscope readings), they
can then move to the next character, which is much more efficient than the brute force method of
guessing every possible sequence of characters.
Example Language: (Good)
Rather than comparing each character to the correct PIN value as it is entered, the device could accumulate the PIN in a
register, and do the comparison all at once at the end. Alternatively, the components for the comparison could be modified
so that the current pulse shape is the same regardless of the correctness of the entered character.
Example 2:
Consider the device vulnerability CVE-2021-3011, which affects certain microcontrollers
[REF-1221]. The Google Titan Security Key is used for two-factor authentication using
cryptographic algorithms. The device uses an internal secret key for this purpose and exchanges
information based on this key for the authentication. If this internal secret key and the encryption
algorithm were known to an adversary, the key function could be duplicated, allowing the adversary
to masquerade as the legitimate user.
Example Language: (Bad)
The local method of extracting the secret key consists of plugging the key into a USB port and using electromagnetic (EM)
sniffing tools and computers.
Example Language: (Good)
Several solutions could have been considered by the manufacturer. For example, the manufacturer could shield the circuitry
in the key or add randomized delays, indirect calculations with random values involved, or randomly ordered calculations to
make extraction much more difficult or a combination of these techniques.
Example 3:
The code snippet provided here is part of the modular exponentiation module found in the
HACK@DAC'21 Openpiton System-on-Chip (SoC), specifically within the RSA peripheral
[REF-1368]. Modular exponentiation, denoted as "a^b mod n," is a crucial operation in the RSA
public/private key encryption. In RSA encryption, where 'c' represents ciphertext, 'm' stands for a
message, and 'd' corresponds to the private key, the decryption process is carried out using this
modular exponentiation as follows: m = c^d mod n, where 'n' is the result of multiplying two large
prime numbers.
Example Language: Verilog (Bad)
...
module mod_exp
...
`UPDATE: begin
if (exponent_reg != 'd0) begin
if (exponent_reg[0])
result_reg <= result_next;
base_reg <= base_next;
exponent_reg <= exponent_next;
state <= `UPDATE;
CWE Version 4.14
CWE-1300: Improper Protection of Physical Side Channels
CWE-1300: Improper Protection of Physical Side Channels