Observable Timing Discrepancy

Overview

  • Rule ID: javascript_lang_observable_timing

  • Applicable Languages: Javascript

  • Weakness ID: CWE-208

Description

Observable Timing Discrepancy happens when attackers can measure and observe the time it takes for specific operations to complete. This vulnerability is especially problematic when operations involve sensitive information, like password checks or secret comparisons. By analyzing the duration of these operations, attackers might infer confidential details, thereby compromising your data.

Remediation Guidelines

  • Do implement algorithms that process sensitive information in constant time. This approach helps prevent attackers from inferring secrets based on the duration of operations.

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

  • Do not use direct string comparisons for sensitive information, as this can lead to early termination of the function if a mismatch is found, revealing timing information.

     if (apiToken === "zDE9ET!TDq2uZx2oM!FD2") { // unsafe
        ...
     }
  • Do not design application logic that changes execution paths in a manner that could introduce 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