CWE-1255: Comparison Logic is Vulnerable to Power Side-Channel Attacks
A device's real time power consumption may be monitored during security token evaluation and the information gleaned may be used to determine the value of the reference token.
How it's found
Comparison Logic is Vulnerable to Power Side-Channel Attacks is a specific, narrowly defined instance of a broader pattern. Testers confirm it with targeted code review and a proof-of-concept input that exercises the exact code path this weakness describes.
The power consumed by a device may be instrumented and monitored in real time. If the algorithm for evaluating security tokens is not sufficiently robust, the power consumption may vary by token entry comparison against the reference value. Further, if retries are unlimited, the power difference between a "good" entry and a "bad" entry may be observed and used to determine whether each entry itself is correct thereby allowing unauthorized parties to calculate the reference value.
Vulnerable vs. safe
password_ok |= 1; // Power consumption is different here
password_ok |= 0; // than from hereif (GetPasswordByte() == stored_password([i])else
password_tries = NUM_RETRIES;break_to_Ok_to_proceedwhile (password_tries == 0) ; // Hang here if no more password triespassword_ok = 0;for (i = 0; i < NUM_PW_DIGITS; i++)endif (password_ok > 0)password_tries--;static nonvolatile password_tries = NUM_RETRIES;dowhile (true)// Password OKpassword_ok |= 0x10; // Power consumption here
password_ok |= 0x01; // is now the same hereif (GetPasswordByte() == stored_password([i])else
password_tries = NUM_RETRIES;break_to_Ok_to_proceedwhile (password_tries == 0) ; // Hang here if no more password triespassword_tries--; // Put retry code here to catch partial retriespassword_ok = 0;for (i = 0; i < NUM_PW_DIGITS; i++)endif ((password_ok & 1) == 0)static nonvolatile password_tries = NUM_RETRIES;dowhile (true)// Password OKConsequences
- Modify Memory, Read Memory, Read Files or Directories, Modify Files or Directories, Execute Unauthorized Code or Commands, Gain Privileges or Assume Identity, Bypass Protection Mechanism, Read Application Data, Modify Application Data, Hide Activities: As compromising a security token may result in complete system control, the impacts are relatively universal.
Mitigations
- Architecture and Design: The design phase must consider each check of a security token against a standard and the amount of power consumed during the check of a good token versus a bad token. The alternative is an all at once check where a retry counter is incremented PRIOR to the check.
- Architecture and Design: Another potential mitigation is to parallelize shifting of secret data (see example 2 below). Note that the wider the bus the more effective the result.
- Architecture and Design: An additional potential mitigation is to add random data to each crypto operation then subtract it out afterwards. This is highly effective but costly in performance, area, and power consumption. It also requires a random number generator.
- Implementation: If the architecture is unable to prevent the attack, using filtering components may reduce the ability to implement an attack, however, consideration must be given to the physical removal of the filter elements.
- Integration: During integration, avoid use of a single secret for an extended period (e.g. frequent key updates). This limits the amount of data compromised but at the cost of complexity of use.
Where this fits in a TurboPentest engagement
This weakness is not covered by the automated black-box pentest. IntegSec pentesters cover it in a manual engagement.
Frequently asked questions
What is CWE-1255?
A device's real time power consumption may be monitored during security token evaluation and the information gleaned may be used to determine the value of the reference token.
How do you find Comparison Logic is Vulnerable to Power Side-Channel Attacks?
Comparison Logic is Vulnerable to Power Side-Channel Attacks is a specific, narrowly defined instance of a broader pattern. Testers confirm it with targeted code review and a proof-of-concept input that exercises the exact code path this weakness describes.
What is the impact of CWE-1255?
Modify Memory, Read Memory, Read Files or Directories, Modify Files or Directories, Execute Unauthorized Code or Commands, Gain Privileges or Assume Identity, Bypass Protection Mechanism, Read Application Data, Modify Application Data, Hide Activities: As compromising a security token may result in complete system control, the impacts are relatively universal.
Does TurboPentest test for Comparison Logic is Vulnerable to Power Side-Channel Attacks?
This weakness is not covered by the automated black-box pentest. IntegSec pentesters cover it in a manual engagement.
Related CWEs
Written and reviewed by
Michel Chamberland - Founder & CEO, IntegSec
CISSP, OSCP, OSCE, CEH, GIAC, CCSK · 20+ years in offensive security
Michel has spent 20+ years on offensive security teams including IBM X-Force Red and Trustwave SpiderLabs, leading penetration tests, red team engagements, and breach response for Fortune 500 customers. He is the founder of IntegSec and the architect of TurboPentest.
Find these issues before an attacker does
TurboPentest runs an agentic AI pentest against your target and reports findings with proof, from $99 per target.
Start a pentest