/** * Timing Attack Security Tests * * These tests verify that security-sensitive operations are timing-safe * to prevent timing attacks that could leak information about valid tokens, * passwords, API keys, and other secrets. * * TIMING ATTACK BACKGROUND: * ------------------------- * A timing attack exploits the fact that naive string comparison operations * (like `===`) typically short-circuit on the first differing character. * An attacker can measure response times to infer how many characters of a * secret they have guessed correctly. * * Example vulnerability: * - "a..." vs "secret" fails immediately (1 comparison) * - "s..." vs "secret" fails after 1 match (2 comparisons) * - "se..." vs "secret" fails after 2 matches (3 comparisons) * * By measuring timing differences (often in microseconds), an attacker can * iteratively discover the correct secret character by character. * * SOLUTION: * --------- * Use constant-time comparison functions that always compare all characters, * regardless of where the first difference occurs. * * NOTE ON TIMING TESTS: * -------------------- * Unit tests for timing characteristics are inherently noisy due to: * - JIT compilation optimizations * - Garbage collection pauses * - OS scheduling and interrupts * - CPU frequency scaling * - Cache effects * * The statistical timing tests in this file use relaxed thresholds and are * primarily for documentation and regression detection, not cryptographic * certification. For production-grade timing analysis, use dedicated tools * like https://github.com/oreparaz/dudect in a controlled environment. * * @see https://en.wikipedia.org/wiki/Timing_attack * @see https://codahale.com/a-lesson-in-timing-attacks/ */ export {}; //# sourceMappingURL=security.test.d.ts.map