[READ-ONLY] Mirror of https://github.com/mrgnw/ananas. learn multiple languages at once
ananas.xcc.es
2.9 kB
Based on the Lucia example analysis, here are the remaining improvements we should make:
Security & Cryptographic Validation
- 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
- 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
- Separate passkeys from security keys - Create distinct tables/handling for passkeys vs security keys - Different authenticator selection criteria for each type
- 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
- 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
- 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
- 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
- Add host/origin validation - Validate RP ID matches expected domain - Verify origin in client data JSON - Add environment-specific configuration
Additional Security Features
- Add credential management features - Allow users to name/rename their passkeys - Show last used timestamps - Enable passkey deletion/management
- 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
- Add proper transaction handling - Wrap database operations in transactions - Handle race conditions properly - Add proper cleanup of expired challenges
- 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.