Skip to content

fix(wecom): bound outbound local media paths#26424

Open
lidge-jun wants to merge 1 commit into
NousResearch:mainfrom
lidge-jun:codex/8733-wecom-media-path-boundary
Open

fix(wecom): bound outbound local media paths#26424
lidge-jun wants to merge 1 commit into
NousResearch:mainfrom
lidge-jun:codex/8733-wecom-media-path-boundary

Conversation

@lidge-jun

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes WeCom outbound local media loading so file:// and plain local path sources are resolved and checked before read_bytes(). Local media uploads are now limited to Hermes media cache directories and the system temp directory, which blocks arbitrary local file reads while preserving generated/cached media delivery.

HTTP/HTTPS media sources still use the existing _download_remote_bytes() path with tools.url_safety.is_safe_url() SSRF protection.

I found this while following up on the OpenClaw/Hermes runtime and security-hardening work after the Oracle zip contribution, and kept the patch intentionally narrow to the public WeCom issue.

Related Issue

Fixes #8733

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • gateway/platforms/wecom.py: add a resolved allowlist for outbound local media roots: image/audio/video/document caches plus tempfile.gettempdir().
  • gateway/platforms/wecom.py: validate every local/file URL outbound media source before existence checks and read_bytes().
  • gateway/platforms/wecom.py: reject non-local file://host/... media URLs.
  • tests/gateway/test_wecom.py: cover allowed media-cache files, blocked arbitrary local files, and symlink escape attempts.

How to Test

  1. scripts/run_tests.sh tests/gateway/test_wecom.py
  2. git diff --check
  3. .venv/bin/python -m ruff check gateway/platforms/wecom.py tests/gateway/test_wecom.py
  4. .venv/bin/python -m py_compile gateway/platforms/wecom.py tests/gateway/test_wecom.py

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):)
  • I searched for existing PRs to make sure this isn't a duplicate
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes
  • I've tested on my platform: macOS Darwin 25.3.0 arm64, Python 3.11.13

Focused WeCom tests and touched-file checks passed; full pytest tests/ -q was not run because this is a narrow platform-adapter fix.

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — N/A
  • I've considered cross-platform impact per the compatibility guide
  • I've updated tool descriptions/schemas if I changed tool behavior — N/A

For New Skills

N/A

Screenshots / Logs

scripts/run_tests.sh tests/gateway/test_wecom.py
45 passed in 3.46s

.venv/bin/python -m ruff check gateway/platforms/wecom.py tests/gateway/test_wecom.py
All checks passed!

git diff --check
# no output

.venv/bin/python -m py_compile gateway/platforms/wecom.py tests/gateway/test_wecom.py
# no output

@daimon-nous daimon-nous Bot added type/security Security vulnerability or hardening P1 High — major feature broken, no workaround platform/wecom WeCom / WeChat Work adapter comp/gateway Gateway runner, session dispatch, delivery labels May 15, 2026
@lidge-jun lidge-jun force-pushed the codex/8733-wecom-media-path-boundary branch from c63ca08 to 7a4e0b5 Compare May 17, 2026 03:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P1 High — major feature broken, no workaround platform/wecom WeCom / WeChat Work adapter type/security Security vulnerability or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Arbitrary File Read via file:// URL Path Traversal in WeCom Adapter

1 participant