Fix arbitrary file write in download_polyhaven_asset#258
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR hardens the Poly Haven asset download flow by adding path traversal prevention. The ChangesPath Traversal Prevention in Asset Downloads
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Review Summary by QodoFix path traversal vulnerability in download_polyhaven_asset
WalkthroughsDescription• Prevents arbitrary file write via path traversal in Poly Haven asset downloads • Validates include paths from API responses against directory escape attempts • Rejects absolute paths and paths containing ".." components • Ensures resolved paths remain within temporary directory boundary Diagramflowchart LR
API["Poly Haven API Response"]
VALIDATE["Validate include_path"]
CHECK1["Check: absolute path?"]
CHECK2["Check: contains '..'?"]
CHECK3["Check: escapes temp_dir?"]
SKIP["Skip unsafe include"]
DOWNLOAD["Download to temp_dir"]
API --> VALIDATE
VALIDATE --> CHECK1
CHECK1 -->|Yes| SKIP
CHECK1 -->|No| CHECK2
CHECK2 -->|Yes| SKIP
CHECK2 -->|No| CHECK3
CHECK3 -->|Yes| SKIP
CHECK3 -->|No| DOWNLOAD
File Changes1. addon.py
|
Code Review by Qodo
Context used 1. Overbroad '..' path filter
|
#257
summary
BlenderMCPServer.download_polyhaven_asset(models branch, addon.py:755) joins dict keys from the Poly Haven API"include"field directly into a filesystem path with no containment check. A malicious or MITM'd API response can set those keys to../../.bashrcor absolute paths and write arbitrary files anywhere the Blender process has write access.fix
Mirrors the existing zip-slip check in download_sketchfab_model (addon.py:1750-1777):
Unsafe includes are skipped with a log message, not aborted — matches the existing convention on the same code path (a failed include download is already logged + skipped, not fatal). Legitimate model imports continue to work; only the malicious entry is dropped.
Summary by CodeRabbit