fix: constrain local upload paths to configured directories - #330
Conversation
WalkthroughThe change adds configurable upload roots, canonical path validation, and local upload enforcement. Paths must remain within the download directory or configured ChangesUpload path security
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant Client
participant normalizeUploadCommand
participant getConfig
participant assertAllowedUploadPath
participant Filesystem
Client->>normalizeUploadCommand: submit local upload path
normalizeUploadCommand->>getConfig: load uploadDirs
normalizeUploadCommand->>assertAllowedUploadPath: validate path
assertAllowedUploadPath->>Filesystem: resolve path and roots
Filesystem-->>assertAllowedUploadPath: canonical paths
assertAllowedUploadPath-->>normalizeUploadCommand: allowed path or validation error
normalizeUploadCommand->>Filesystem: read allowed file
Suggested reviewers: Merge Risk: 🟡 Moderate · up to A process able to modify an allowed upload directory can race the path check and cause files outside the configured roots to be uploaded. Bind validation to the opened file before merging. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 10 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
A rabbit checks each upload gate Comment |
|
Verification complete: all six reported checks pass (tests on Node 24, package hygiene, Prettier, title validation, CodeRabbit, and Devin Review). Local build/full tests passed with 1,054 tests; lint and changed-file formatting checks also passed. Both reviewers raised the same filesystem-isolation concern; the threads document why descriptor-relative confinement is outside this canonical directory-selection change for an operator-managed filesystem. CodeRabbit explicitly withdrew its finding; both bot threads are resolved. This guard is not an OS sandbox. The docstring-coverage warning is advisory, not a failing repository check. The branch is mergeable and ready for human review. No merge or release performed. |
Summary
Configuration
BROWSERLESS_UPLOAD_DIRSadds upload directories to the default download directory. Separate entries with:on macOS/Linux or;on Windows. Unset or empty values keep the download-directory-only default.Model-facing file-transfer guidance now describes these requirements.
Test plan
npm test— 1,054 passing, including build and regression tests.npm run lintCoverage includes allowed paths, explicit additional directories, canonical paths and symlinks, rejected paths, default configuration, the upload size cap, and download-to-upload reuse. No live-service smoke test was run; the changed behavior is local stdio file handling.
No new dependencies.
Summary by CodeRabbit
New Features
BROWSERLESS_UPLOAD_DIRS.Bug Fixes
Tests