fix: reject path traversal in chart and file parameters - #36
Conversation
|
Preview environment torn down. |
|
Warning Review limit reached
More reviews will be available in 45 minutes and 7 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughBoth ChangesRoute path validation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@server/routes/folders.js`:
- Around line 114-115: The input validation in the `init` handler should reject
non-string `folder` and `chart` values before calling string/path methods, since
`includes(...)` and `path.isAbsolute(...)` can throw on objects, numbers, or
arrays and cause a 500. Update the existing guard around the `folder` and
`chart` checks in `server/routes/folders.js` to first verify both fields are
strings, then apply the path traversal and absolute-path checks, returning the
same 400 response for any invalid type or value.
In `@server/routes/git.js`:
- Around line 156-158: The `/diff` path validation in `git.js` should guard the
`file` query value’s type before using `path.isAbsolute`, since `req.query.file`
may be an array or object and currently can throw instead of returning the
intended 400. Update the existing validation block around the `file` check to
only run string-based path checks when `file` is a string, and treat any
non-string `file` as invalid alongside the existing `..` and absolute-path
checks.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 6b8abef9-6922-4838-b09a-6b1356d0a372
📒 Files selected for processing (4)
server/routes/folders.jsserver/routes/git.jstests/integration/folders-api.test.jstests/integration/git-api.test.js
Prevent 500 errors when chart/folder/file receive non-string values (e.g. arrays from repeated query params or malformed JSON body). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
POST /folders/init: rejectschartvalues containing..or absolute paths (closes POST /folders/init missing path traversal validation onchartparameter #33)GET /api/git/diff: applies the same guard to thefileparameter (closes GET /api/git/diff missing path traversal validation onfileparameter #34)..and absolute path casesTest plan
POST /folders/initwithchart: '../../etc'→ 400POST /folders/initwithchart: '/etc/passwd'→ 400GET /api/git/diff?file=../../etc/passwd→ 400GET /api/git/diff?file=/etc/passwd→ 400🤖 Generated with Claude Code
Summary by CodeRabbit
400errors instead of being partially accepted.