feat(gateway): HERMES_MEDIA_EXTRA_ROOTS to widen /api/media read roots - #42778
feat(gateway): HERMES_MEDIA_EXTRA_ROOTS to widen /api/media read roots#42778maxtrigify wants to merge 1 commit into
Conversation
GET /api/media is confined to ~/.hermes/{images,screenshots,cache}, so a remote
desktop client can't display images an agent generates outside that tree — e.g.
into a project/output dir — which 403 "Path outside media roots" and render as
dead links. Let operators opt extra directories in via HERMES_MEDIA_EXTRA_ROOTS
(os.pathsep-separated absolute paths). Each is still resolved symlink-safe and
the suffix/size guards are unchanged, so this widens the allowlist deliberately
without bypassing the other protections.
Common multi-host case: gateways on one machine serving a desktop on another,
where the agent writes generated images into its working/output directory.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Verified — no issues found. Security review notes on the
The opt-in model (explicit env var, no wildcard expansion, default empty) is the right trade-off for a media-serving endpoint. LGTM on the security posture. |
Positive Verification — Media Serving Security ReviewReviewed the full diff in Changes verified:
No issues found. Clean opt-in mechanism for operators needing wider media serving roots. |
|
Thanks for the scoped implementation and the preserved symlink, suffix, and size checks. This is an automated hermes-sweeper review.
Closed as not-planned per standing maintainer policy ( |
Summary
GET /api/media(remote image display) is confined to~/.hermes/{images,screenshots,cache}. That's the right default, but it means a desktop client connected to a remote gateway can't display images an agent generated outside that tree — e.g. into its project/output directory. Those requests return403 {"detail":"Path outside media roots"}and render as dead "Open …png" links instead of inline images.This adds an opt-in
HERMES_MEDIA_EXTRA_ROOTSenv var (anos.pathsep-separated list of absolute directories) that operators can set to allow additional read roots.Why
Common multi-host setup: gateways on one machine, desktop on another. The agent writes generated images (charts, cards, screenshots) into its working/output dir — outside
~/.hermes— so they can't be displayed remotely today. There's no way to widen the allowlist without editing source.Safety
The widening is deliberate and scoped:
.resolve()+root in target.parentscheck as the built-in roots).Changes
hermes_cli/web_server.py—_media_serve_roots()appendsHERMES_MEDIA_EXTRA_ROOTSentries.tests/hermes_cli/test_web_server.py— new test: a dir is 403 by default, served once opted in via the env var, and a sibling dir not listed stays 403 (scoping).Verified:
pytest tests/hermes_cli/test_web_server.py -k get_media→ 6 passed.🤖 Generated with Claude Code