Commit Graph

57 Commits

Author SHA1 Message Date
lockbitchat
ee635da66f docs: Update README to v4.7.53 with Desktop Edition and roadmap updates
- Update version to v4.7.53
- Add Desktop Edition documentation (Windows, macOS, Linux)
- Update roadmap with all versions and dates
- Add mobile apps information (Q1 2026)
- Expand security and development sections
- Update URLs to securebit.chat domain
2025-12-28 20:28:22 -04:00
lockbitchat
79c8d08782 fix: prevent encryption key loss and IndexedDB connection errors
Some checks failed
CodeQL Analysis / Analyze CodeQL (push) Has been cancelled
Mirror to Codeberg / mirror (push) Has been cancelled
Mirror to PrivacyGuides / mirror (push) Has been cancelled
- Disable timer-based key rotation for Double Ratchet mode
- Auto-reinitialize encryption keys when missing but ECDH available
- Preserve active keys during periodic cleanup in ratchet sessions
- Fix IndexedDB "database closing" errors with connection checking
- Add individual transactions per queue item to prevent race conditions
2025-11-04 13:14:24 -04:00
lockbitchat
207e51361c security: increase PBKDF2 iterations from 100,000 → 310,000 (OWASP 2025 compliance)
Some checks failed
CodeQL Analysis / Analyze CodeQL (push) Has been cancelled
Mirror to Codeberg / mirror (push) Has been cancelled
Mirror to PrivacyGuides / mirror (push) Has been cancelled
Updated PBKDF2 key derivation parameters to align with OWASP 2025 recommendations.
PBKDF2-HMAC-SHA256 now uses 310,000 iterations instead of 100,000 to improve resistance
against modern GPU and ASIC brute-force attacks.

- Updated both encryptData() and decryptData() derivation routines.
- Ensures ~100ms derivation time on modern CPUs (meets OWASP 2025 standard).
- No changes required for backward compatibility of existing ciphertexts.
2025-10-30 15:24:09 -04:00
lockbitchat
4583db39a2 feat(security): switch master key to non-extractable CryptoKey handle and remove direct access
Some checks failed
CodeQL Analysis / Analyze CodeQL (push) Has been cancelled
Mirror to Codeberg / mirror (push) Has been cancelled
Mirror to PrivacyGuides / mirror (push) Has been cancelled
2025-10-30 15:16:36 -04:00
lockbitchat
77ed4b3e4f remove key/hash logging and debug output from EnhancedSecureWebRTCManager and EnhancedSecureCryptoUtils
Some checks failed
CodeQL Analysis / Analyze CodeQL (push) Has been cancelled
Mirror to Codeberg / mirror (push) Has been cancelled
Mirror to PrivacyGuides / mirror (push) Has been cancelled
2025-10-30 14:55:46 -04:00
lockbitchat
c7b16157fc Enhanced HKDF-based key derivation with improved security features
Some checks failed
CodeQL Analysis / Analyze CodeQL (push) Has been cancelled
Mirror to Codeberg / mirror (push) Has been cancelled
Mirror to PrivacyGuides / mirror (push) Has been cancelled
- Implemented proper RFC 5869 compliant HKDF key derivation process
- Added Perfect Forward Secrecy (PFS) key for enhanced session security
- Improved key separation using unique info parameters for each derived key
- Enhanced salt size from 32 to 64 bytes for increased entropy
- Added comprehensive key validation and error handling
- Implemented proper ECDH + HKDF integration following Web Crypto API best practices
- Added metadata encryption key for enhanced data protection
- Improved compatibility with modern cryptographic standards (RFC 7748, NIST SP 800-56A)
 -Enhanced logging and debugging capabilities for cryptographic operations
- Maintained backward compatibility while upgrading security infrastructure
Security improvements:
- Cryptographic isolation between different key purposes
- Enhanced protection against cross-key attacks
- Improved resistance to future key compromise scenarios
- Better compliance with OWASP cryptographic storage guidelines
Technical details:
- Refactored deriveSharedKeys() method for proper HKDF implementation
- Updated WebRTC manager to use new messageKey API
- Added comprehensive error handling and validation
- Improved browser compatibility with standardized cryptographic operations
- This update strengthens the existing security foundation with modern cryptographic practices while maintaining full system compatibility.
2025-10-27 15:18:15 -04:00
lockbitchat
40381cc0a1 Increase session timeout to 60min and inactivity to 30min
Fix sendMessage isUnlocked check to prevent immediate lock
Move session extension logic to SecureMasterKeyManager
Improve error messages
Keep validation of crypto keys before encryption
2025-10-20 02:06:42 -04:00
lockbitchat
7604381584 fix: eliminate division on crypto random in getSafeRandomFloat 2025-10-20 01:10:25 -04:00
lockbitchat
a7a5861e0a fix: replace modulo with bitwise mask in crypto random 2025-10-20 01:02:07 -04:00
lockbitchat
63a19e6a4c fix: resolve CodeQL biased crypto random warning
Use unsigned right shift (>>>) to properly handle 32-bit random values and eliminate statistical bias.
2025-10-20 00:51:03 -04:00
lockbitchat
9c1258cd1e Fix cryptographic random bias in fingerprint mask generation 2025-10-20 00:42:03 -04:00
lockbitchat
60e4bb6b8a Fix cryptographic random bias in getUnbiasedRandomInRange
Reworked getUnbiasedRandomInRange() to eliminate modulo bias by using
rejection sampling combined with bucket indexing instead of the `%` operator.
Added getUnbiasedRandomFloat() to safely generate unbiased floats for
sizeVariation and sizeMultiplier.
2025-10-20 00:34:17 -04:00
lockbitchat
4233ba3d7e Fix cryptographic random bias (CodeQL js/biased-cryptographic-random)
Reimplemented getUnbiasedRandomInRange() using rejection sampling for all range sizes to eliminate modulo bias and ensure uniform cryptographically secure randomness.
2025-10-20 00:25:50 -04:00
lockbitchat
5c658cdd6c Security updates for CodeQL 2025-10-19 23:39:14 -04:00
lockbitchat
e209d3e6f5 fix: improve sanitization to prevent XSS
- Now the sanitization function protects against:
  - Nested script tags: <scrip<script>alert("XSS")</script>t>
  - HTML comments containing scripts: <!-- <script>alert("XSS")</script> -->
  - Multiple overlapping tags: <script><script>alert("XSS")</script></script>
  - Attributes in closing tags: </script foo="bar">
  - Complex nested structures combining different tags
  - All known XSS vectors
2025-10-19 23:23:58 -04:00
lockbitchat
49e5a054cb fix: security and build improvements
- Fixed biased cryptographic random with modulo operations
- Corrected biased cryptographic random with addition operations
- Resolved infinite page loading issue
- Rebuilt all distribution files
2025-10-19 23:05:24 -04:00
lockbitchat
d292c84829 session bug fix 2025-10-13 11:13:11 -04:00
lockbitchat
7af8f528ff refactor: implement minimal PWA caching strategy
- Cache only essential PWA assets (manifest, icons, core scripts)
- Use Network First for all other requests
- Remove aggressive caching of UI components and styles
- Preserve PWA installation while minimizing cache footprint
2025-10-13 01:35:32 -04:00
lockbitchat
75fa1cd27d Qr generator create bug fix 2025-10-08 01:24:04 -04:00
lockbitchat
204e1edd9a Update version to 4.3.120 UX/UI 2025-10-08 00:08:13 -04:00
lockbitchat
6bed472e09 feat(security): implement core crypto and logging hardening
- removed all logging of raw IV, JWK, session tokens, verification codes
  → logs now only include error codes, timestamps and short non-reversible SHA-256 hashes (first 4 bytes)
- replaced global master key storage with PBKDF2-derived non-extractable AES key
  → master key lives only in session memory and is cleared on timeout/focus-out
- added password-based derivation (PBKDF2) for master key initialization
- migrated persistent key storage to AES-GCM wrapped ciphertext in IndexedDB
  → JWK export → encrypt with session master key → store ciphertext + IV + metadata
  → unwrap + import as non-extractable on restore
- removed busy-wait loops and direct `window.gc()` calls
  → replaced with async non-blocking cleanup via setTimeout/Promise/WebWorker
