Path: blob/main/foundations/06-elliptic-curves/break/invalid-curve-attack.ipynb
483 views
Break: Invalid Curve Attack
Module 06 | Breaking Weak Parameters
If a server does not validate that received points lie on the curve, an attacker can send points on weaker curves and extract the secret key piece by piece.
Why This Matters
In ECDH, a server receives a public key point from a client and computes a scalar multiplication using its secret key . But what if the point does not lie on the expected curve?
The elliptic curve addition formulas for short Weierstrass form only use the coefficient , not . This means the server will happily compute scalar multiplication on a point from a different curve (same , different ) without noticing.
The attacker chooses so that the alternative curve has small-order subgroups. A point of small order reveals via brute force. Repeating with different small-order points and combining via CRT recovers the full secret .
This attack has been demonstrated against real TLS implementations.
Step 1: Find Alternative Curves with Small Subgroups
The attacker searches for values such that the curve has an order divisible by small primes. For each such , the attacker finds a point of small prime order on .
Key insight: the addition formulas for Weierstrass curves only use :
where for addition or for doubling. The parameter never appears!
Step 2: Query the Vulnerable Server
The attacker sends each small-order point (from curve with parameter ) to the server. The server computes using the standard point addition formulas, which only use , not .
Since has order , the result is one of only possible points. The attacker brute-forces all possibilities to find .
Step 3: Combine with CRT to Recover the Full Secret
We now have a system of congruences:
Since all are distinct primes, they are pairwise coprime. By the Chinese Remainder Theorem (Module 04), there is a unique solution modulo .
The Fix: Point Validation
The defense is simple: always validate that received points satisfy the curve equation.
Given a point , check:
(point is on the correct curve)
The point is not the point at infinity
Optionally: (point is in the correct subgroup)
Exercises
Query count: How many server queries does the attack need in total? Express this as a function of the secret key size and the small primes used.
Montgomery curves: The Curve25519 (Montgomery form) key exchange uses only the -coordinate. Research why the invalid curve attack is harder against X25519.
Subgroup check: Even if the point is on the correct curve, it might be in a small subgroup (if the curve has cofactor ). Why does checking prevent this?
Summary
| Aspect | Detail |
|---|---|
| Vulnerability | Server does not check if received point lies on the expected curve |
| Root cause | Weierstrass addition formulas use but not |
| Attack | Send points of small order from curves with different ; brute force ; combine via CRT |
| Cost | One query per small prime; brute force at most values each |
| Fix | Validate for received points; check subgroup membership |
The invalid curve attack illustrates a general principle: never trust external input. In cryptographic protocols, every received value must be validated against the expected mathematical structure. A missing check turns the hardness of ECDLP into a trivial CRT computation.
Back to Module 06: Elliptic Curves