Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,111 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

---

## [0.75.1] — 2026-11-21 · *Spanner*

**Admin → Security: hbbs's UDP socket is no longer an "unexpected public listener", the SSH ordering rule is
proven against the host that prompted it, and a Platform Admin can accept a finding as a deliberate risk — which
re-opens on its own when the evidence changes.** Two fixes to 0.74.0's posture page (docs/server-security.md;
check-security-invariants §84, extended). No agent, signer or sudoers change.

### Fixed — a false positive on the production page

- **`udp/33344` reported as an unexpected public listener.** `ss -tulpn` as root showed it was `hbbs`, UNCONN on
`*:33344`: the RustDesk server's own outbound socket, bound without naming a port, so the kernel picked one from
its ephemeral range (`/proc/sys/net/ipv4/ip_local_port_range`, 32768–60999 on this host). A service names its
port; the kernel never hands out one below the range. So an **unconnected UDP socket on a port inside the range**
is now an *ephemeral client socket*: listed on its own information line (`network.ephemeral_sockets`), not a
finding. TCP listeners are judged as before whatever their port, and so is UDP outside the range. If the range
cannot be read nothing is excused, and the listener finding says so. The port number changes when hbbs restarts,
which is why an allow-list entry would not have worked.
- **`ss` now runs as `ss -Htlnup`** (still as `reboot`, no sudo), so a socket owned by the service user's own
processes is named (`tcp/8080 on 0.0.0.0 (node)`). Root's sockets — hbbs's included — show no owner to `reboot`,
and nothing asks for root to find out.

### Checked — SSH's first-match-wins order (no behaviour change)

The owner set `PermitRootLogin no` in `/etc/ssh/sshd_config.d/40-rem0te.conf` and asked why the finding might
still read Unknown. The 0.74 parser already did the right thing — it was run against this host's real files and
reported `permitrootlogin no` from `40-rem0te.conf`, **certain** — because sshd reads `sshd_config` from the top
(its `Include` is line 12) and the drop-ins in lexical order, and keeps the first value: `40-rem0te.conf` comes
before the root-only `50-cloud-init.conf`, so nothing that file says can override it. A value is Unknown only when
an unreadable file is read before the first readable value. `PasswordAuthentication` *is* still Unknown on this
host, correctly: the first readable value is in `60-cloudimg-settings.conf`, after `50-cloud-init.conf` (which,
the owner confirms, says `yes`). What changed:

- Each sshd value records the unreadable files read before it (`unreadableBefore`), and the evidence names them:
"…50-cloud-init.conf could not be read and is read first, so it may set passwordauthentication before this".
0.74 listed every unreadable file, including ones read after the value.
- The fix line for an Unknown SSH finding suggests a drop-in that sorts first (`01-rem0te.conf`).
- Fixtures for each ordering in `unit-host-security.mjs`: an earlier readable drop-in (certain), the same setting
after the unreadable file (unsure), `sshd_config` above its `Include` (certain), every file readable (first
drop-in wins), a default after an unreadable file (unsure), and lexical order (`10-b.conf` before `9-a.conf`).

### Added — accepted risks

Some findings are decisions: SSH reachable only behind the owner's hardware firewall; a single-disk host with no
off-host audit export yet. A Platform Admin can now **accept** one finding so it stops showing as a warning.

