Files
davidandClaude Opus 5.5 e991264ddc Let Hermes' gateway reach only a Matrix server you've allowed
sandbox/setup.sh allowed Hermes' gateway the host in MATRIX_HOMESERVER
from ~/.hermes/.env, which Hermes can write from inside its sandbox. On
the next update, Hermes could have opened the way out to any host it
chose.

The allowed server is now in ~/.config/coredesktop/sandbox/hermes.json,
which no sandbox can write. configure hermes is to do while Hermes names
a server you haven't allowed, and asks about only that; update says so.
Only a plain host name counts, so it can't be a wildcard or carry escape
codes into the question. A migration carries over the server the
gateway's systemd drop-in allows now, so a working gateway keeps
working. sandbox/agent no longer takes domains from
COREDESKTOP_SANDBOX_DOMAINS, which nothing else used.

The security checks skill now records step 3 as done.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 16:13:32 -07:00

18 lines
943 B
Bash

#!/bin/bash
# Hermes' gateway used to be allowed whatever Matrix server Hermes' own
# settings named, which Hermes can change from inside its sandbox. Now it
# reaches only a server in ~/.config/coredesktop/sandbox/hermes.json, which
# configure hermes asks about. Carry over the server the gateway reaches now,
# from its systemd drop-in, which the sandbox can't write, so a gateway that
# works keeps working; sandbox/setup.sh then rewrites the drop-in without it.
DROPIN="$HOME/.config/systemd/user/hermes-gateway.service.d/coredesktop-sandbox.conf"
[ -f "$DROPIN" ] || exit 0
COREDESKTOP="${COREDESKTOP:-$HOME/.local/share/coredesktop}"
source "$COREDESKTOP/sandbox/hermes-homeserver.sh"
host="$(sed -nE 's#^Environment="?COREDESKTOP_SANDBOX_DOMAINS=([^" ]*)"?$#\1#p' "$DROPIN" | head -n 1)"
[[ "$host" =~ ^[A-Za-z0-9]([A-Za-z0-9.-]*[A-Za-z0-9])?$ ]] || exit 0
hermes_homeserver_allowed "$host" && exit 0
hermes_allow_homeserver "$host"