12 Commits

Author SHA1 Message Date
UNITRONIX 47f4aa680c fix(docker): share console auth.db with Go for panel folder sync (#138)
Mount console-data read-only into the server container and set AUTH_DB_PATH
so RustDesk clients receive panel folders/groups in SQLite deployments.
Wait for auth.db on first boot and start console before Go in single-container
layouts to avoid empty /api/device-group/accessible responses.

Refs #138
2026-06-06 13:58:44 +02:00
UNITRONIX 923602d679 feat(enrollment): operator approval queue for stock RustDesk clients
Add a device verification/enrollment workflow so new registrations are
held for operator review instead of connecting silently.

Go server (signal + api):
- Signal-mode pending: in 'managed' mode, unknown stock RustDesk clients
  are queued (pending_device_<id>) instead of being silently rejected.
- Rich approve: handleApproveDevice accepts display_name, sync_mode and
  normalized tags; handleRejectDevice supports an optional ban.

Node.js console:
- registrations.ejs approve modal (name, sync mode, tags, folder) and
  reject modal with ban option; betterdeskApi + routes wire display_name,
  sync_mode, tags and folder assignment through to the Go server.
- EN/PL/ZH i18n for all new strings.

Installers (managed default for FRESH installs only; existing installs
stay on the Go default 'open' or their DB-persisted mode):
- betterdesk.sh / betterdesk.ps1 write ENROLLMENT_MODE=managed to the
  server env only when no existing database is detected (FRESH_INSTALL).
- Docker single + multi container entrypoints detect fresh volumes via a
  sentinel plus id_ed25519/db_v2.sqlite3 presence and default to managed;
  ENROLLMENT_MODE is now passed through supervisord and all compose files.

This commit was made possible thanks to Insolve.
2026-05-31 01:10:38 +02:00
UNITRONIX 0f161181f1 feat(installers): run services under unprivileged accounts by default
Privilege separation across all installers so the long-running services no longer run with full administrative rights:

betterdesk.sh: installer keeps root but systemd units now run as a dedicated unprivileged 'betterdesk' system account by default (auto-created via ensure_service_user). Added full systemd hardening for the Go server (NoNewPrivileges, ProtectSystem=strict, ProtectHome, PrivateTmp, ReadWritePaths) and light hardening for the Node.js console. chown migrates existing root-owned data to the service account on update. Opt-out via --run-as-root / BETTERDESK_RUN_AS_ROOT=1; custom account via BETTERDESK_SERVICE_USER. Minimal mode covered too.

betterdesk.ps1: NSSM services now run under their per-service low-privilege virtual accounts (NT SERVICE\<service>) instead of LocalSystem, with scoped icacls grants on the install/data dirs (Set-ServiceLeastPrivilege helper). Applied to the Go server, Node.js console and minimal-mode service. Opt-out via -RunAsRoot / BETTERDESK_RUN_AS_ROOT=1.

Docker: verified already privilege-separated (supervisord drops both programs to user=betterdesk; multi-container images drop via su-exec).

Also bundles in-progress changes to the Go server API, Node.js console services and Docker compose/Dockerfiles.

This commit was made possible thanks to Insolve.
2026-05-31 00:35:28 +02:00
UNITRONIX 97d228545f fix(docker): restore SETUID/SETGID/CHOWN/FOWNER caps for su-exec (#153)
cap_drop: ALL removed capabilities needed by su-exec to drop from root to betterdesk user. The entrypoint scripts chown volumes then su-exec to UID 10001, which calls setgroups() — requires SETGID. Added cap_add with the 4 minimal capabilities across all 3 compose files.

This commit was made possible thanks to Insolve.
2026-05-28 01:08:43 +02:00
Knienartowicz f8fbb88e47 security: apply 12 audit fixes (H-03/H-04/M-03/M-04/M-05/M-06/M-07/L-01/L-02/L-04/I-02/I-04)
Node.js (no recompile required):

- H-04: RUSTDESK_API_DISABLE_TOTP now requires explicit _ACKNOWLEDGED flag

- M-03: drop Referer-based skip from apiLimiter; add dedicated widgetLimiter

- M-06: gate /api/system/info, /logs/recent, /database/stats, /docker/containers, /speed-test behind requirePermission('metrics.view')

- L-01: startup banner now warns when TRUST_PROXY is off in production / errors when TOTP bypass is set without acknowledgement

Scripts / Docker:

- M-04: betterdesk.sh migration tool invocation switched from eval(cmd-string) to bash array exec

- M-05: all admin / PostgreSQL password generators switched from openssl rand -base64+tr+head to openssl rand -hex 16 (full entropy)

- L-02: docker-compose.yml / single.yml / quick.yml services gain security_opt: no-new-privileges and cap_drop: ALL

Documentation:

- I-04: add SECURITY.md (supported versions, reporting channels, SLA, scope, hardening defaults)

Go server (requires rebuild on host: cd betterdesk-server && go build ./...):

- H-03: /metrics now gated by METRICS_IP_ALLOWLIST / METRICS_PUBLIC; per-username login + 2FA rate-limit added on top of per-IP

- M-07: enrollment (/api/devices/register*) and branding (GET /api/branding) endpoints rate-limited per IP

- I-02: bd-mgmt WebSocket gets SetReadLimit(16 MiB) to bound memory

- L-04: auth middleware skips noisy public probes and redacts /peers/{id} segments

This commit was made possible thanks to Insolve.
2026-05-26 13:58:16 +02:00
UNITRONIX e19703dd25 fix: implement signal registration rate limiting per IP 2026-05-15 00:30:15 +02:00
UNITRONIX 1e2047c033 BetterDesk 3.0.0 Alpha 2026-03-24 00:26:25 +01:00
UNITRONIX 60657da980 Add Address Book API, relay env & UI fixes
Implement address book support and related fixes: add address_books table and Get/SaveAddressBook to DB interface with SQLite/Postgres migrations and upsert, add handlers for /api/ab, /api/ab/personal and /api/ab/tags (GET/POST) and normalize/limit incoming data. Signal server: generate relay UUIDs, send RelayResponse (with UUID and signed PK) and forward RequestRelay to targets to ensure hbbr pairing. Docker/compose/supervisord/entrypoint: introduce RELAY_SERVERS env, expose it in Dockerfile and supervisord, add docker-compose hint, and add entrypoint auto-detection/warnings for public IP inside containers. Web UI fixes: align settings password field names and include confirmPassword, modal input supports inputType, fix change-id request body key, add i18n strings for device actions/errors, and improve device delete route error handling. Also update changelog (.github/copilot-instructions.md) and add some API logging and validations.
2026-03-16 22:30:44 +01:00
UNITRONIX 5b4408a190 Harden API/installer security & opt-in creds
Security hardening and installer fixes across the Go API, installers and Node console.

Key changes:
- WebSocket: removed InsecureSkipVerify and added API_WS_ALLOWED_ORIGINS allowlist (parsed in config) used by the API events WS endpoint.
- Node.js console: added HOST and API_HOST envs and used apiHost in the server; docker-compose and installer templates updated accordingly.
- Admin credentials: plaintext .admin_credentials persistence is now opt-in via STORE_ADMIN_CREDENTIALS (default false); installers and reset flows no longer persist creds unless explicitly enabled.
- Installer hardening: added sql_escape_literal for safe SQL literals, PostgreSQL identifier validation, and safer CREATE/ALTER/psql invocations; API key and password updates now pass secrets via environment variables to Python/Node fallbacks to avoid unsafe shell interpolation.
- Docker compose/scripts: preserve_compose_database_config to keep DB mode during regen, escaped API key insertion into sqlite, and various compose generation formatting fixes.
- Go toolchain & checks: go.mod toolchain set to go1.26.1 and installers now reject known-vulnerable Go 1.26.0 stdlib.
- Dependency: bumped web-nodejs tar override to ^7.5.11.

These changes reduce attack surface for cross-origin WS usage, eliminate unsafe credential persistence by default, and harden installer DB operations and password reset paths.
2026-03-15 14:53:55 +01:00
UNITRONIX fc943e808d Streamline Docker builds, add .dockerignore
Add .dockerignore to trim Docker build context and exclude local artifacts (node_modules, dev files, secrets, runtime DBs, etc.). Simplify Dockerfiles: remove unnecessary sqlite-dev and rely on better-sqlite3's bundled SQLite; use npm install --production in build stages; copy application files first then overlay compiled node_modules from the builder to avoid local node_modules clobbering Alpine-compiled native modules. Update Docker console image similarly. Change supervisord to log to /dev/stdout and /dev/stderr so logs appear in docker logs. Remove explicit compose 'version' keys. Also set SQLite busy_timeout for main and auth DBs to reduce locking errors during concurrent access.
2026-03-14 23:05:02 +01:00
UNITRONIX 82475de81d Disable CGO, use DB_URL env for DB config
Switch Go builds to CGO_ENABLED=0 and remove system SQLite build deps and static extldflags (modernc.org/sqlite is pure-Go). Remove hardcoded -db flags from server CMD/supervisord and introduce a DB_URL environment variable propagated from entrypoint.sh. entrypoint.sh now sets DB_URL based on DB_TYPE/DATABASE_URL (Postgres or SQLite) and prints the chosen DB, and supervisord is updated to inject DB_URL into the server process. docker-compose files and docs updated to default to SQLite, expose DB_TYPE/DB_URL configuration, and document using a .env or postgres profile for PostgreSQL setups.
2026-03-14 18:45:31 +01:00
UNITRONIX 0496b1dbc4 Add client API, sysinfo endpoints and Docker
Add RustDesk-compatible client API and telemetry support and introduce a single-container Docker build. New client_api_handlers.go implements /api/login, /api/login-options, /api/logout, /api/currentUser, /api/ab, /api/heartbeat, /api/sysinfo and /api/sysinfo_ver with TOTP flow and an in-memory TFA session store; auth middleware and Server registration updated accordingly. Database interface and SQLite/Postgres implementations gain UpdatePeerSysinfo (with tests), audit actions for sysinfo, and handleGetPeer now returns live_online/live_status. Also add Dockerfile, docker-compose.single.yml, supervisord entrypoint, UI fixes (QR color inversion, 403 error view), labels file, README updates, and other ancillary changes.

Co-Authored-By: MrBrodacz - Design <215021251+MrBrodacz2025@users.noreply.github.com>
Co-Authored-By: boruto79 <176351662+boruto79@users.noreply.github.com>
Co-Authored-By: marcosacramento <marcosacramento@gmail.com>
Co-Authored-By: Charles Olivier Savignac <1275666+sircharlo@users.noreply.github.com>
2026-03-06 01:08:10 +01:00