CWE-203: Observable Discrepancy | Glexia
CWE-203 (Observable Discrepancy) weakness overview with consequences, detection methods, mitigations, related CVEs and MITRE ATT&CK context.
Glexia's Take · Automated analysis
CWE-203: Side Channel Attack
Observable Discrepancy represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.
Executive Impact
- Confidentiality,Access Control: Read Application Data,Bypass Protection Mechanism: An attacker can gain access to sensitive information about the system, including authentication information that may allow an attacker to gain access to the system. Other security-relevant information about the operation or internal state of the product may be revealed to an unauthorized actor, such as whether a particular operation was successful or not.
- Confidentiality: Read Application Data: In some cases, discrepancies can be used by attackers to form a side channel. When cryptographic primitives are vulnerable to side-channel attacks, this could be used to reveal unencrypted plaintext in the worst case.
Developer Pattern
CWE-203 is the kind of defect developers can usually prevent with explicit validation, safer framework defaults, and tests that exercise hostile input or unsafe state transitions.
Automation confidence
high confidence from CWE-203, 4.20.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Official CWE Definition
CWE-203: Observable Discrepancy
The product behaves differently or sends different responses under different circumstances in a way that is observable to an unauthorized actor.
Developer And Remediation Guidance
How teams prevent and detect this weakness
Causes
- The following code checks validity of the supplied username and password and notifies the user of a successful or failed login. In the above code, there are different messages for when an incorrect username is supplied, versus when the username is correct but the password is wrong. This difference enables a potential attacker to understand the state of the login function, and could allow an attacker to discover a valid username by trying different values until the incorrect password message is returned. In essence, this makes it easier for an attacker to obtain half of the necessary authentication credentials.,While this type of information may be helpful to a user, it is also useful to a potential attacker. In the above example, the message for both failed cases should be the same, such as:
- In this example, the attacker observes how long an authentication takes when the user types in the correct password. When the attacker tries their own values, they can first try strings of various length. When they find a string of the right length, the computation will take a bit longer, because the for loop will run at least once. Additionally, with this code, the attacker can possibly learn one character of the password at a time, because when they guess the first character right, the computation will take longer than a wrong guesses. Such an attack can break even the most sophisticated password with a few hundred guesses.,Note that in this example, the actual password must be handled in constant time as far as the attacker is concerned, even if the actual password is of an unusual length. This is one reason why it is good to use an algorithm that, among other things, stores a seeded cryptographic one-way hash of the password, then compare the hashes, which will always be of the same length.
- Non-uniform processing time causes timing channel. In the example above, an attacker may vary the inputs, then observe differences between processing times (since different plaintexts take different time). This could be used to infer information about the key.
- Suppose memory access patterns for an encryption routine are dependent on the secret key. An attacker can recover the key by knowing if specific memory locations have been accessed or not. The value stored at those memory locations is irrelevant. The encryption routine's memory accesses will affect the state of the processor cache. If cache resources are shared across contexts, after the encryption routine completes, an attacker in different execution context can discover which memory locations the routine accessed by measuring the time it takes for their own memory accesses to complete.
Remediation
- Architecture and Design:
- Implementation:
Detection
- Code review
- SAST
- DAST
- Focused regression tests
Mappings
Related CVEs, CWEs, and ATT&CK context
Related CWEs
- CWE-1300: Improper Protection of Physical Side Channels
- CWE-1300: Improper Protection of Physical Side Channels
- CWE-1303: Non-Transparent Sharing of Microarchitectural Resources
- CWE-200: Exposure of Sensitive Information to an Unauthorized Actor
- CWE-200: Exposure of Sensitive Information to an Unauthorized Actor
- CWE-204: Observable Response Discrepancy
- CWE-205: Observable Behavioral Discrepancy
- CWE-208: Observable Timing Discrepancy
ATT&CK Relevance
ATT&CK relevance is shown only when reviewed or responsibly inferred.
