Security hardening: TLS, HMAC auth, rate limiting, privacy fixes#6
Open
leetcrypt wants to merge 5 commits into
Open
Security hardening: TLS, HMAC auth, rate limiting, privacy fixes#6leetcrypt wants to merge 5 commits into
leetcrypt wants to merge 5 commits into
Conversation
…rate limiting, IP leak prevention CRITICAL fixes: - Auto-generated self-signed TLS certs (HTTPS/WSS by default) - Removed session_key from /srp/verify response (was sent in plaintext) - Replaced with HMAC-SHA256 ws_token for WebSocket authentication HIGH fixes: - WebSocket auth now validates ws_token via hmac.compare_digest() - /clear endpoint requires Bearer admin_token (printed at server start) - Password no longer required as CLI arg — supports env var + getpass prompt - Removed user_ip from Message model (no longer broadcast to clients) MEDIUM fixes: - Rate limiter on /srp/init and /srp/verify (10 req/min/IP) - MessageStore capped at 1000 messages (prevents RAM DoS) - access_log disabled (was leaking request metadata) LOW fixes: - Username sanitization against rich markup injection - Dead code removed from helpers.py All 79 tests passing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ncoding - lab/setup-lab.sh: automated tmux setup with server + 2 chat clients Supports --no-tls, --password, --port, --user1/--user2, --teardown Auto-installs missing pip dependencies, verifies port availability, waits for server health before connecting clients - lab/README.md: usage docs and keyboard shortcuts - requirements.txt: fixed UTF-16 encoding to UTF-8, cleaned pinned versions Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…tions Detects all available IPs (Tailscale, LAN, public), prints connect command for friends to copy, prompts for password securely via getpass. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
New commands: /send <filepath>, /accept, /reject Protocol: - Sender proposes file (name, size, SHA-256 hash) - Recipient sees offer and chooses /accept or /reject - On accept: file chunked (64KB), encrypted with room key, sent over WebSocket - On receive: chunks reassembled, SHA-256 verified, saved to ./downloads/ - Server never sees file content (E2E encrypted, same as messages) Limits: 50MB max file size. Files saved with collision-safe naming. No server changes — server remains a dumb encrypted relay. All 79 existing tests pass. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… guide Clear, concise documentation covering installation, hosting, connection security (Tailscale/LAN/public), password sharing, file transfer protocol, CLI reference, helper scripts, and architecture overview. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Security hardening + encrypted file transfer for cmd-chat. All changes maintain the SRP + Fernet architecture. Zero new dependencies.
Security Fixes
~/.cmd-chat/certs//srp/verifyresponsews_tokenverified withhmac.compare_digest()/clear— requires Bearer token (printed at server start)getpassinstead of CLI arguser_ipdeleted from Message modelEncrypted File Transfer
New commands:
/send <filepath>,/accept,/reject./downloads/with collision-safe namingLab Environment
lab/setup-lab.sh— one-command tmux lab with server + 2 chat clients.Setup
git clone https://github.com/diorwave/cmd-chat.git cd cmd-chat pip install -r requirements.txtHosting
Connecting
--insecureskips cert verification for self-signed certs.Securing the Connection
Tailscale (recommended): Both install Tailscale. Use Tailscale IP (
tailscale ip -4). Encrypted WireGuard tunnel, zero port forwarding, works across NATs.LAN: Use local IP. No port forwarding. Both devices must be on same network.
Public internet: Requires router port forwarding (TCP 3000). Use real TLS certs via
--cert/--keyif exposing to internet.Sharing the Password
Share out-of-band (never through the chat):
CLI Flags
--password,-p--cert--key--no-tls--insecure,-kChat Commands
/send <filepath>/accept/rejectqTest Plan
/clearrequires admin Bearer token