2025-10-02 03:25:38 -04:00
lockbitchat
65cc136b99 chore: remove debug logging and disable debug mode for production
- Removed temporary console logs used for debugging
- Disabled DEBUG_MODE flag
- Updated configuration to run in production mode
- Cleaned up leftover debug utilities to reduce noise in console
2025-10-02 01:43:32 -04:00
lockbitchat
34094956b7 feat(core): update session, security system and QR exchange
- Removed session creation and Lightning payment logic
- Refactored security system:
  * no more restrictions
  * all systems enabled on session creation
- Improved QR code exchange for mobile devices
2025-09-23 20:01:02 -04:00
lockbitchat
0f8399ec88 feat(security,ui): self-host React deps, Tailwind, fonts; strict CSP; local QR; better selection state
Replace CDN React/ReactDOM/Babel with local libs; remove Babel and inline scripts
Build Tailwind locally, add safelist; switch to assets/tailwind.css
Self-host Font Awesome and Inter (CSS + woff2); remove external font CDNs
Implement strict CSP (no unsafe-inline/eval; scripts/styles/fonts from self)
Extract inline handlers; move PWA scripts to external files
Add local QR code generation (qrcode lib) and remove api.qrserver.com
Improve SessionTypeSelector visual selection (highlighted background and ring)
Keep PWA working with service worker and offline assets
Refs: CSP hardening, offline-first, no external dependencies
2025-09-08 16:04:58 -04:00
lockbitchat
3458270477 deleting unnecessary comments 2025-09-08 11:45:32 -04:00
lockbitchat
e2316f6557 **What Changed:**
- **Removed:** All libsodium dependencies and PAKE-based authentication
- **Replaced With:** ECDH + DTLS + SAS triple-layer security system
- **Impact:** Eliminates complex PAKE implementation in favor of standardized protocols

**Security Benefits:**
-  **Simplified Architecture** - Reduced attack surface
-  **Standards Compliance** - RFC-compliant protocols
-  **Better Maintenance** - Native Web Crypto API usage
-  **Enhanced Security** - Triple-layer defense system

**New Features:**
- **Elliptic Curve Diffie-Hellman** using P-384 (secp384r1)
- **Cryptographically secure** key pair generation
- **Perfect Forward Secrecy** with session-specific keys
- **MITM resistance** requiring knowledge of both private keys
2025-09-04 17:25:01 -04:00
lockbitchat
beb5bcfd01 fix: resolve message sending - _createMessageAAD method not found
- Move methods to constructor for early availability
- Add connectionId initialization
- Remove duplicate definitions
- Fix AAD creation for anti-replay protection
2025-09-01 17:14:04 -04:00
lockbitchat
77c19c4d71 CRITICAL: Fix major security vulnerabilities
- Remove forced session verification bypass (MITM)
- Implement mandatory file message encryption with AAD
- Add DTLS fingerprint validation and SDP parsing
- Implement hard security gate for unverified connections
- Add emergency key wipe on security breaches
2025-09-01 16:04:33 -04:00
lockbitchat
a04fc16d58 Security Update 2025-09-01 15:15:42 -04:00
lockbitchat
14b001710a feat(security): strengthen crypto, entropy checks, and memory cleanup
- Added constant-time key validation to prevent timing attacks
- Improved randomization (crypto.getRandomValues, larger noise patterns)
- Optimized IV cleanup with batch processing and shorter lifetime
- Added multi-dimensional entropy analysis with quantum-resistant checks
- Enhanced emergency cleanup with atomic operations and rollback
2025-08-31 19:37:26 -04:00
lockbitchat
35d83d46f2 feat(security): Implement input validation and fix logging conflicts
- Added comprehensive input validation with size/rate limits
- Fixed logging conflicts by renaming _sanitizeString → _sanitizeInputString
- Implemented XSS/injection protection via pattern detection
- Added safe logging recovery mechanism
- Maintained all existing security protections
2025-08-31 18:35:31 -04:00
lockbitchat
6c4d0eeaee feat(security): harden API export, remove global flags, unify scheduler
- Removed reliance on window.DEBUG_MODE and window.DISABLE_* flags.
- Configuration is now passed via constructor instead of global variables.
- Exposed API remains on `window.secureBitChat`, but without backup globals or hidden toggles.
- Consolidated multiple setInterval tasks into a single scheduler to reduce attack surface.
- Added strict limits for IV history and log storage to prevent memory exhaustion.
- Improved XSS hardening: no more global switches to disable security features.
2025-08-31 18:01:46 -04:00
lockbitchat
39ae9f01b7 feat: comprehensive security fixes for critical vulnerabilities
BREAKING CHANGES:
- Enhanced logging system with comprehensive data sanitization
- Atomic key generation with race condition protection
- Strengthened mutex system implementation
- Complete IV reuse prevention system
- Secured global API with multi-layer protection
- Enhanced memory management with secure wiping
- Improved error handling without information disclosure

