fix(gateway): validate MEDIA tag paths to block arbitrary local file …#6084
Open
Ruzzgar wants to merge 1 commit into
Open
fix(gateway): validate MEDIA tag paths to block arbitrary local file …#6084Ruzzgar wants to merge 1 commit into
Ruzzgar wants to merge 1 commit into
Conversation
4 tasks
Collaborator
1 similar comment
Collaborator
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.
Context
MEDIA:directives are intended for explicit media attachment delivery (images/audio/video), but the parser currently accepts overly broad path tokens.This creates a trust-boundary issue: model-generated text can influence which local files are sent as platform attachments.
What’s wrong (concrete exploit path)
A crafted response such as:
MEDIA:'/etc/passwd'MEDIA:/tmp/secrets.envMEDIA:"/home/user/.ssh/config"can be parsed as a valid attachment candidate and routed into native send flows (
send_document/send_image_file/send_video), depending on adapter behavior.That means non-media host files can be exfiltrated through normal chat output delivery.
Behavioral change in this PR
MEDIA:extraction is now strict and intentionally conservative:http://,https://, etc.).env,.txt,.conf, etc.)Implementation overview
gateway/platforms/base.py_normalize_media_tag_path()as a single validation gate forMEDIA:values.extract_media()to use normalized/validated output only.Regression coverage
tests/gateway/test_platform_base.pyAdded:
test_media_tag_ignores_non_media_file_pathsThis test verifies that sensitive/non-media files are not extracted from
MEDIA:tags and therefore are not eligible for attachment routing.Why this fix is scoped correctly
MEDIA:contract for real media outputs intact.Validation status