fix(security): denylist ~/.hermes/mcp-tokens/ for media delivery - #56163
Merged
Conversation
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/.
Collaborator
Salvage of #37222 by @briandevans — related, not a duplicate. Part of the media-delivery credential denylist family: #50912, #51453, #32090. |
13 tasks
13 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
mainwith authorship preserved.Root cause:
_media_delivery_denied_paths()ingateway/platforms/base.pydenied.env,auth.json,credentials/,config.yaml, andpairing/— but notmcp-tokens/. The read/write guard (agent/file_safety.py) already denied that directory, so the delivery/exfil side trailed the write side. A prompt-injectionMEDIA:~/.hermes/mcp-tokens/github.jsontag 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), mirroringpairing/. Comment updated (the old text pointed at this PR as the pending sibling).tests/gateway/test_platform_base.py: parametrized test assertingvalidate_media_delivery_pathreturnsNonefor the three token file types.Validation
MEDIA:mcp-tokens/github.jsonNone(denied)pairing/,auth.jsoncache/images/*.pngscripts/run_tests.sh tests/gateway/test_platform_base.py→ 177/177 pass (3 new cases).HERMES_HOME: all three token files DENIED, control siblings still denied, fresh cache image still delivers.Infographic
Nous Research