Security Fixes:
• CRITICAL: Fix logging system data leakage
  - Add comprehensive pattern detection (hex, base64, base58, base32)
  - Implement entropy-based sensitive data detection
  - Add suspicious character distribution analysis
  - Emergency disable logging on security violations
  - Reduce production logging to errors only

• CRITICAL: Resolve race conditions in key generation
  - Implement atomic state checks within mutex protection
  - Add proper waiting mechanism for concurrent operations
  - Validate key generation results before assignment
  - Add operation timeouts and error recovery

• HIGH: Strengthen mutex system implementation
  - Replace silent failures with proper error propagation
  - Add comprehensive mutex system validation
  - Implement authorized emergency unlock mechanisms
  - Enhanced timeout handling with state consistency
  - Add mutex diagnostics and recovery systems

• HIGH: Complete IV reuse prevention system
  - Implement comprehensive IV collision detection
  - Add entropy validation for generated IVs
  - Track IV usage across sessions with cleanup
  - Detect suspicious patterns and weak RNG
  - Emergency mode activation on security violations

• HIGH: Secure global API exposure
  - Multi-layer protection with Proxy-based access control
  - Block internal property access attempts
  - Implement API replacement monitoring and restoration
  - Add method interception protection
  - Comprehensive global namespace monitoring

• HIGH: Enhanced memory management
  - Implement secure memory wiping for all data types
  - Multiple overwrite passes (random, zeros, ones)
  - Secure cleanup of cryptographic materials
  - Force garbage collection where available
  - Track and validate memory cleanup operations

• HIGH: Improve error handling security
  - Categorize errors by security sensitivity
  - Generate safe error messages without internal details
  - Track error frequency for security monitoring
  - Implement secure error message mapping

Additional Security Enhancements:
• Add DTLS ClientHello race condition protection
• Implement enhanced SecureKeyStorage with encryption
• Add comprehensive IV tracking and validation systems
• Create emergency mode systems for security violations
• Enhance cryptographic validation and state management
• Add extensive security diagnostics and monitoring

Performance & Reliability:
• Optimize mutex usage to reduce contention
• Improve error recovery mechanisms
• Add comprehensive system validation
• Enhanced debugging and diagnostic capabilities
• Better resource cleanup and management
2025-08-31 15:52:34 -04:00
lockbitchat
551feb21a4 Security hardening: remove global leaks, enforce crypto, cleanup logs
- Removed unsafe exposure of internal objects:
      • deleted all references to `window.fileTransferSystem`
      • unified global API setup to a single immutable `safeGlobalAPI` via Object.freeze
      • removed legacy branch with `delete window[name]`

    - Logging improvements:
      • eliminated all direct `console.*` calls (use `_secureLog` exclusively)
      • fixed string templates with proper interpolation (``${var}``)
      • prevented accidental fallback to raw console in production

    - Cryptography enforcement:
      • updated `_validateCryptographicSecurity()` to require ECDSA and PFS
      • added emergency shutdown if critical crypto features are missing
      • ensured consistent feature enabling for production
