A server past its hello budget dropped the hello, so a flood of forged
hellos kept every new socket from its welcome until it fell back to
plaintext. The server now answers such a hello with a cookie, a MAC of
the client's address, and takes the same hello again with the cookie
attached, which proves the address can receive: WireGuard's cookie reply
under load and QUIC's Retry (RFC 9000 8.1.2). The reply echoes part of
the hello's enc, so only one who saw the hello can forge it, and it is
shorter than any hello. The client keeps the cookie for two minutes and
attaches it to its hellos; the cookie is bound to the address, not the
socket, as QUIC's tokens are, so a one-off socket may carry it too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8
The welcome now carries a fresh server ephemeral, and the DH of it with
the hello's ephemeral is mixed into the welcome key (Noise NK's
`<- e, ee`, folded in with Noise's MixKey). A server key taken later
redoes a recorded hello's HPKE but opens neither the welcome nor the
session it hands out. The hello itself stays readable to that key, as
WireGuard's first message does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8
A server that waits to see a new session used before pushing under it
(key confirmation, as WireGuard's next_keypair) keeps pushing under the
old one after its welcome has gone out. The client now keeps that old
session for receiving until a datagram opens under the new one, the way
QUIC keeps old read keys for a while after a key update (RFC 9001 §6).
Sending always uses the newest session.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8
The module doc already pointed at HPKE, Oblivious HTTP and PSP. It now
also names what the packet numbers, the replay window, the first-byte
split and the subkey PRF follow, and the analysis of using the server's
signing key for X25519 as well. Comments only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8
The server charges its hello budget for every hello, so a 5-byte header
spent it as well as a real one. A hello is at least an unsigned one with
no payload, 54 bytes; anything shorter is now neither counted nor opened.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8
Pushes take their packet numbers from one counter for the whole server,
so on a server with a hundred thousand devices the 64 numbers below the
highest seen cover about ten milliseconds, and a push the network
delays by more is dropped as a replay. A 1024-bit ring covers about
150 ms at that rate, for 120 more bytes per window.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8
A client that re-signs its session dropped it first, so until the new
welcome came back pushes under the old key could not open and a
plaintext push was taken even from a server that seals every push.
ClientSeal::hello builds a hello without touching the session; the
welcome replaces it as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8
A device whose key pair changes at runtime re-registers its new public key;
its later hellos must be signed by the new secret key, or the server can
never tie a seal to the device again.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8
One sealed datagram per message and no handshake: an RFC 9180 HPKE single
shot to the server's signing key converted to X25519, signed by the device
key the server has on record, answered by a welcome sealed under an exported
key and a fresh nonce (RFC 9458) that hands over a session key the server
re-derives from a process secret and the key id. Data carries the key id
and a packet number under per-direction subkeys, with a replay window.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkpVy2ufxgEjKd3SjXPnJ8
websocket_port() took the rendezvous host from get_rendezvous_server(),
which falls back to a cached or public server when none is set. With
only relay-server and websocket-port set, the public rendezvous server
also got the port, and registration failed. Match the servers this
client is set up with instead: the exe-name host, custom-rendezvous-server,
the build-time server, and relay-server.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
check_ws runs on every rendezvous reconnect, online query and relay
connect, so an invalid websocket-port logged a warning each time.
Keep one line a minute with a count of the rest. Also import the key
with the other config keys instead of in the function body.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
check_ws turns a domain endpoint into ws(s)://<domain>/ws/id or
/ws/relay with no port, so a reverse proxy that cannot take 443 (or 80)
is unreachable, even when api-server already points at it, for example
https://example.com:8443.
websocket-port adds that port for the hosts this client is configured
with: custom-rendezvous-server and relay-server. A relay that hbbs hands
out on another host, or a peer's server, keeps the default port, since
another machine has its own proxy. IP endpoints are unchanged, and an
empty option gives the same URL as before.
https://github.com/rustdesk/rustdesk-server-pro/discussions/1029
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The V2 management UI no longer displays legacy enrollment metadata. Remove the unused presence helper while preserving legacy records during ordinary saves.
Signed-off-by: fufesou <linlong1266@gmail.com>
Retain legacy trusted-device records for migration without using them for authentication. Preserve malformed V2 values for strict validation while allowing explicit revocation to replace them.
Signed-off-by: fufesou <linlong1266@gmail.com>
Stop ordinary Config2 and peer settings saves when the current file cannot be read. Keep first-save behavior for missing files and log failures without replacing V2 records with defaults.
Signed-off-by: fufesou <linlong1266@gmail.com>
Add fallible grant persistence with file locking and atomic replacement. Preserve the persisted grant state during ordinary settings writes so stale configuration snapshots cannot restore revoked devices.
Signed-off-by: fufesou <linlong1266@gmail.com>
Support WS and WSS over SOCKS5, HTTP, and HTTPS proxies, including custom
ports. Use the configured proxy only when allow-websocket-proxy is enabled;
explicit proxy configuration takes precedence. Propagate proxy failures
without retrying a direct connection.
Add regression coverage for proxy routing, authentication, TLS, custom
ports, direct defaults, and failure handling.
Signed-off-by: 21pages <sunboeasy@gmail.com>
fix: flush WebSocket proxy tunnels before native TLS reads
Flush buffered HTTP and HTTPS tunnel writes before NativeTls reads so WSS handshakes can complete on macOS. Apply the adapter only to NativeTls WebSocket connections through HTTP or HTTPS proxies.
Extend the existing proxy round-trip test with HTTPS and SOCKS5 NativeTls cases. The websocket_proxy integration test passes in the rustdesk workspace.
Signed-off-by: 21pages <sunboeasy@gmail.com>
refactor: simplify WebSocket proxy configuration
Select the configured proxy inside WsFramedStream::new based on the WebSocket proxy option and remove the explicit proxy argument. Update the socket client and drop the unused Stream::connect_websocket wrapper.
Adapt integration tests to configured proxies and cover custom target ports and WebSocket close handling.
USB forwarding now runs inside a normal remote desktop session
(rustdesk/rustdesk#16278), so it needs no connection type of its own. Only
ControlPermissions.Permission.usb remains.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: AzimovIz <sergo.p.987@gmail.com>
Adds ConnType::REMOTE_USB for the RemoteUsb feature (rustdesk/rustdesk#16278),
following the same pattern as TERMINAL, and ControlPermissions.Permission.usb
so USB forwarding can be controlled centrally like the other permissions.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: AzimovIz <sergo.p.987@gmail.com>
src/webrtc.rs calls fork-only APIs (set_ice_max_binding_requests,
set_no_congestion_control), which only rustdesk's root [patch] supplied,
so building this crate on its own with --features webrtc failed with
E0425/E0599. Mirror the root patch here; it applies only when this crate
is the root.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019aokqJuhjvB3kijXtAg5Ns
With advertised and picked both 1, swapping their order in the
derivation leaves the vector unchanged. Advertised 3 with picked 1 is
what a client meets at a newer server, and tells the two apart.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019aokqJuhjvB3kijXtAg5Ns
The existing tests run both ends on the same code, so they pass even
if the derivation changes. Fixed bytes catch that: the version 0 frame
released peers send, and the same subkey vector hbbs's copy of this
code pins.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019aokqJuhjvB3kijXtAg5Ns
Version 1 is matched explicitly and any other picked version is an
error, so adding a version without its arm here fails instead of
running as version 1. WebRTC takes only version 0, as both handshakes
already require.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019aokqJuhjvB3kijXtAg5Ns
Every handshake picked a version and then repeated the same choice: at
least 1 splits the key, 0 sets it as before. Stream now makes that choice
from the transcript it is already given, so callers make one call and a
later version is handled here rather than at each of them. Version 0
still goes through set_key.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019aokqJuhjvB3kijXtAg5Ns