- **`POST /admin/security/findings/:id/accept`** `{ reason, expiresInDays?, fingerprint? }`: Platform Admin, then
`assertFresh` naming the existing `server.security` key (it hides a warning, §62; the catalog description now
says so), then the service. Reason 3–300 characters, trimmed, no control characters; expiry none by default,
1–365 days. Refused: an id outside the closed list (404 `UNKNOWN_FINDING`), a never-acceptable finding (400
`FINDING_NOT_ACCEPTABLE`, with why), a check that is not failing or unknown now (409 `FINDING_NOT_OPEN`),
evidence that moved since the page read it (409 `EVIDENCE_CHANGED`), and a second acceptance (409
`ALREADY_ACCEPTED`). Recorded with `logOrFail` as `SECURITY_FINDING_ACCEPTED` (finding, status, severity, the
reason — it is not secret —, expiry, fingerprint); if the audit write fails the acceptance is closed again.
- **`DELETE /admin/security/findings/:id/accept`** re-opens it: Platform Admin, **never** a fresh confirmation (it
only shows a warning again), audited as `SECURITY_FINDING_UNACCEPTED` (`cause: unaccepted`).
- **`GET /admin/security/findings/acceptances`**: the last 200, open and closed, with who and why each ended.
- **It re-opens on its own.** Each finding now has a `fingerprint`: sha256 of its id, status and *basis* — the
facts it was decided on (the offending sockets; the effective sshd value, its file and what made it unsure; the
pending package versions; the vulnerable packages; …), never its wording or when it was read. The basis stays in
the API. On every posture read an open acceptance is closed when its expiry has passed (`expired`), its check
passes or is gone (`resolved`), or the fingerprint moved (`evidence_changed`) — a conditional write, audited
once as an automatic `SECURITY_FINDING_UNACCEPTED`. A closed acceptance never comes back, even if the evidence
returns to what it was. Accept the listener finding for `udp/5353`, and a new public `tcp/9000` re-opens it.
- **Never shown as passing.** An accepted finding keeps its status (fail or unknown), moves to a collapsed
*Accepted risks* section labelled *Accepted* or *Accepted (unknown)* with who, when, why and until when, carries
no score penalty, and is counted as `accepted` in the summary instead of fail or unknown. Coverage is unchanged:
an accepted unknown was still not read.
- **Never acceptable — fix these:** a Platform Admin without MFA (`portal.mfa.admins`); a break-glass account
without both factors (`portal.admins`); an audit chain that does not verify (`portal.audit_chain`: an incident,
not a risk); SSH accepting empty passwords; `NODE_ENV` not `production`; any `process.switch.*` test switch;
every `web.tls.*` certificate. The row says why instead of offering *Accept…*.
- **Migration `0093_security_risk_acceptance`** — numbered 0093 because 0092 is the diagnostics palette branch
(0.76.0) in flight at the same time. `SecurityFindingAcceptance`, rows never deleted; CHECKs on the finding id
(exactly `ACCEPTABLE_FINDINGS`, 30 ids, no value-carrying ones), status, severity, fingerprint shape, reason
length (3–300 after trim), evidence length, expiry (after acceptance, at most 365 days) and the reopen cause; a
partial unique index keeps one open acceptance per finding; two `ActivityAction` values.

### Tests

- `unit-host-security.mjs` (CI): 123 checks — the listener fixture now runs `ss -Htlnup` with owners and a fixtured
port range, the range's edges, TCP inside the range still unexpected, connected and loopback UDP; eight sshd
ordering fixtures; the never-acceptable list, the two lists disjoint and equal to 0093's CHECK; reason, expiry,
fingerprint stability and movement; standing (holds, expired first, evidence_changed, resolved); the score with
accepted findings.
- `e2e-host-security.mjs` (run-e2e.sh): 155 checks on 3991–3994. New: Business Owner 403 and no session 401 on
both routes; accepting asks (`server.security`) and stores nothing before; thirteen refusals; acceptance of a
failing and an unknown finding; the summary; audit rows; the database's own CHECKs; re-opening without
confirmation; expiry closing once on the next read; and a fourth API on the same host after a new port and a
readable `40-rem0te.conf` — root login decided by it (pass, not unknown), the listener acceptance re-opened
(`evidence_changed`), root login's resolved, the audit export's still holding.
- `e2e-ui.mjs`: the dialog in every combination — no *Accept…* on the Platform Admin without MFA (and why), a short
reason refused, the step-up asked, the finding under *Accepted risks* as *Accepted* (never OK) with the reason
and expiry, *1 accepted* in the summary, *Re-open* putting it back, phone width without sideways scroll, no
console errors.
- §84 (check-security-invariants): the two routes (accept asks, re-open never does), the closed list against
0093, the never-acceptable list, `acceptance.ts` pure, `logOrFail` and conditional closes, one writer, the
fingerprint/expiry rule, and `ss -Htlnup` without sudo.

