-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommit_msg.txt
More file actions
77 lines (63 loc) · 3.77 KB
/
Copy pathcommit_msg.txt
File metadata and controls
77 lines (63 loc) · 3.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
fix(crypto): VULN-04 — True E2EE ECDH for real Perfect Forward Secrecy
SEVERITY: CRITICAL
CATEGORY: Cryptographic Architecture Design Flaw
VULNERABILITY SUMMARY:
The ECDH key exchange was performed between the Client and the Server
(relay), not between the Client and the Admin (operator). To compensate,
the Worker serialized the ephemeral ecdhSecret into the RSA-OAEP-encrypted
INIT payload and transmitted it over the network. This design destroyed
Perfect Forward Secrecy: a future compromise of the RSA private key would
allow an adversary to extract the ecdhSecret from captured INIT payloads
and retroactively derive every past session's AES-GCM-256 key.
The ECDH was reduced to cryptographic theater — the entire system's
confidentiality rested solely on the long-term RSA key.
ATTACK VECTOR (Harvest Now, Decrypt Later):
1. Adversary records all WebSocket traffic (encrypted frames)
2. At a future date, adversary compromises RSA private key
3. Adversary decrypts captured INIT payloads → extracts ecdhSecret
4. Adversary reconstructs AES key: HKDF(PBKDF2(token), ecdhSecret)
5. Adversary decrypts ALL historical session messages
ARCHITECTURAL FIX:
The ECDH exchange is now strictly End-to-End (E2EE) between Client and
Admin. The server acts as a Zero-Knowledge relay for ECDH public keys,
never generating, computing, or storing any ECDH material.
FILES MODIFIED:
src/server.js:
- REMOVED: sessionECDH Map, generateECDHKeyPair(), ECDH_CLIENT_KEY handler
- REMOVED: Server-side ECDH key generation in HANDSHAKE handler
- ADDED: HANDSHAKE_ACK response (replaces direct ECDH_EXCHANGE)
- ADDED: ECDH_EXCHANGE Zero-Knowledge relay handler
→ Client→Admin: relays publicKey with sessionId
→ Admin→Client: routes publicKey to targetSession
- ADDED: Pending ECDH replay on ADMIN_AUTH (for late admin connection)
- MODIFIED: Session socket registration moved to HANDSHAKE (earlier)
- CLEANED: sessionECDH.delete() removed from close/expiry handlers
src/client.js:
- ADDED: HANDSHAKE_ACK handler → generates ECDH keypair, sends publicKey
- MODIFIED: ECDH_EXCHANGE handler → receives Admin's publicKey (not server's)
- REMOVED: ECDH_COMPLETE handler (server no longer confirms ECDH)
- ADDED: Worker re-initialization support for admin reconnection (re-keying)
src/ztap-worker.js:
- REMOVED: ecdhSecret from RSA-OAEP encrypted INIT payload
- PRESERVED: ecdhSecret usage in deriveKey() (received from client.js, local)
- PRESERVED: Hard-fail guard SEC_FAULT_NO_ECDH (L110-113)
src/admin-client.js:
- ADDED: sessionECDHSecrets{} — per-session shared secret storage
- ADDED: generateAdminECDH() — Web Crypto API ECDH P-256 key generation
- ADDED: computeAdminECDHSecret() — local shared secret derivation
- ADDED: ECDH_EXCHANGE handler → generates keypair, computes secret, responds
- MODIFIED: INIT handler → uses sessionECDHSecrets[sessId] instead of
initData.ecdhSecret from RSA payload
- ADDED: Guard rejecting INIT without prior E2EE ECDH completion
SECURITY PROPERTIES ACHIEVED:
✓ True Perfect Forward Secrecy (ecdhSecret never leaves browser memory)
✓ Zero-Knowledge relay (server has zero cryptographic capability)
✓ CDH-hard ephemeral secrets (irrecoverable without ECDH private keys)
✓ RSA channel restricted to identity/token transport only
PROTOCOL FLOW CHANGE:
BEFORE: Client ←ECDH→ Server ──RSA(ecdhSecret)──→ Admin (PFS BROKEN)
AFTER: Client ←ECDH→ Admin (via ZK relay) (PFS REAL)
BREAKING CHANGES: None. Wire protocol frame format is preserved.
All ECDH_EXCHANGE frames now carry {publicKey} instead of {serverPublicKey}.
The HANDSHAKE response changes from ECDH_EXCHANGE to HANDSHAKE_ACK.
Signed-off-by: Eduardo "Noir0x63" Camarillo