2025-08-28 18:53:16 -04:00
lockbitchat
a265209ff6 fix(security): fixes in keystore and cryptography
- Metadata of extracted keys is now marked encrypted: true
- Removed decryption bypass via _keyReferences, all keys are returned via decrypt
- Nested encryption uses random 96-bit IV instead of single byte increment
- Fixed _secureLogShim: correct argument destructuring (...args)
- Removed busy-wait in forceInitializeFileTransfer, replaced with async wait
2025-08-28 17:01:14 -04:00
lockbitchat
97b87828e2 feat(security): encrypted key storage with WeakMap and SecureKeyStorage
- Added SecureKeyStorage class: JWK storage encrypted (AES-GCM) + WeakMap
- Support for non-extractable keys via secure links without export
- Implemented secure wipe/secure wipe all, statistics collection
- Improved secure logging: blacklist of sensitive fields, whitelist of secure ones
- Integration with WebRTC manager layers and secure key installation
2025-08-28 16:17:40 -04:00
lockbitchat
e468838596 SECURITY: Fix console logging vulnerabilities in production mode
- Replace unsafe console.error/warn calls with secure logging system
- Implement production-safe logging that masks sensitive data
- Add automatic sanitization for cryptographic keys and sensitive information
- Create secure logging infrastructure for EnhancedSecureWebRTCManager and EnhancedSecureCryptoUtils
- Prevent data leakage of internal logic and error details in production
- Add production/development mode detection for appropriate logging levels
- Implement server-side error logging for production environments
2025-08-28 15:05:42 -04:00
lockbitchat
171a7d9dfb Fixed DTLS Race Condition & Memory Safety
 FIXED HIGH CRITICALITY vulnerabilities (October 2024):
- DTLS ClientHello Race Condition: Added source validation
- Memory Safety Issues: Enhanced secure memory cleanup
- Added DTLS protection constants and validation methods
- Improved memory cleanup with secureWipe and zero-filling
- Integrated DTLS protection in handleSecureAnswer
2025-08-24 16:30:06 -04:00
lockbitchat
cef5654cf8 Update to pre-release version. Removed logging that was used for debugging. Added typing of files that the user sends with size restrictions. 2025-08-21 17:40:17 -04:00
lockbitchat
430ff2a6af - Removed redundant console.log statements to clean up the code
- Added English comments for better readability and GitHub compatibility
2025-08-21 05:16:41 -04:00
lockbitchat
31485989f7 feat(security): comprehensive connection security overhaul with mutex framework
Implemented robust security framework with custom withMutex system:

**Race condition protection:**
- Custom _withMutex('connectionOperation') implementation with 15s timeout
- Atomic key generation through _generateEncryptionKeys()
- Serialized connection operations to prevent conflicts

**Multi-stage validation pipeline:**
- Step-by-step validation (keys, fingerprints, SDP)
- Automatic rollback via _cleanupFailedOfferCreation() on failures
- Error phase detection for precise diagnostics

**Enhanced MITM protection:**
- Unique encryption key fingerprints
- Session ID anti-hijacking protection
- Mutual authentication challenge system
- Package integrity validation

**Advanced logging & monitoring:**
- Secure logging without sensitive data leaks
- Operation tracking via unique operationId
- Comprehensive error diagnostics and phase tracking
- Deadlock detection with emergency recovery

Breaking changes: Connection establishment now requires mutex coordination
2025-08-21 04:07:16 -04:00
lockbitchat
9b2884a3af implemented secure key storage with WeakMap isolation
- Replaced public key properties (`encryptionKey`, `macKey`, etc.) with private `WeakMap`-based storage
- Added secure access methods: `_initializeSecureKeyStorage()`, `_getSecureKey()`, `_setSecureKey()`
- Implemented validation (`_validateKeyValue()`), rotation (`_rotateKeys()`), and emergency wipe (`_emergencyKeyWipe()`)
- Updated `cleanupConnection()` and `disconnect()` for secure key handling
- Added getters/setters for backward compatibility with existing code
- Integrated key security monitoring via `_startKeySecurityMonitoring()`
- Ensured keys are inaccessible via direct property access or debugger

Fixes: Direct exposure of sensitive keys in memory
Security: Prevents unauthorized access, enforces key lifetime limits
2025-08-21 00:06:28 -04:00
lockbitchat
7ee5ec6208 Security: Implement secure logging to prevent data leaks in console
- Add production mode detection and secure logging system
- Replace console.log with _secureLog() that sanitizes sensitive data
- Hide encryption keys, message content, and security details from logs
- Implement log level control (production: warn+error only, dev: debug+)
- Add data sanitization for keys, tokens, buffers, and sensitive strings
- Prevent log spam with automatic rate limiting and cleanup
- Maintain useful debugging info while protecting user privacy
- Add automatic memory cleanup for log counters

