Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Design and Implementation of a Secure Key Server for PWA Authentication #298

Open
francis-pouatcha opened this issue Jan 20, 2025 · 0 comments

Comments

@francis-pouatcha
Copy link
Member

francis-pouatcha commented Jan 20, 2025

This project focuses on building a "Key Server" to facilitate secure, user-friendly authentication within our ecosystem of Progressive Web Apps (PWAs). Our PWAs prioritize a seamless user experience by minimizing explicit authentication requests. To achieve this, we utilize key pairs for app authentication and employ a unique encryption strategy for securing private keys on user devices.

Challenges:

  • PWA Security Limitations: PWAs, unlike native apps, have limited capabilities to conceal sensitive data, such as the secrets used to encrypt private keys.
  • Offline Functionality: We need to support both online and offline authentication scenarios within our PWAs.
  • User Experience: Authentication should be as frictionless as possible, ideally not requiring any user interaction for read-only operations.

Proposed Solution:

  1. Key Pair Generation: Each PWA will have its own unique key pair. The public key is used for server-side authentication, while the private key is encrypted and stored locally on the user's device.

  2. Secret Encryption: To protect the private key encryption secret, we'll utilize a user-specific piece of information that is:

    • Memorable: Easily remembered by the user (e.g., a strong, memorable PIN).
    • Not Locally Stored: Not directly stored on the device to minimize the risk of compromise.
  3. Key Server Functionality:

    • Secure Secret Storage: The Key Server will store an encrypted copy of the device secret.
    • Passkey Support: For devices with passkey capabilities, the secret can be bound to the user's passkey, eliminating the need for a PIN.
    • PIN-Based Recovery: If passkeys are not available, the user can recover their secret using their PIN.
    • TOTP Fallback: As a secondary recovery method, the Key Server will support TOTP (Time-based One-Time Password) generation for users who forget their PIN.
  4. Offline Mode:

    • For offline scenarios, the user will need to enter their PIN to access the locally encrypted secret. This PIN will be hashed (with a salt) to derive the encryption key.
    • Read-only app functionality may not require PIN authentication, enhancing user experience.

Functional Requirements:

  • Secret Storage and Encryption:
    • Securely store and encrypt user secrets on the server.
    • Utilize strong encryption algorithms for data protection.
  • Passkey Integration:
    • Implement WebAuthn or a similar protocol for passkey-based authentication.
    • Bind user secrets to passkeys for seamless access.
  • PIN-Based Authentication:
    • Allow users to authenticate using their PIN.
    • Implement secure hashing and salting mechanisms for PIN storage.
  • TOTP Fallback:
    • Generate and deliver time-based OTPs for secret recovery.
    • Configure OTP expiration times for enhanced security.
  • Offline Functionality:
    • Enable local decryption of secrets using PIN-derived keys in offline mode.
    • Synchronize local data with the Key Server when online connectivity is restored.
  • API Endpoints:
    • Secret Backup API: For securely backing up user secrets.
    • Secret Recovery API: For retrieving and restoring secrets after authentication (passkey or PIN).
    • Passkey Authentication API: For handling passkey-based authentication.
    • OTP Generation API: For generating and delivering OTPs.

Security Requirements:

  • Encryption:
    • Encrypt all sensitive data (secrets, passkeys) during storage and transmission.
  • Logging and Auditing:
    • Log all authentication and secret recovery events.
    • Maintain a comprehensive audit trail for data access and modifications.
  • User Data Privacy:
    • Adhere to relevant privacy regulations (e.g., GDPR, CCPA).
    • Minimize data collection and storage.
  • Session Management:
    • Implement session timeouts and ensure passkeys and OTPs expire after a defined period.
  • Immutable Device Binding:
    • Server-side storage of device credentials must be cryptographically bound to a unique device identifier.
    • This binding should prevent system administrators from manipulating server-side data to compromise user accounts.
    • Passkey Implementation: Utilize the public key as the device identifier.
    • OTP Implementation: Use a salted hash of the OTP secret key as the device identifier.
    • Ensure that any server-side manipulation cannot re-associate credentials with a different device identifier.

Non-Functional Requirements:

  • Performance: The Key Server should be highly responsive to ensure a smooth user experience.
  • Scalability: The system should be able to handle a growing number of users and PWAs.
  • Reliability: Ensure high availability and fault tolerance to minimize service disruptions.
  • Tamper-Proof Storage: Implement mechanisms to ensure the integrity and immutability of device credentials stored on the server, preventing unauthorized modification.

Benefits:

  • Enhanced Security: Strong encryption and multiple authentication methods protect user secrets.
  • Improved User Experience: Streamlined authentication with minimal user interaction.
  • Offline Accessibility: Maintain app functionality even without internet connectivity.
  • Flexible Authentication: Support for both passkeys and PINs caters to a wider range of devices and user preferences.
@francis-pouatcha francis-pouatcha changed the title Set Up SecretServer to Support Passkeys, OTP, and Secure PIN Storage Design and Implementation of a Secure Key Server for PWA Secret Key Recovery Jan 20, 2025
@francis-pouatcha francis-pouatcha changed the title Design and Implementation of a Secure Key Server for PWA Secret Key Recovery Design and Implementation of a Secure Key Server for PWA Authentication Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant