[READ-ONLY] Mirror of https://github.com/mrgnw/ananas. learn multiple languages at once ananas.xcc.es
0

Configure Feed

Select the types of activity you want to include in your feed.

ananas / lucia-notes.md
2.9 kB

Based on the Lucia example analysis, here are the remaining improvements we should make:

Security & Cryptographic Validation

  1. Add proper WebAuthn signature verification - Install and use @oslojs/webauthn for parsing attestation objects and authenticator data - Implement real cryptographic signature verification during authentication - Parse and validate client data JSON properly
  2. Add proper public key extraction and storage - Extract actual public keys from attestation objects during registration - Store algorithm IDs alongside public keys - Use proper COSE key parsing for ES256/RS256 algorithms

Database Schema Improvements

  1. Separate passkeys from security keys - Create distinct tables/handling for passkeys vs security keys - Different authenticator selection criteria for each type
  2. Store proper credential metadata - Add algorithm_id field to store COSE algorithm identifier - Store actual public keys instead of raw attestation objects - Add credential counter for replay attack protection

Challenge Management

  1. Implement dedicated challenge endpoint - Create /api/webauthn/challenge endpoint separate from begin flows - Add proper rate limiting to challenge generation - Centralize challenge creation and validation
  2. Add comprehensive rate limiting - Rate limit challenge requests per IP - Rate limit authentication attempts per user - Implement exponential backoff for failed attempts

Code Organization & Architecture

  1. Add proper error handling and logging - Implement structured logging for WebAuthn operations - Better error messages and error categorization - Handle edge cases and browser compatibility issues
  2. Add host/origin validation - Validate RP ID matches expected domain - Verify origin in client data JSON - Add environment-specific configuration

Additional Security Features

  1. Add credential management features - Allow users to name/rename their passkeys - Show last used timestamps - Enable passkey deletion/management
  2. Add 2FA integration - Support passkeys as 2FA method alongside TOTP - Recovery code support for passkey-only accounts - Proper session management with 2FA verification flags

Performance & Reliability

  1. Add proper transaction handling - Wrap database operations in transactions - Handle race conditions properly - Add proper cleanup of expired challenges
  2. Add user enumeration protection - Consistent timing for valid/invalid emails - Generic error messages that don't leak user existence

The most critical missing pieces are proper signature verification and real public key storage - our current implementation is essentially just storing credentials without actually validating their authenticity, which is a major security vulnerability.