Security Impact: HIGH - Prevents sensitive data exposure through browser console
Changes:
- Production: Only critical errors/warnings logged
- Development: Safe debugging info without sensitive content
- All message content, encryption keys, and tokens are now sanitized
- Automatic detection of production vs development environment
2025-08-20 23:34:56 -04:00
lockbitchat
73850f423c Security: Fix critical global exposure vulnerability in WebRTC Manager
- Remove dangerous global window exposure of encryption keys and manager instance
- Replace window.webrtcManager/globalWebRTCManager with secure limited API
- Add window.secureBitChat with validated public methods only
- Implement automatic monitoring for unauthorized global exposure attempts
- Add security integrity checks and emergency shutdown capability
- Prevent access to sensitive data (encryption keys, session data, internal methods)
- Maintain full functionality while securing internal implementation

BREAKING CHANGE: window.webrtcManager is no longer available
MIGRATION: Use window.secureBitChat.sendMessage() instead of window.webrtcManager.sendMessage()

Security Impact: CRITICAL - Prevents XSS attacks from accessing encryption keys
Tested: All functionality preserved, file transfers working, connections stable
2025-08-20 23:04:29 -04:00
lockbitchat
241212a315 🔧 Improve file transfer system integration and message handling
- File Transfer Integration: Refactored file transfer system initialization with better error handling and automatic retry mechanisms
- Message Filtering: Added comprehensive message filtering system to prevent file transfer and system messages from appearing in chat UI
- Callback System: Simplified file transfer callback system - removed progress notifications from chat to reduce noise
- System Message Deduplication: Implemented notification flags to prevent duplicate system messages (verification, security upgrades, etc.)
- Error Handling: Enhanced error handling with graceful fallbacks instead of throwing exceptions that could break connections
- UI Message Delivery: Added `deliverMessageToUI()` method with built-in filtering for system/file messages
- DataChannel Event Handling: Improved onmessage handler with early filtering for file transfer messages
- Global Integration: Better integration with global file transfer system (`window.fileTransferSystem`)
- Connection Stability: Removed aggressive reconnection attempts that could cause session closure
- Debug Logging: Enhanced debug logging for better troubleshooting

- File transfer messages now bypass chat UI entirely
- System messages are deduplicated using internal flags
- Better separation of concerns between WebRTC and file transfer systems
- More robust initialization sequence with proper cleanup
- Improved message routing and processing pipeline

- Fixed duplicate system notifications
- Resolved file transfer message leakage into chat
- Improved connection state management
- Better handling of initialization race conditions
2025-08-20 18:19:42 -04:00
lockbitchat
fe611f7630 Refactored file encryption/decryption logic for P2P transfers
- Reworked the core logic for encrypting and decrypting files exchanged between users
- Improved key derivation and session handling for file chunks
- Enhanced integrity checks to prevent tampering and replay attacks
- Work in progress: adding hardened encryption schemes and conducting fault-tolerance testing
2025-08-18 23:56:10 -04:00
lockbitchat
dadc80a755 wip(encryption): experimental support for encrypted file transfer via chunks
Added an early implementation of secure file transfer using chunk-based encryption.
Files are split into encrypted chunks and transmitted over the chat channel.

This feature is still under active development and requires further changes and testing.
2025-08-18 21:45:50 -04:00
lockbitchat
857d7d74ab Encryption module control system & session timer improvements
- Added a real verification system for active encryption modules, giving users full control over enabled modules.
- During session purchase or activation, the actual enabled modules are now displayed for both free and paid sessions.
- Refactored session timer initialization for proper functionality and accurate countdown.
- Optimized code structure related to session management and module verification.
2025-08-17 20:38:47 -04:00
lockbitchat
adb1844392 Update session pricing and demo mode
- Updated demo mode: now includes basic protection features, still stronger than many competing messengers.
- Adjusted pricing for Basic and Premium sessions to better reflect security levels.
- Added restrictions to Basic session and enhanced Premium session to deliver maximum protection.
2025-08-17 02:22:55 -04:00
lockbitchat
12de75f882 Technical comments removed 2025-08-16 21:15:03 -04:00