### Deploy

Apply migration 0093 and regenerate the Prisma client at the target (CLAUDE.md, *A schema change needs two more
steps*). The first posture read after the deploy has fingerprints; nothing is accepted until someone accepts it.

---

## [0.75.0] — 2026-11-20 · *Spanner*

**The device page's Tools panel: everything that can be done to one computer, in eight groups, each opening the flow
Expand Down
39 changes: 36 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1788,9 +1788,42 @@ installer already grants.
and the score counts only decided checks. Release root keys are always
unknown (§56); the web shows `sudo rem0te-signed-status`.

Behavioural proof: `e2e-host-security.mjs` (ports 3991–3993, in
`run-e2e.sh`); unit: `unit-host-security.mjs` (in CI); `e2e-ui.mjs` opens
every tab against the fixture host.
0.75.1 extended §84 for accepted risks and two false positives:

- **Accepting a finding** (`POST findings/:id/accept`) is Platform Admin,
then `assertFresh` naming `server.security` (it hides a warning), then
`acceptFinding`. **Re-opening** (`DELETE` on the same path) is Platform
Admin and never asks. It is the one mutating route without a step-up.
- **One closed list.** Only `ACCEPTABLE_FINDINGS` in
`admin/host-security/acceptance.ts` can be accepted; 0093's CHECK names the
same ids in the same order. `NEVER_ACCEPTABLE` is disjoint from it and
holds a Platform Admin without MFA, break-glass without both factors, the
audit chain, empty SSH passwords, `NODE_ENV`, every `process.switch.*`
and every `web.tls*`. `acceptance.ts` is pure (`node:crypto`, posture's
types).
- **Audited.** An acceptance is written with `logOrFail`
(`SECURITY_FINDING_ACCEPTED`), and closed again if the audit write fails.
Every end of one is a conditional write audited as
`SECURITY_FINDING_UNACCEPTED` with its cause (`unaccepted`, `expired`,
`resolved`, `evidence_changed`). Only `SecurityService` writes
`SecurityFindingAcceptance`, and no row is deleted.
- **It holds only on the same fingerprint** (sha256 of id, status and the
finding's `basis`) and before its expiry (none by default, at most 365
days). The basis never leaves the API. An accepted finding keeps its
status, is never shown as OK, and carries no penalty; coverage is
unchanged.
- **Listeners.** `ss -Htlnup` runs as `reboot`, never through sudo. An
unconnected UDP socket inside `/proc/sys/net/ipv4/ip_local_port_range`
is an ephemeral client socket (hbbs's), shown as information. TCP, and
UDP outside the range, are judged as before; an unreadable range excuses
nothing.
- **SSH** is first match wins: a value is Unknown only when an unreadable
file comes before its first readable setting (`unreadableBefore`).

Behavioural proof: `e2e-host-security.mjs` (ports 3991–3994, in
`run-e2e.sh`; 3994 is the host after its evidence changed); unit:
`unit-host-security.mjs` (in CI); `e2e-ui.mjs` opens every tab against the
fixture host and drives the accept dialog.

§85 (0.75) is the device page's **Tools** panel: a menu of what can be done to
a computer that opens the flow that already does it, never a second way in.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ people and its own history. Rem0te is the portal around a self-hosted RustDesk
server that keeps them organised and separate.

[![CI](https://github.com/agit8or1/rem0te/actions/workflows/ci.yml/badge.svg)](https://github.com/agit8or1/rem0te/actions/workflows/ci.yml)
[![Version](https://img.shields.io/badge/version-0.75.0-blue)](https://github.com/agit8or1/rem0te/releases)
[![Version](https://img.shields.io/badge/version-0.75.1-blue)](https://github.com/agit8or1/rem0te/releases)
[![License: MIT](https://img.shields.io/badge/license-MIT-green)](LICENSE)
[![Stars](https://img.shields.io/github/stars/agit8or1/rem0te?style=flat)](https://github.com/agit8or1/rem0te)

Expand Down
2 changes: 1 addition & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@reboot-remote/api",
"version": "0.75.0",
"version": "0.75.1",
"private": true,
"scripts": {
"dev": "nest start --watch",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
-- 0.75.1 Accepted risks on Admin → Security (admin/host-security/acceptance.ts).
--
-- A Platform Admin may accept one finding, with a reason and an optional
-- expiry, so a deliberate decision stops showing as a warning. The row binds
-- the acceptance to a fingerprint of the evidence; when the evidence changes,
-- the check resolves or the expiry passes, the API closes the row
-- (reopenedAt, reopenCause) and the finding is a warning again. Rows are
-- never deleted.
--
-- Numbered 0093, not 0092: 0092 is taken by the diagnostics palette branch
-- (0.76.0) that was in flight at the same time.
ALTER TYPE "ActivityAction" ADD VALUE IF NOT EXISTS 'SECURITY_FINDING_ACCEPTED';
ALTER TYPE "ActivityAction" ADD VALUE IF NOT EXISTS 'SECURITY_FINDING_UNACCEPTED';

CREATE TABLE "SecurityFindingAcceptance" (
"id" TEXT NOT NULL,
"findingId" TEXT NOT NULL,
"status" TEXT NOT NULL,
"severity" TEXT NOT NULL,
"fingerprint" TEXT NOT NULL,
"evidence" TEXT NOT NULL,
"reason" TEXT NOT NULL,
"acceptedById" TEXT,
"acceptedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"expiresAt" TIMESTAMP(3),
"reopenedAt" TIMESTAMP(3),
"reopenCause" TEXT,
"reopenedById" TEXT,
CONSTRAINT "SecurityFindingAcceptance_pkey" PRIMARY KEY ("id")
);

CREATE INDEX "SecurityFindingAcceptance_findingId_acceptedAt_idx" ON "SecurityFindingAcceptance"("findingId", "acceptedAt");

-- One open acceptance per finding.
CREATE UNIQUE INDEX "SecurityFindingAcceptance_open_key" ON "SecurityFindingAcceptance"("findingId") WHERE "reopenedAt" IS NULL;

-- The closed list of checks that may be accepted: ACCEPTABLE_FINDINGS in
-- acceptance.ts, the same ids in the same order (§84 compares them). The
-- never-acceptable findings (a Platform Admin without MFA, break-glass
-- without both factors, the audit chain, empty SSH passwords, NODE_ENV,
-- test switches, TLS) are not in it.
ALTER TABLE "SecurityFindingAcceptance" ADD CONSTRAINT "SecurityFindingAcceptance_findingId_check" CHECK ("findingId" IN (
'host.ssh.root_login', 'host.ssh.password_auth', 'host.ssh.x11',
'host.firewall', 'network.listeners',
'host.updates.security', 'host.updates.other', 'host.updates.lists', 'host.updates.unattended', 'host.reboot',
'host.fail2ban', 'host.fail2ban.sshd_unit',
'web.public_https', 'web.headers', 'web.http_redirect',
'web.header.hsts', 'web.header.csp', 'web.header.framing', 'web.header.nosniff', 'web.header.referrer', 'web.header.permissions',
'portal.mfa.users', 'portal.apikeys', 'portal.audit_export', 'portal.lockout', 'portal.unenforced_rules',
'portal.signed_releases', 'portal.release_root_keys', 'portal.approval_signer',
'deps.npm'
));
ALTER TABLE "SecurityFindingAcceptance" ADD CONSTRAINT "SecurityFindingAcceptance_status_check" CHECK ("status" IN ('fail', 'unknown'));
ALTER TABLE "SecurityFindingAcceptance" ADD CONSTRAINT "SecurityFindingAcceptance_severity_check" CHECK ("severity" IN ('critical', 'high', 'medium', 'low', 'info'));
ALTER TABLE "SecurityFindingAcceptance" ADD CONSTRAINT "SecurityFindingAcceptance_fingerprint_check" CHECK ("fingerprint" ~ '^[0-9a-f]{64}$');
ALTER TABLE "SecurityFindingAcceptance" ADD CONSTRAINT "SecurityFindingAcceptance_reason_check" CHECK (char_length(btrim("reason")) BETWEEN 3 AND 300);
ALTER TABLE "SecurityFindingAcceptance" ADD CONSTRAINT "SecurityFindingAcceptance_evidence_check" CHECK (char_length("evidence") <= 2000);
ALTER TABLE "SecurityFindingAcceptance" ADD CONSTRAINT "SecurityFindingAcceptance_expiry_check" CHECK (
"expiresAt" IS NULL OR ("expiresAt" > "acceptedAt" AND "expiresAt" <= "acceptedAt" + INTERVAL '365 days')
);
ALTER TABLE "SecurityFindingAcceptance" ADD CONSTRAINT "SecurityFindingAcceptance_reopen_check" CHECK (
("reopenedAt" IS NULL AND "reopenCause" IS NULL AND "reopenedById" IS NULL)
OR ("reopenedAt" IS NOT NULL AND "reopenCause" IN ('evidence_changed', 'expired', 'resolved', 'unaccepted')
AND ("reopenCause" = 'unaccepted' OR "reopenedById" IS NULL))
);
35 changes: 35 additions & 0 deletions apps/api/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,12 @@ enum ActivityAction {
// lockout policy. Meta carries the operation, its inputs and the outcome.
HOST_SECURITY_CHANGED
LOGIN_POLICY_CHANGED
// 0.75.1 Accepted risks (migration 0093): a Platform Admin accepting one
// Admin → Security finding (meta: finding id, status, severity, reason,
// expiry, fingerprint), and an acceptance ending — by a person, or on its
// own when the evidence changed, the check resolved or it expired.
SECURITY_FINDING_ACCEPTED
SECURITY_FINDING_UNACCEPTED
}

// ─── Tenant ───────────────────────────────────────────────────────────────────
Expand Down Expand Up @@ -5015,3 +5021,32 @@ model MsaManagedComputer {
run MsaCutoverRun? @relation(fields: [runId], references: [id], onDelete: SetNull)
updatedAt DateTime @updatedAt
}

/// 0.75.1: one Admin → Security finding a Platform Admin accepted as a risk
/// (admin/host-security/acceptance.ts). Only SecurityService writes it. A row
/// holds while `reopenedAt` is null and the finding's fingerprint is the one
/// stored; it is never deleted, so the history of every acceptance stays.
/// 0093 CHECKs the finding id (ACCEPTABLE_FINDINGS), the reason length, the
/// expiry (at most 365 days) and the reopen cause, and keeps one open row per
/// finding (partial unique index).
model SecurityFindingAcceptance {
id String @id @default(cuid())
findingId String
/// fail | unknown: what it was when accepted.
status String
severity String
/// sha256 hex of the finding's id, status and basis at acceptance.
fingerprint String
/// The evidence as it read then, for the page (at most 2,000 characters).
evidence String
reason String
acceptedById String?
acceptedAt DateTime @default(now())
expiresAt DateTime?
reopenedAt DateTime?
/// evidence_changed | expired | resolved | unaccepted (0093 CHECK).
reopenCause String?
reopenedById String?

@@index([findingId, acceptedAt])
}
Loading
Loading