Skip to main content

Side-channel attacks

Timing Attack Visualization

See how early-exit comparisons can leak information through timing. Compare a vulnerable string comparison with a constant-time approach using safe local demo values.

Ethical demo only

This page simulates timing costs locally. Do not use timing tests against systems or accounts you do not own or have permission to test.

Timing comparison

Vulnerable comparison cost grows with the matched prefix. Constant-time comparison keeps the cost closer to the full input length.

Vulnerable avg cost

48.67

Leaks prefix length

Constant-time avg cost

78.00

Avoids early exit

Leaked prefix

cry

What timing may reveal

Risk

medium

Based on matched-prefix length

Explanation

Timing attacks work when comparison code exits early and response time reveals how many characters were correct. Constant-time comparison keeps work roughly independent of the matching prefix.

Attempt samples

Costs are deterministic demo units, not real wall-clock timings. They make the leak visible without attacking any external system.

SampleGuessMatched prefixVulnerable costConstant-time costMatch
1crysta35079no
2crysta34778no
3crysta34877no
4crysta34877no
5crysta34778no
6crysta35178no
7crysta34778no
8crysta34978no
9crysta35079no
10crysta35079no
11crysta34978no
12crysta34877no

How to defend

Use constant-time comparison for secrets, tokens, MACs, and signatures.
Avoid early return when comparing sensitive values.
Add rate limits and lockouts around authentication flows.
Prefer battle-tested framework utilities instead of hand-written comparison code.