-
Notifications
You must be signed in to change notification settings - Fork 0
Description
🎯 Vision
Implement end-to-end client-side file encryption for files shared via Share Target API before upload to backend, ensuring zero-knowledge architecture where the backend cannot decrypt file contents.
📋 Sub-Issues & Work Plan
Implementation Phases
- Phase 1: Crypto Utilities (AES-GCM, HKDF, SHA-256) #172 Phase 1: Crypto Utilities ✅ COMPLETE (PR feat(crypto): Phase 1 - AES-GCM-256 Encryption Utilities #177 - Merged 19.11.2025)
- Phase 2: ShareTarget Encryption Integration #173 Phase 2: ShareTarget Integration ✅ COMPLETE (PR [WIP] feat: Phase 2 - ShareTarget Encryption Integration #178 - Merged 19.11.2025)
- Phase 3: Upload Integration (Encrypted Blobs to Backend) #175 Phase 3: Upload Integration ✅ COMPLETE (PR feat: Phase 3 - Upload Integration (Client-Side File Encryption) #187 - Merged 21.11.2025)
- Phase 4: Download & Decryption (Client-Side File Decryption) #176 Phase 4: Download & Decryption ✅ COMPLETE (PR feat: Phase 4 - Download & Decryption (Client-Side File Encryption) #188 - Merged 21.11.2025)
- Phase 5: Security Audit & Documentation (FINAL) #174 Phase 5: Security Audit & Documentation ⏳ FINAL PHASE
🎯 Success Criteria
- ✅ End-to-End Encryption: Files encrypted client-side before upload
- ✅ Zero-Knowledge Backend: Server cannot decrypt file contents
- ✅ Web Crypto API: Browser-native AES-GCM-256 encryption
- ✅ Secure Key Management: HKDF-based key derivation from Secret's master key
- ✅ Integrity Verification: SHA-256 checksums before/after encryption
- ✅ Comprehensive Tests: ≥80% coverage, known test vectors validated
- ⏳ Security Audit: Final review pending (Phase 5)
- ⏳ Documentation: Final documentation pending (Phase 5)
📚 Technical Architecture
Encryption Flow
1. User shares file via Share Target API
→ File stored in IndexedDB (unencrypted, temporary)
2. User selects/creates Secret
→ Derive file encryption key from Secret's master key (HKDF)
3. Encrypt file client-side (Web Crypto API)
→ AES-GCM-256 with random IV (12 bytes)
→ Generate auth tag (16 bytes)
→ Calculate SHA-256 checksum
4. Upload encrypted blob + metadata to backend
→ Backend stores encrypted file as-is (no decryption)
→ Metadata (filename, size, type) encrypted separately
5. Download: Fetch encrypted blob
→ Decrypt client-side with Secret's key
→ Verify checksum
→ Display/download decrypted file
Key Features
Core Encryption:
- AES-GCM-256 with 128-bit auth tag
- Random IV per encryption operation (12 bytes)
- HKDF-based key derivation (secure, deterministic)
- Non-extractable CryptoKeys (never leave secure storage)
Integrity Protection:
- SHA-256 checksums (before/after encryption)
- GCM auth tag (automatic tampering detection)
- Checksum verification enforced on download
Security:
- Zero-knowledge architecture (backend blind to contents)
- Keys never logged or exposed
- Known test vectors validated (NIST)
- Forward secrecy ready
🔗 Dependencies
Requires (All Complete):
- ✅ feat: Add POST method file sharing support to Share Target API (#101) #140 - Share Target POST method (Merged)
- ✅ enhancement: Add file upload to backend API for Secret attachments #141 - Backend file upload API (Completed)
- ✅ enhancement: Implement IndexedDB storage for offline file queue #142 - IndexedDB storage (Completed)
- ✅ Phase 1: Secret Model + CRUD API (Backend Foundation) api#174 - Secret Model + CRUD API (Merged)
- ✅ Phase 2: File Attachments API (Upload/Download/Encryption) api#175 - File Attachments API (Merged)
Part of:
- Epic: Progressive Web App Infrastructure #64 - Progressive Web App Infrastructure (Epic)
Blocks:
- Full zero-knowledge architecture ✅ READY
- Public beta release (awaiting Phase 5 security audit)
📊 Implementation Timeline
Phase 1: Crypto Utilities ✅ COMPLETE (19.11.2025)
Phase 2: ShareTarget Integration ✅ COMPLETE (19.11.2025)
Phase 3: Upload Integration ✅ COMPLETE (21.11.2025)
Phase 4: Download & Decryption ✅ COMPLETE (21.11.2025)
Phase 5: Security Audit & Documentation ⏳ IN PROGRESS
Total Estimated Effort: 2 weeks
Current Progress: 80% (Phase 1-4 complete, Phase 5 in progress - 21.11.2025)
🔒 Security Considerations
- ✅ NEVER log or expose encryption keys - VERIFIED
- ✅ Use secure key derivation (HKDF, not simple hash) - IMPLEMENTED
- ✅ Verify file integrity (checksum before/after) - ENFORCED
- ⏳ Handle key rotation carefully - TO BE REVIEWED (Phase 5)
- ✅ Test against known encryption test vectors (NIST) - VALIDATED
- ⏳ Consider forward secrecy for future implementations - DOCUMENTED
🚫 Non-Goals (Future Work)
- File compression (handle separately)
- Chunked encryption for large files (>10MB)
- Multi-party encryption (shared Secrets)
- Key escrow/recovery mechanisms
- Client-side key backup
📚 References
- Web Crypto API
- AES-GCM Mode
- HKDF Specification
- Share Target Implementation
- PR feat(crypto): Phase 1 - AES-GCM-256 Encryption Utilities #177 (Phase 1): feat(crypto): Phase 1 - AES-GCM-256 Encryption Utilities #177
- PR [WIP] feat: Phase 2 - ShareTarget Encryption Integration #178 (Phase 2): [WIP] feat: Phase 2 - ShareTarget Encryption Integration #178
- PR feat: Phase 3 - Upload Integration (Client-Side File Encryption) #187 (Phase 3): feat: Phase 3 - Upload Integration (Client-Side File Encryption) #187
- PR feat: Phase 4 - Download & Decryption (Client-Side File Encryption) #188 (Phase 4): feat: Phase 4 - Download & Decryption (Client-Side File Encryption) #188
Type: Epic
Priority: High (Security-Critical)
Target Milestone: v0.3.0
Status: 80% Complete (Phase 1-4 done, Phase 5 final - 21.11.2025)