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>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Purpose : The Matrix server Hermes' gateway talks to, and whether you've let
|
||||
# its sandbox reach it. Source this file; used by sandbox/setup.sh,
|
||||
# configure hermes and a migration.
|
||||
#
|
||||
# Hermes' settings (~/.hermes/.env) name the server, but Hermes can change them
|
||||
# from inside its sandbox, so they say only what Hermes wants to reach. The
|
||||
# server it may reach is in your own hermes.json, which no sandbox can write;
|
||||
# configure hermes asks you before adding it there.
|
||||
|
||||
HERMES_ENV="$HOME/.hermes/.env"
|
||||
HERMES_SANDBOX_CONF="$HOME/.config/coredesktop/sandbox/hermes.json"
|
||||
|
||||
# The host in MATRIX_HOMESERVER, e.g. matrix.example.org, or nothing. Only a
|
||||
# plain host name or IPv4 address counts, so it can't be a wildcard or carry
|
||||
# characters that would change what a terminal shows when it's asked about.
|
||||
hermes_homeserver() {
|
||||
local host
|
||||
host="$(sed -nE "s#^MATRIX_HOMESERVER=[\"']?https?://([^/:\"']+).*#\1#p" "$HERMES_ENV" 2> /dev/null | head -n 1)"
|
||||
[[ "$host" =~ ^[A-Za-z0-9]([A-Za-z0-9.-]*[A-Za-z0-9])?$ ]] && echo "$host"
|
||||
}
|
||||
|
||||
# hermes_homeserver_allowed HOST: true if Hermes' sandbox may reach HOST
|
||||
hermes_homeserver_allowed() {
|
||||
[ -n "$1" ] && jq -e --arg host "$1" '(.network.allowedDomains // []) | index($host) != null' \
|
||||
"$HERMES_SANDBOX_CONF" > /dev/null 2>&1
|
||||
}
|
||||
|
||||
# hermes_allow_homeserver HOST: let Hermes' sandbox reach HOST
|
||||
hermes_allow_homeserver() {
|
||||
source "${COREDESKTOP:-$HOME/.local/share/coredesktop}/configure.d/lib/json.sh"
|
||||
edit_json "$HERMES_SANDBOX_CONF" '{}' --arg host "$1" \
|
||||
'.network.allowedDomains = ((.network.allowedDomains // []) - [$host] + [$host])'
|
||||
}
|
||||
Reference in New Issue
Block a user