constant time testing

Other Community

Skill notes

Background

Timing attacks were introduced by Kocher in 1996. Since then, researchers have demonstrated practical attacks on RSA (Schindler), OpenSSL (Brumley and Boneh), AES implementations, and even post-quantum algorithms like Kyber.

Key Concepts

Concept · Description Constant-time · Code path and memory accesses independent of secret data Timing leakage · Observable execution time differences correlated with secrets Side channel · Information extracted from implementation rather than algorithm Microarchitecture · CPU-level timing differences (cache, division, shifts)

Why This Matters

Timing vulnerabilities can: Expose private keys - Extract secret exponents in RSA/ECDH Enable remote attacks - Network-observable timing differences Bypass cryptographic security - Undermine theoretical guarantees Persist silently - Often undetected without specialized analysis

Common Constant-Time Violation Patterns

Four patterns account for most timing vulnerabilities: Conditional jumps cause different code paths, leading to vast timing differences. Array access dependent on secrets enables cache-timing attacks, as shown in AES cache-timing research. Integer division and shift operations leak secrets on certain CPU architectures and compiler configurations. When patterns cannot be avoided, employ masking techniques to remove correlation between timing and secrets.

Example: Modular Exponentiation Timing Attacks

Modular exponentiation (used in RSA and Diffie-Hellman) is susceptible to timing attacks. RSA decryption computes: $$ct^{d} \mod{N}$$ where $d$ is the secret exponent. The exponentiation by squaring optimization reduces multiplications to $\log{d}$: $$ \begin{align*}

Fluxly profile Runtime and permissions are inferred by Fluxly static checks, not author declarations or runtime test results.
Domain
Other
Author-declared agents
No explicit declaration found; this is not inferred or tested compatibility
Static check
88 / 100 · heuristic scan, not runtime safety proof
Runtime evidence
Not run; no isolated runtime test evidence is currently recorded
Author / version / license
@trailofbits · no license declared
Token usage
Moderate
Setup complexity
Manual integration
External API key
Required · Vendor-specific
Operating systems
Unspecified (assume cross-platform)
Runtime requirements
No explicit requirements detected
Detected file/system behavior
  • Read-only
  • Write / modify
  • Shell exec
Network behavior
External requests
Install commands
None (reference only)

Heads up: Tool permissions are not declared; actual access depends on the runtime.

01
Phase 1: Initial Assessment

Identify cryptographic code handling secrets: Private keys, exponents, nonces Password hashes, authentication tokens Encryption/decryption operations Quick statistical check:

02
Phase 2: Detailed Analysis

If dudect detects leakage: Root cause investigation: Mark secret variables with Timecop `poison()` Run under Valgrind to identify exact line Review the four common violation patterns

03
Phase 3: Remediation

Fix the timing leak: Replace conditional branches with constant-time selection (bitwise operations) Use constant-time comparison functions Replace array lookups with constant-time alternatives or masking Verify compiler doesn't optimize away constant-time code

04
Phase 4: Continuous Monitoring

Integrate into CI: Add dudect tests to test suite Run for fixed duration (5-10 minutes in CI) Fail build if leakage detected See the dudect skill for CI integration examples.

Discussion

Powered by GitHub Discussions. Sign in with GitHub to comment, react, or subscribe.