Skip to content

fix(security): denylist ~/.hermes/mcp-tokens/ for media delivery - #56163

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-f6ff1a2e
Jul 1, 2026
Merged

fix(security): denylist ~/.hermes/mcp-tokens/ for media delivery#56163
teknium1 merged 1 commit into
mainfrom
hermes/hermes-f6ff1a2e

Conversation

@teknium1

@teknium1 teknium1 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Media delivery can no longer auto-attach a live MCP OAuth bearer token. mcp-tokens/ is now on the media-delivery denylist, pairing the exfil side with the read/write guard that already blocked it.

Salvage of #37222 by @briandevans, cherry-picked onto current main with authorship preserved.

Root cause: _media_delivery_denied_paths() in gateway/platforms/base.py denied .env, auth.json, credentials/, config.yaml, and pairing/ — but not mcp-tokens/. The read/write guard (agent/file_safety.py) already denied that directory, so the delivery/exfil side trailed the write side. A prompt-injection MEDIA:~/.hermes/mcp-tokens/github.json tag would, in default (non-strict) mode, deliver a live bearer token as a native gateway attachment.

Changes

  • gateway/platforms/base.py: add "mcp-tokens" to _ROOT_CREDENTIAL_DIRS. Directory-prefix containment (_path_is_within) seals the whole subtree (<server>.json / .client.json / .meta.json), mirroring pairing/. Comment updated (the old text pointed at this PR as the pending sibling).
  • tests/gateway/test_platform_base.py: parametrized test asserting validate_media_delivery_path returns None for the three token file types.

Validation

Before After
MEDIA:mcp-tokens/github.json delivered (leak) None (denied)
pairing/ , auth.json denied denied (no regression)
legit cache/images/*.png delivers delivers (feature preserved)
  • scripts/run_tests.sh tests/gateway/test_platform_base.py → 177/177 pass (3 new cases).
  • E2E with real imports against a temp HERMES_HOME: all three token files DENIED, control siblings still denied, fresh cache image still delivers.

Infographic

PR #37222 infographic

Nous Research

mcp-tokens/ holds live MCP OAuth access tokens (<server>.json) and
dynamically-registered OAuth client credentials (<server>.client.json),
layout per tools/mcp_oauth.py. This is the same credential class as
auth.json/credentials/, which _media_delivery_denied_paths() already
blocks. The write side already denies this dir (file_tools
_check_sensitive_path), but the media-delivery (read/exfil) side did
not, leaving an unpaired half-door.

Without it, a prompt-injection MEDIA: tag emitting
~/.hermes/mcp-tokens/<server>.json would, in default (non-strict)
mode, pass the denylist and exfiltrate a live OAuth bearer token to
the same untrusted channel. Sibling follow-up to commit 4ec0ade
(config.yaml media-delivery denylist).

mcp-tokens is a directory and _path_under_denied_prefix already does
containment matching, so the whole subtree (.json/.client.json/
.meta.json) is denied, mirroring credentials/.
@alt-glitch alt-glitch added type/security Security vulnerability or hardening comp/gateway Gateway runner, session dispatch, delivery tool/mcp MCP client and OAuth area/auth Authentication, OAuth, credential pools sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data P2 Medium — degraded but workaround exists labels Jul 1, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Salvage of #37222 by @briandevans — related, not a duplicate. Part of the media-delivery credential denylist family: #50912, #51453, #32090.

@teknium1
teknium1 merged commit 42d0174 into main Jul 1, 2026
31 checks passed
@teknium1
teknium1 deleted the hermes/hermes-f6ff1a2e branch July 1, 2026 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/auth Authentication, OAuth, credential pools comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data tool/mcp MCP client and OAuth type/security Security vulnerability or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants