Observable Timing Discrepancy

Overview

  • Rule ID: java_lang_observable_timing

  • Applicable Languages: Java

  • Weakness ID: CWE-208

Description

Observable Timing Discrepancy occurs when attackers can measure and observe the duration of specific operations. This vulnerability is especially problematic when sensitive information is involved, such as password checks or secret comparisons. By analyzing the time taken for these operations, attackers might deduce confidential details, putting your data at risk.

Remediation Guidelines

  • Use algorithms that process sensitive information in constant time to prevent attackers from inferring secrets based on operation duration.

  • Utilize built-in security features and cryptographic libraries that provide functions safe from timing attacks for comparing secret values.

  • Avoid direct string comparisons for sensitive information, as early termination on a mismatch can reveal timing information.

    boolean isAdmin = "admin".equals(username); // unsafe
  • Avoid designing application logic that alters execution paths in a way that could create timing discrepancies based on user input or secret values.

References

Configuration

To omit this rule during a scan, and to provide you with continuous 24/7 code-level scanning, you can employ our SAST TOOL

Last updated