rustdesk / rustdesk/rustdesk-server

hbbs server generates random key when no key is specified, making it impossible for clients to connect

Open
#595 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
10.4k
Forks
2.6k
PR merge metrics
No merged PRs in 30d

Description

Description

I've discovered what appears to be a logic issue in the hbbs (RustDesk ID/Rendezvous Server) implementation that makes it impossible for clients to connect when the server is started without an explicit key.

The Problem

When analyzing the code, I found the following behavior:

  1. In src/main.rs, if no -k (key) argument is provided, the server defaults to "-":
RendezvousServer::start(port, serial, &get_arg_or("key", "-".to_owned()), rmem)?;
  1. In src/rendezvous_server.rs, the get_server_sk function treats "-" as a special value and generates a new random key pair:
if key.is_empty() || key == "-" || key == "_" {
    let (pk, sk) = crate::common::gen_sk(0);
    out_sk = sk;
    if !key.is_empty() {  // Since key is "-", this is true
        key = pk;  // Replaces "-" with newly generated public key
    }
}
  1. Later in handle_punch_hole_request, the server checks if the client's key matches:
if !key.is_empty() && ph.licence_key != key {
    // Returns LICENSE_MISMATCH error
}

The Issue

This creates a situation where:

  • If you start the server without specifying a key, it generates a random key
  • Clients have no way to know this randomly generated key
  • All client connections fail with LICENSE_MISMATCH

The only way to disable key checking would be to have an empty key string, but that's impossible because:

  • Empty input → replaced with "-" in main.rs
  • "-" → generates new random key
  • Random key is never empty → key checking is always enabled

Question

Is this the intended behavior? If so, how are self-hosted servers supposed to work when no key is specified?

It seems like either:

  1. The server should not generate a random key when "-" is provided (just keep it as "-" or empty)
  2. Or there should be a way to truly disable key checking
  3. Or the generated key should be communicated to clients somehow

Am I misunderstanding the intended logic here? How is this supposed to work for self-hosted deployments?

Environment

  • RustDesk Server (hbbs)
  • Self-hosted deployment

Thank you for clarifying this behavior!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/main.rs and trace the default key value into src/rendezvous_server.rs, especially get_server_sk and handle_punch_hole_request. Confirm the intended no-key behavior and how the generated or empty key reaches client validation. Done means the no-key path has an explicit, testable behavior that does not leave clients unable to connect.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
authentication, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.