rustdesk / rustdesk-server

RustDesk Server Program
https://rustdesk.com/server
GNU Affero General Public License v3.0
6.46k stars 1.35k forks source link

Despite -k _ option, connection without key still possible #123

Open rucksman opened 1 year ago

rucksman commented 1 year ago

I am testing rustdesk and use the docker images. For both containers (hbbs and hbbr) I enabled the "-k _" option like so:

command: hbbs -r my.domain.com:21117 -k _
command: hbbr -k _

Then I downloaded the portable Windows client and started it. I changed the "ID Server", and without entering the key the green status lights up, connection is obviously made. What am I doing wrong here? Or do I misinterpret the "-k _" option?

xVlmRx commented 1 year ago

Hello I have a similar problem

I tried to prescribe in docker-compose.yml for services

command: hbbs -r <my_domain>:21117 -k _
command: hbbr -k _

Similarly, I raised the s6 container and prescribed -"ENCRYPTED_ONLY=1"

After that, for verification, either did not specify or specified the wrong public key in the client settings. Anyway, the client connected to the server and then also successfully established a connection to the managed machine.

christiantakle commented 1 year ago

Same @xVlmRx using the docker-compose example using the example from the docs.

(cannot link so inlining)

version: '3'

services:
  rustdesk-server:
    container_name: rustdesk-server
    ports:
      - 21115:21115
      - 21116:21116
      - 21116:21116/udp
      - 21117:21117
      - 21118:21118
      - 21119:21119
    image: rustdesk/rustdesk-server-s6:latest
    environment:
      - "RELAY=rustdesk.example.com:21117"
      - "ENCRYPTED_ONLY=1"
      - "DB_URL=/db/db_v2.sqlite3"
    volumes:
      - ./db:/db
    restart: unless-stopped
    secrets:
      - key_pub
      - key_priv

secrets:
  key_pub:
    file: secrets/id_ed25519.pub
  key_priv:
    file: secrets/id_ed25519     
paspo commented 1 year ago

I just finished trying to reproduce this issue:

You have different results, so clearly there's something different between your setup and mine.

paspo commented 1 year ago

Just to establish some common ground: you have to start a connection between two peers to check if the key is valid, the "ready" state in the bottom of the client windows is indicating only the connection to a server (AKA your client saying hello to the server) not the server validating your key.

christiantakle commented 1 year ago

So the difference is a local-network only vs different networks and is that expected?

update: changed RELAY in the docker-compose file to use explicit the ip + docker compose --file containers/rustdesk/docker-compose.yml up --detach --force-recreate for completeness. The result is the same.

paspo commented 1 year ago

I don't have a raspberry PI 4, so the tests can't be 100% representative. Here's what I did this time:

It turns out I said something wrong in my previous reply, let me fix that:

Honestly I never tough of testing this behavior, I always supposed the key was needed both sides. @rustdesk any comment on that? Is that by design?

This behavior is true for both x86-64 and armv7.

robotex82 commented 1 year ago

We are experiencing the same problem using the latest docker image on synology. Is there any progress regarding this issue?

lonix1 commented 1 year ago

Same problem here. I tried the s6 docker image with ENCRYPTED_ONLY=1, and the normal docker image with -k _.

glitch452 commented 11 months ago

@paspo Re:

  • for the connection to work, we need the correct server and key on the "requesting" side and the correct server on the "target" side. So you need the key only when starting a connection.

The documentation would seem to indicate that this is by design, although it's not necessarily worded in the clearest way 🤔:

... If you want to prohibit users without the key from establishing non-encrypted connections, please add the -k _ parameter when running hbbs and hbbr ...

But I've also run into situations where I wasn't able to establish a connection unless both clients had the key.

RR-T commented 8 months ago

I seem to have the same issue as posted above, my docker-compose looks like the following:

version: '3'

services:
  rustdesk-server:
    container_name: rustdesk-server
    image: rustdesk/rustdesk-server:latest
    environment:
      - "ENCRYPTED_ONLY=1"
    command: hbbs -r rustdesk.domain.xyz:21117
    volumes:
      - /media/data-ssd/rustdesk/data:/root
    depends_on:
      - rustdesk-relay
    ports:
      - "21115:21115"
      - "21116:21116"
      - "21116:21116/udp"
      - "21118:21118"
    networks:
      rustdesknet:

  rustdesk-relay:
    container_name: rustdesk-relay
    image: rustdesk/rustdesk-server:latest
    environment:
      - "ENCRYPTED_ONLY=1"
    command: hbbr
    volumes:
      - /media/data-ssd/rustdesk/data:/root
    ports:
      - "21117:21117"
      - "21119:21119"
    networks:
        rustdesknet:

networks:
  rustdesknet:

However I am able to initiate a connection without a key on either side, and of course get the following: image

Kurgan- commented 7 months ago

Yes, i have the same issue.

Setting the environment variable "ENCRYPTED_ONLY=1" does absolutely nothing.

If I specify -k "my private key" (where the key is the text extracted from the file id_ed25519) for both hbbs and hbbr, then it actually refuses connections with the wrong key.

(I'm running hbbs and hbbr not in docker but as normal executables on my server)

It seems security is not a a priority in Rustdesk.

paspo commented 7 months ago

environment:

  • "ENCRYPTED_ONLY=1"

This option is valid only in the rustdesk/rustdesk-server-s6 docker image. If you set this to "1", the -k _ parameter will be added to the command line. See https://github.com/rustdesk/rustdesk-server/blob/79f0eb497b4adaaadb51f6ba3a58978846fa5318/docker/rootfs/etc/s6-overlay/s6-rc.d/hbbs/run#L5

It has no effect on the binary itself or on the classic docker image (which only contains the binaries).

Kurgan- commented 7 months ago

Thanks for the clarification. I believe this should be the default behaviour anyway, since it's more secure.