Repository navigation
Conversation
Version 2 is a rewrite with a new wire protocol, so the 1.x files go away. Node.js 22.18+ runs the TypeScript sources directly; tsc only type-checks. - chalk is replaced by util.styleText (respects NO_COLOR and non-TTY output) - clipboardy 4 -> 5.3.2: native Wayland support (wl-clipboard) - bonjour-service for mDNS discovery; typescript 7 and @types/node 22 for checks - package-lock.json had a stale "ISC" license; regenerated Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Framing: u32 length | u8 type | body, decoded from a byte stream with a size check before buffering. 1.x split messages on a "NetP" marker and assumed that every TCP read starts with a whole fragment: texts larger than one segment arrived corrupted, and 4 bytes crashed the process. Handshake: ephemeral X25519 + scrypt(passphrase, per-connection salt) + HKDF-SHA256. The client proves the passphrase first; the server proves it back. A passive eavesdropper cannot test guesses, a stranger receives nothing. Wrong passphrase: delayed ERROR, so online guessing is slow. Messages: AES-256-GCM with per-direction keys and counter nonces, the frame header as AAD. Changed, replayed, reordered or reflected messages fail. 1.x used AES-CTR without a MAC, so text could be changed or forged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Text is passed through unchanged; 1.x trimmed indentation and final newlines. - Echo suppression by content instead of a 2-second flag. 1.x lost copies made within 2 s of a received one, echoed copies made about 2 s apart, and a single failed write blocked all later copies. - One sequential poll loop; a read that overlaps a network write is dropped. - After a failed first read, the first successful read is the baseline, so old clipboard content is not sent just because netpaste started. - A failed write resynchronizes instead of sending the old text out as new. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Passphrase input in 1.x stored Backspace as \x7f and arrow keys as the text "undefined", so a corrected typo silently gave the machines different passphrases. It also never finished when stdin was a pipe. - Raw-mode line editor: Backspace, Ctrl+U, escape sequences (also split across reads), bracketed paste, Ctrl+C / Ctrl+D. - --passphrase-file (warns about group/world-readable files) and NETPASTE_PASSPHRASE (removed from the environment of child processes). - util.parseArgs with strict validation: no silent fallback to port 8134, flags in any order, per-command options, sizes like 10mb. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The hub announces _netpaste._tcp; "netpaste connect" without HOST finds it. Two problems of bonjour-service are worked around: - It announces A/AAAA records for os.hostname(). On macOS that is the name that mDNSResponder owns, so macOS renames the computer (Name-2.local). We announce a unique SRV target, netpaste-<name>-<random>.local. - It does not listen for 'error' on its multicast socket, so a busy UDP port would crash the process. We report it as a warning instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- netpaste serve | connect [HOST[:PORT]] | discover - The hub relays text from one client to all others (1.x did not); --no-clipboard turns it into a pure relay. - The client reconnects with exponential backoff and jitter. 1.x crashed on its first reconnect: setTimeout(createConnection) passed no arguments. - PING/PONG heartbeats, idle timeout and TCP keepalive detect dead peers after sleep or a network change. - One clipboard poller per process, active only while a peer is connected. 1.x started a new poller per connection and never stopped it. - After a wrong passphrase the hub blocks the address, 1 s doubling to 60 s. - Clear errors and exit codes: wrong passphrase, busy port, old protocol, no TTY. - bin/netpaste.js checks the Node.js version before it loads TypeScript. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- README: install, usage, passphrase sources, firewall, autostart, security limits, upgrade notes from 1.x. - docs/PROTOCOL.md: framing, handshake, key schedule, messages, threat model. - CHANGELOG.md: every 1.x problem that 2.0 fixes. - launchd LaunchAgent and systemd user service templates. - GitHub Actions: typecheck and tests on Linux and macOS, Node.js 22/24/26. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Security and robustness: - Unread input is bounded: FrameReader pauses the socket when more than one maximum-size frame + 64 KiB waits unread. Before, a stranger could make the hub buffer 600 MB while it ran scrypt. - The hub runs scrypt only after the client proof arrives, so a HELLO alone costs it nothing; a connection dropped during scrypt gets no answer. - Connections without the passphrase are limited (4 per address, 32 total), separately from authenticated peers (32). IPv6 addresses count per /64. - A wrong passphrase blocks the address at once (the block counts from the delayed reply) and closes its other pending connections: at most 2 guesses per block period instead of 32. - ERROR frames are not authenticated: "wrong passphrase" counts only after our own proof, and it stops the client only for an explicitly given hub. For a hub found with mDNS (or several of them) the client keeps trying. Correctness: - Client.close() during mDNS discovery stopped nothing; the search is now abortable and the client checks the signal before it connects. - The idle timeout counts every received chunk, so a large text on a slow link is not cut; heartbeats use a monotonic clock and are checked every 5 s. - The hub sends no text to a peer before its INFO (unknown limit), nor to a peer that does not read (bounded send queue). - Clipboard watcher: after a failed write, the next read becomes the baseline instead of a concurrent re-read (no echo, no old text sent out). - Passphrase prompt: a stray ESC no longer swallows Enter or Ctrl+C; TAB is kept; NETPASTE_PASSPHRASE is removed even when --passphrase-file wins. - CLI: host names are validated; --host with a specific address turns the mDNS announcement off; --max-size is capped at 64 MiB (clipboardy reads through a 100 MB buffer); the Node.js check also rejects 23.0-23.5. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <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.
A rewrite of netpaste. A review of 1.x found more than 25 problems, several of them critical; this PR fixes all of them. The wire protocol changes, so all machines must be updated.
Critical problems in 1.x (all reproduced)
printf NetP | nc host 8134).setTimeout(createConnection)passed no arguments.\x7f, arrow keys as the textundefined.The full list is in
CHANGELOG.md.What 2.0 does
u32 length | u8 type | body, decoded from a byte stream, size checked before buffering, unread input bounded by TCP flow control.--no-clipboard= relay), reconnect with backoff, heartbeats, idle timeout.trim(), echo suppression by content instead of a 2-second window, one poller that runs only while a peer is connected.netpaste serve | connect [HOST[:PORT]] | discover; mDNS discovery; passphrase from a prompt,--passphrase-fileorNETPASTE_PASSPHRASE; launchd and systemd templates.chalkreplaced byutil.styleText; clipboardy 5 (Wayland).The design and threat model are in
docs/PROTOCOL.md, including the known limits: offline guessing by an active attacker who poses as the hub (use a long passphrase), and crossing copies made within ~1 s on two machines.Testing
node:test):🤖 Generated with Claude Code