The issue discusses the possibility of integrating alternate PAKE (Password-Authenticated Key Exchange) algorithms into Magic Wormhole. Here’s an in-depth summary and analysis of the issue, including its implications and possible actionable steps.
Current Context:
Magic Wormhole currently uses SPAKE2 (a symmetric PAKE) with Ed25519 for key exchange. SPAKE2 was chosen for its simplicity, symmetric properties, and minimal round-trip requirements. These properties make it particularly suitable for Magic Wormhole's use case, which often includes scenarios like "offline code exchange" and peer-to-peer communication without predefined roles (e.g., sender/receiver).
However, there are discussions about:
- Exploring alternate PAKE algorithms, like SPAKE2-EE (Elligator2-based SPAKE2) or other modern PAKEs, such as CPace.
- The necessity of maintaining backward compatibility with existing clients, especially since Magic Wormhole is widely distributed.
- The potential to improve performance, security, and compatibility by adopting newer cryptographic primitives or algorithms.
Key Points from the Issue:
1. Threat Model and Protocol Summary:
The issue outlines the Magic Wormhole protocol in detail from a security perspective, including:
- Mailbox server: A trusted intermediary that relays messages between the sender and recipient.
- PAKE in the protocol: SPAKE2 ensures that both participants know the correct code before establishing a secure session key.
- Attacker goals: Confidentiality, integrity, or both (e.g., full man-in-the-middle attacks).
The main vulnerability lies in the short entropy of the wormhole code (16 bits by default with two-word codes), which gives attackers a brute-force opportunity. Alternate PAKEs might help mitigate risks by improving cryptographic properties or performance.
2. Alternate PAKE Algorithms:
Some alternate PAKEs discussed include:
- SPAKE2-EE over Ristretto: Uses Elligator2 to map passwords to elliptic curve points, potentially improving security.
- CPace: Another modern PAKE often considered alongside SPAKE2 in cryptographic competitions.
- Augmented PAKEs: These add features for asymmetric use cases but may require additional round-trips.
3. Backward Compatibility:
Maintaining compatibility with existing deployments is critical. Transitioning to a new algorithm would require:
- Negotiation protocols to allow both old and new clients to interoperate.
- Defaulting to SPAKE2 for clients that only support the current algorithm.
4. Performance and Usability:
- Alternate PAKEs may provide faster computation or better security guarantees.
- However, they may increase implementation complexity or CPU usage.
5. Protocol Extension for Multiple PAKEs:
The issue proposes two strategies to support multiple PAKEs:
- Negotiation before PAKE computation: Exchanging supported algorithms before computing any PAKE message. This adds a round-trip but ensures both sides agree on the algorithm.
- Parallel PAKE offers: Computing PAKEs for all supported algorithms and including them in a single message. This avoids extra round-trips but increases computation overhead.
6. Implementation Considerations:
- The
pake_v1 field in the protocol (build_pake() in _key.py) can be extended to include additional PAKE messages (e.g., pake_v2 for a new algorithm).
- Care must be taken to ensure only one PAKE computation is completed per code to prevent attackers from exploiting multiple guesses.
Challenges:
-
Backward Compatibility:
- Existing deployments rely on SPAKE2. Any change must ensure seamless operation between old and new clients.
- A phased approach or optional parameter (e.g.,
pakes=[V1, V2]) could allow gradual adoption of new algorithms.
-
Security Implications:
- Adding multiple PAKEs increases the complexity of the protocol, which could inadvertently introduce vulnerabilities.
- Negotiation of algorithms must prevent downgrade attacks, where an attacker forces both sides to use a weaker PAKE.
-
Performance Overhead:
- Computing multiple PAKE messages (for parallel offers) could be costly, especially for low-powered devices like Raspberry Pi.
-
Library Support:
- The current SPAKE2 library (python-spake2) is unmaintained, which could pose long-term challenges for maintaining the protocol.
Suggestions and Path Forward:
-
Adopt a Negotiable PAKE Framework:
- Introduce a negotiation mechanism to allow clients to agree on a PAKE algorithm during the protocol handshake.
- Extend the
pake_v1 field to include new algorithms (e.g., pake_v2).
- Use the "side" parameter to determine the leader (who decides the algorithm) or converge on a decision without additional messages.
-
Default to SPAKE2 for Compatibility:
- Retain SPAKE2 as the default algorithm for compatibility with existing clients.
- New applications (with a different
appid) can adopt alternate algorithms without worrying about legacy compatibility.
-
Evaluate Alternate PAKEs:
- Research and test newer algorithms like SPAKE2-EE or CPace to assess their suitability for Magic Wormhole.
- Focus on symmetric PAKEs to maintain the current protocol's minimal round-trip design.
-
Optimize Performance:
- Implement efficient cryptographic libraries (e.g., Rust-based) for newer PAKEs to minimize computation overhead.
- Avoid doubling the CPU workload unless the benefits (e.g., security) outweigh the costs.
-
Plan for Long-Term Maintenance:
- If SPAKE2 remains the default, consider switching to a better-supported library for future-proofing.
- Alternatively, migrate to a well-specified and maintained PAKE algorithm standard.
-
Community Coordination:
- Coordinate with other implementations (e.g., Rust port) to standardize algorithm identifiers and negotiation mechanisms.
- Ensure that different implementations can gracefully detect and handle incompatible configurations.
Conclusion:
The idea of supporting alternate PAKE algorithms is compelling, especially for improving performance and security. However, careful planning is required to maintain backward compatibility, avoid security regressions, and minimize computational overhead. A phased approach with optional algorithm negotiation and a default fallback to SPAKE2 seems like the most prudent path forward.
By prioritizing compatibility and evaluating alternate PAKEs' benefits and tradeoffs, Magic Wormhole can continue to evolve while staying true to its promise of "getting things from one computer to another, safely."