E2EE THREAT MODEL - nself-org/nchat GitHub Wiki
Version: 1.0.0 Date: 2026-02-03 Status: Production Ready
- Executive Summary
- System Overview
- Trust Boundaries
- Threat Actors
- Assets
- Threats and Mitigations
- Attack Scenarios
- Security Guarantees
- Limitations
- Incident Response
nself-chat implements Signal Protocol end-to-end encryption (E2EE) to provide confidential, authenticated communication between users. This threat model documents the security boundaries, potential threats, and mitigation strategies employed to protect user communications.
-
Signal Protocol implementation using
@signalapp/libsignal-client - X3DH (Extended Triple Diffie-Hellman) key exchange
- Double Ratchet algorithm for forward secrecy and break-in recovery
- Hardware-backed key storage using IndexedDB with encryption
- Device lock policies with PIN/biometric authentication
- Remote wipe capabilities for compromised devices
- Safety number verification for identity verification
┌─────────────────────────────────────────────────────────────┐
│ User Devices │
│ ┌───────────┐ ┌───────────┐ ┌───────────┐ │
│ │ Browser │ │ Mobile │ │ Desktop │ │
│ │ (PWA) │ │ (Cap.) │ │ (Electron)│ │
│ └─────┬─────┘ └─────┬─────┘ └─────┬─────┘ │
└────────┼──────────────┼──────────────┼───────────────────────┘
│ │ │
│ E2EE Messages │
│ (Encrypted End-to-End) │
│ │ │
┌────────┼──────────────┼──────────────┼───────────────────────┐
│ │ Server Layer │ │
│ ┌─────▼──────────────▼──────────────▼─────┐ │
│ │ Hasura GraphQL + PostgreSQL │ │
│ │ (Stores encrypted payloads only) │ │
│ └──────────────────────────────────────────┘ │
│ ┌──────────────────────────────────────────┐ │
│ │ Nhost Auth (User Management) │ │
│ └──────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────┘
| Component | Algorithm/Protocol | Purpose |
|---|---|---|
| Identity Keys | Curve25519 | Long-term device identity |
| Signed Prekeys | Curve25519 + Ed25519 | Medium-term keys with signature |
| One-time Prekeys | Curve25519 | Perfect forward secrecy |
| Message Encryption | AES-256-GCM | Symmetric message encryption |
| Key Derivation | PBKDF2-SHA256 | Master key from password |
| Hash Functions | SHA-256, SHA-512 | Fingerprints and integrity |
| Random Generation | Web Crypto API | Secure randomness |
-
User's Device - Fully trusted
- Browser environment (WebCrypto API)
- Local storage (encrypted)
- Device hardware (for biometrics)
-
Signal Protocol Libraries - Trusted
-
@signalapp/libsignal-client(official Signal library) -
@noble/hashes,@noble/curves(audited crypto libraries)
-
-
User-Controlled Keys - Trusted
- Master key derived from password
- Device identity keys
- Session keys
-
Server Infrastructure - Untrusted for confidentiality
- Can see metadata (who talks to whom, when)
- Cannot see message content (encrypted)
- Can perform DoS attacks
- Can manipulate delivery timing
-
Network Layer - Untrusted
- Can observe traffic patterns
- Can perform man-in-the-middle attacks (mitigated by E2EE)
- Can block or delay messages
-
Third-Party Services - Untrusted
- Analytics providers (can track metadata)
- CDN providers (can serve malicious code)
- DNS providers (can redirect traffic)
┌─────────────────────────────────────────┐
│ TRUSTED ZONE │
│ ┌────────────────────────────────┐ │
│ │ User Device │ │
│ │ - Private Keys │ │
│ │ - Master Key │ │
│ │ - Decrypted Messages │ │
│ └────────────────────────────────┘ │
└─────────────────────────────────────────┘
▲
│ E2EE Channel
│
┌─────────────┼───────────────────────────┐
│ UNTRUSTED ZONE │
│ ┌──────────▼──────────────────────┐ │
│ │ Server │ │
│ │ - Encrypted Messages │ │
│ │ - Public Keys │ │
│ │ - Metadata │ │
│ └──────────────────────────────────┘ │
└──────────────────────────────────────────┘
Capabilities:
- Observe network traffic
- Monitor server data
- Analyze metadata
Mitigations:
- End-to-end encryption (message content protected)
- TLS/HTTPS (network layer encryption)
- Metadata minimization
Capabilities:
- Man-in-the-middle attacks
- Traffic injection
- Message tampering
Mitigations:
- Authenticated encryption (AES-GCM)
- Safety number verification
- Certificate pinning (optional)
Capabilities:
- Serve malicious code updates
- Correlate metadata
- Selective message delivery
- DoS attacks
Mitigations:
- Subresource Integrity (SRI)
- Content Security Policy (CSP)
- Safety number verification
- Client-side validation
Capabilities:
- Access to local storage
- Keyloggers
- Screen capture
- Memory dumping
Mitigations:
- Device lock (PIN/biometric)
- Encrypted storage
- Secure memory wiping
- Remote wipe capability
Capabilities:
- All of the above
- Zero-day exploits
- Endpoint compromise
- Traffic analysis
Mitigations:
- Defense in depth
- Regular security updates
- Threat monitoring
- Incident response plan
-
Master Key
- Description: User's password-derived encryption key
- Storage: Memory only (never persisted)
- Protection: PBKDF2 derivation (100k iterations)
-
Private Identity Key
- Description: Long-term device identity key
- Storage: Encrypted in database with master key
- Protection: AES-256-GCM encryption
-
Session Keys
- Description: Ephemeral keys for message encryption
- Storage: Encrypted IndexedDB
- Protection: Derived via Double Ratchet
-
Message Plaintext
- Description: Decrypted message content
- Storage: Memory only (browser DOM)
- Protection: Never persisted unencrypted
-
Signed Prekeys
- Description: Medium-term keys for key exchange
- Storage: Encrypted in database
- Rotation: Weekly
-
One-Time Prekeys
- Description: Single-use keys for perfect forward secrecy
- Storage: Encrypted in database
- Consumption: Used once and discarded
-
Recovery Code
- Description: Master key recovery mechanism
- Storage: Session storage (temporary)
- Protection: User must write down
-
Safety Numbers
- Description: Identity verification codes
- Storage: Generated on-demand
- Protection: Public information
-
Metadata
- Description: Message timestamps, sender/recipient
- Storage: Database (unencrypted)
- Protection: Minimized collection
Threat: Attacker intercepts messages in transit
Attack Vector: Network sniffing, MITM attack
Impact: Loss of confidentiality
Likelihood: Medium
Mitigations:
- Signal Protocol E2EE (implemented) ✅
- TLS/HTTPS transport encryption (implemented) ✅
- Certificate pinning (optional) 🔄
Residual Risk: Low
Threat: Attacker gains access to private keys
Attack Vector: Device theft, malware, memory dump
Impact: Past/future message decryption
Likelihood: Low
Mitigations:
- Forward secrecy via Double Ratchet (implemented) ✅
- Device lock with PIN/biometric (implemented) ✅
- Encrypted key storage (implemented) ✅
- Remote wipe capability (implemented) ✅
- Break-in recovery (Signal Protocol feature) ✅
Residual Risk: Low
Threat: Attacker compromises server infrastructure
Attack Vector: Server breach, insider threat
Impact: Metadata disclosure, DoS
Likelihood: Low
Mitigations:
- E2EE (server cannot decrypt) ✅
- Safety number verification ✅
- Client-side key management ✅
- Metadata minimization 🔄
Residual Risk: Medium (metadata still exposed)
Threat: Attacker serves malicious JavaScript
Attack Vector: Compromised CDN, XSS, supply chain attack
Impact: Full compromise of client security
Likelihood: Low
Mitigations:
- Content Security Policy (implemented) ✅
- Subresource Integrity (implemented) ✅
- Code signing (planned) 🔄
- Reproducible builds (planned) 🔄
Residual Risk: Medium
Threat: Attacker impersonates another user
Attack Vector: Key substitution, server manipulation
Impact: Loss of authenticity
Likelihood: Low
Mitigations:
- Safety number verification (implemented) ✅
- Signal Protocol identity keys ✅
- Trust-on-first-use (TOFU) model ✅
- Out-of-band verification (manual) ✅
Residual Risk: Low (with verification)
Threat: Attacker replays old messages
Attack Vector: Message capture and re-injection
Impact: Confusion, unauthorized actions
Likelihood: Low
Mitigations:
- Double Ratchet nonces (implemented) ✅
- Message counters (Signal Protocol) ✅
- Timestamp validation 🔄
Residual Risk: Very Low
Threat: Attacker prevents message delivery
Attack Vector: Server flood, network disruption
Impact: Loss of availability
Likelihood: Medium
Mitigations:
- Rate limiting (implemented) ✅
- Message queuing (implemented) ✅
- Offline support 🔄
Residual Risk: Medium
Threat: Attacker analyzes communication patterns
Attack Vector: Traffic analysis, timing attacks
Impact: Social graph disclosure
Likelihood: High
Mitigations:
- Metadata minimization 🔄
- Sealed sender (planned) 🔄
- Padding (planned) 🔄
Residual Risk: High
Threat: Attacker compromises user device
Attack Vector: Malware, physical access, zero-day
Impact: Full compromise
Likelihood: Low
Mitigations:
- Device lock (implemented) ✅
- Remote wipe (implemented) ✅
- Encrypted storage (implemented) ✅
- Regular updates ✅
Residual Risk: Medium
Attacker: State-level actor with server access
Capabilities:
- Full server access
- Traffic monitoring
- Endpoint targeting
Attack Path:
- Compromise server infrastructure
- Collect encrypted messages and metadata
- Target high-value endpoints with zero-days
- Decrypt targeted conversations
Defense:
- E2EE prevents mass decryption
- Safety number verification detects MITM
- Device lock limits endpoint compromise
- Regular updates patch vulnerabilities
Outcome: Metadata exposed, targeted content at risk
Attacker: Insider with database access
Capabilities:
- Read database contents
- Manipulate message delivery
Attack Path:
- Access database via compromised credentials
- Export encrypted messages
- Analyze metadata for target identification
- Attempt offline attacks on keys
Defense:
- E2EE renders encrypted payloads useless
- Keys stored encrypted with user passwords
- Audit logging detects suspicious access
- RBAC limits database permissions
Outcome: Metadata compromised, content protected
Attacker: Thief with physical access
Capabilities:
- Full device access
- Storage extraction
- Memory analysis
Attack Path:
- Steal unlocked device
- Extract local storage and IndexedDB
- Attempt to decrypt keys
- Access messages in memory
Defense:
- Device auto-lock after inactivity
- Encrypted storage requires master key
- Remote wipe capability
- Keys never persisted in plaintext
Outcome: If device locked, minimal risk; if unlocked, current session compromised
Attacker: Compromised CDN or server
Capabilities:
- Serve modified JavaScript
- Inject backdoor code
Attack Path:
- Compromise deployment pipeline
- Inject malicious code into build
- Serve to users on next update
- Exfiltrate keys via backdoor
Defense:
- Subresource Integrity (SRI) prevents modification
- Content Security Policy blocks exfiltration
- Code review process
- Reproducible builds (planned)
Outcome: SRI and CSP block attack; manual verification possible
✅ Message Confidentiality: Server cannot read message content ✅ Message Authenticity: Recipient can verify sender identity ✅ Forward Secrecy: Past messages secure even if keys compromised ✅ Break-in Recovery: Future messages secure after key compromise ✅ Deniability: Plausible deniability for senders (Signal Protocol feature)
❌ Metadata: Server sees who talks to whom, when ❌ Endpoint Security: Compromised device reveals all ❌ Traffic Analysis: Network observers see patterns ❌ User Behavior: Server logs activity ❌ Group Size: Number of participants visible
-
Web-Based Deployment
- Limitation: Server can serve malicious updates
- Mitigation: SRI, CSP, code signing (planned)
- Residual Risk: Medium
-
Metadata Collection
- Limitation: Server stores metadata (timestamps, participants)
- Mitigation: Metadata minimization, sealed sender (planned)
- Residual Risk: High
-
Group Messaging
- Limitation: Sender keys more complex than 1:1
- Mitigation: Signal's sender keys protocol
- Residual Risk: Low
-
Key Verification
- Limitation: Users must manually verify safety numbers
- Mitigation: QR codes, out-of-band verification
- Residual Risk: Medium (social engineering)
-
Browser Environment
- Limitation: Less secure than native apps
- Mitigation: Modern browser security features
- Residual Risk: Medium
- Backup Encryption: User-managed backups not encrypted
- Screenshot Protection: Browser cannot prevent screenshots
- Forensic Resistance: Browser history/cache may leak metadata
- Anonymous Messaging: User identity linked to account
-
Safety Number Mismatch
- Action: Warn user, require verification
- Timeline: Immediate
-
Unexpected Key Change
- Action: Alert user, show safety number
- Timeline: Immediate
-
Failed Decryption
- Action: Log error, prompt re-sync
- Timeline: Immediate
-
Unauthorized Device
- Action: Send notification, offer remote wipe
- Timeline: <5 minutes
- Monitor security alerts
- Analyze suspicious activity
- Confirm incident severity
- Remote wipe compromised devices
- Revoke compromised keys
- Notify affected users
- Disable compromised accounts
- Patch vulnerabilities
- Deploy security updates
- Reset compromised infrastructure
- Audit logs for IOCs
- Restore service
- Re-key affected sessions
- Verify safety numbers
- Monitor for recurrence
- Post-mortem analysis
- Update threat model
- Improve defenses
- Update documentation
-
Cryptographic Implementation Review (Annual)
- Verify Signal Protocol implementation
- Review key management
- Test random number generation
-
Penetration Testing (Quarterly)
- Endpoint security
- Server security
- Network security
-
Code Audit (Continuous)
- Dependency scanning
- SAST/DAST tools
- Manual code review
-
Third-Party Audit (As needed)
- Independent security firms
- Public disclosure
- CVE tracking
- NIST SP 800-57: Key Management (Implemented)
- NIST SP 800-63B: Digital Identity Guidelines (Implemented)
- OWASP ASVS: Application Security Verification (Level 2)
- Signal Protocol Specification: Fully compliant
- GDPR: Right to erasure (remote wipe)
- CCPA: Data deletion
- HIPAA: End-to-end encryption (healthcare use cases)
nself-chat implements production-grade Signal Protocol E2EE with comprehensive security controls:
✅ Confidentiality: Messages encrypted end-to-end ✅ Authenticity: Cryptographic signatures and safety numbers ✅ Forward Secrecy: Double Ratchet algorithm ✅ Device Security: PIN/biometric lock, remote wipe ✅ Key Management: Encrypted storage, secure generation
Residual Risks:
- Metadata collection (inherent to server architecture)
- Web-based deployment (SRI/CSP mitigations)
- Endpoint compromise (defense-in-depth)
Recommended Actions:
- Enable safety number verification for sensitive conversations
- Use device lock on all devices
- Regularly update to latest security patches
- Verify server code updates (when available)
- Report security issues to [email protected]
Document Version: 1.0.0 Last Updated: 2026-02-03 Next Review: 2026-05-03 Owner: Security Team Classification: Public