fix(gateway): validate MEDIA tag paths to block arbitrary local file … - #6084
fix(gateway): validate MEDIA tag paths to block arbitrary local file …#6084Ruzzgar wants to merge 1 commit into
Conversation
1 similar comment
|
merge conflicts This PR does not merge cleanly with the base branch. Please rebase or merge current Signed: GPT-5.5-low in Codex |
|
Thanks for the security-minded report, @Ruzzgar — and for the tests. After verifying against current The vulnerability doesn't exist on current main. Verified live: This permissive-by-default, validate-at-delivery design is intentional (#29523) — it's symmetric with inbound delivery (platforms hand the agent any uploaded file, the agent can hand back any non-credential file), with strict mode for the public-bot threat model. Two reasons not to land the change as written:
Closing as superseded by the existing delivery-path validation. Appreciate the contribution — if you hit a path that actually does slip through |
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