Skip to content

🛡️ Sentinel: [HIGH] Fix path traversal in file upload handling#151

Open
Cukurikik wants to merge 4 commits intomainfrom
jules-sentinel-path-traversal-fix-8867312925282303551
Open

🛡️ Sentinel: [HIGH] Fix path traversal in file upload handling#151
Cukurikik wants to merge 4 commits intomainfrom
jules-sentinel-path-traversal-fix-8867312925282303551

Conversation

@Cukurikik
Copy link
Copy Markdown
Owner

@Cukurikik Cukurikik commented Mar 29, 2026

🚨 Severity: HIGH
💡 Vulnerability: User-provided filenames were not properly sanitized when building destination file paths in API routes handling file uploads (api/video/[tool]/route.ts and api/plugins/install/route.ts). If a malicious user intercepted the request and changed the filename to include relative paths like ../../, this could result in Path Traversal, writing files to arbitrary directories on the server.
🎯 Impact: Arbitrary File Write (Path Traversal) potentially leading to Remote Code Execution or System Compromise.
🔧 Fix: Wrapped the user-supplied file.name values inside Node's native path.basename() method, which safely strips any malicious directory traversal characters off the filename before prepending it with the UUID or timestamp identifiers.
✅ Verification: Tested API logic using unit tests and verified code manually; testing indicates the issue is fixed without regressions to core functionality.


PR created automatically by Jules for task 8867312925282303551 started by @Cukurikik

Summary by CodeRabbit

  • Bug Fixes
    • Fixed path traversal in file upload endpoints by sanitizing user-provided filenames; responses now return sanitized filenames to avoid unsafe server paths.
  • Chores
    • CI updates: upgraded Node.js runtime, switched install/cache to pnpm and updated pnpm setup steps across workflows.

Sanitize user-provided filenames using `path.basename` in
`src/app/api/video/[tool]/route.ts` and
`src/app/api/plugins/install/route.ts` to prevent path traversal
attacks where malicious files could be written outside their
designated directories.

Co-authored-by: Cukurikik <266119688+Cukurikik@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 29, 2026

📝 Walkthrough

Walkthrough

Sanitized user-supplied filenames with path.basename() in two upload API routes to prevent path traversal; added a sentinel entry documenting the issue and updated CI workflows to use pnpm (pnpm setup and lockfile cache adjustments).

Changes

Cohort / File(s) Summary
Security Documentation
\.jules/sentinel.md
Added sentinel entry (2024-05-30) describing a path traversal risk in API uploads and recommending path.basename() for filename sanitization.
API Route Sanitization
src/app/api/plugins/install/route.ts, src/app/api/video/[tool]/route.ts
Import and use path.basename() to derive safeFileName; replace direct file.name usage when constructing temp/on-disk paths and returned fileName.
CI: pnpm & Node updates
.github/workflows/audio-ci.yml, .github/workflows/ci-cd.yml, .github/workflows/video-backend-ci.yml
Switch CI to pnpm (install step and cache keyed by pnpm-lock.yaml), update Node setup and pnpm action/version references.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I nibbled through names, removed each sly slash,
basename() saved the day with a hop and a dash.
No ".." shall wander where temp files lie,
Safe paths now hum beneath the sky. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main change: fixing path traversal vulnerability in file upload handling through filename sanitization.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jules-sentinel-path-traversal-fix-8867312925282303551

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

- Sanitize user-provided filenames using `path.basename` in
  `api/video/[tool]/route.ts` and `api/plugins/install/route.ts`
  to prevent path traversal attacks.
- Update GitHub workflows (`ci-cd.yml`, `audio-ci.yml`,
  `video-backend-ci.yml`) to use `pnpm/action-setup@v4` with Node 22
  to resolve Node 20 deprecation warnings and missing pnpm v3 support.
- Apply `pnpm install --no-frozen-lockfile` to resync the out-of-date
  `pnpm-lock.yaml` with `package.json`, fixing the failing CI job.

Co-authored-by: Cukurikik <266119688+Cukurikik@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
.github/workflows/audio-ci.yml (1)

19-26: Consider centralizing Node/pnpm versions in workflow env

Hardcoded versions at Line 19 and Line 26 may drift over time. This repo already uses top-level NODE_VERSION/PNPM_VERSION in .github/workflows/ci-cd.yml:13-35; mirroring that pattern here will reduce maintenance overhead.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/audio-ci.yml around lines 19 - 26, Replace the hardcoded
node-version: '22' and the pnpm setup version: '9' with workflow environment
variables used elsewhere (NODE_VERSION and PNPM_VERSION) so versions are
centralized; update the job steps that set node-version and the
pnpm/action-setup@v4 with their with: version to reference env variables (e.g.,
use ${ { env.NODE_VERSION } } and ${ { env.PNPM_VERSION } } or the workflow’s
variable syntax) and ensure the top-level env entries NODE_VERSION and
PNPM_VERSION exist in this workflow to mirror .github/workflows/ci-cd.yml.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/audio-ci.yml:
- Around line 16-26: The workflow config enables actions/setup-node cache:
'pnpm' before pnpm is actually installed, causing "Unable to locate executable
file: pnpm"; fix by installing pnpm first (the step labeled "Setup pnpm" /
pnpm/action-setup@v4) and then run the "Setup Node.js" step that uses cache:
'pnpm', or alternatively remove the pnpm cache flag; reorder the steps so the
pnpm/action-setup step runs before the actions/setup-node step that sets cache:
'pnpm'.

---

Nitpick comments:
In @.github/workflows/audio-ci.yml:
- Around line 19-26: Replace the hardcoded node-version: '22' and the pnpm setup
version: '9' with workflow environment variables used elsewhere (NODE_VERSION
and PNPM_VERSION) so versions are centralized; update the job steps that set
node-version and the pnpm/action-setup@v4 with their with: version to reference
env variables (e.g., use ${ { env.NODE_VERSION } } and ${ { env.PNPM_VERSION } }
or the workflow’s variable syntax) and ensure the top-level env entries
NODE_VERSION and PNPM_VERSION exist in this workflow to mirror
.github/workflows/ci-cd.yml.
🪄 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

Run ID: c4cf4721-8f0a-4cea-89be-cb501ff502e6

📥 Commits

Reviewing files that changed from the base of the PR and between f09a0ec and dbee8f8.

📒 Files selected for processing (3)
  • .github/workflows/audio-ci.yml
  • .github/workflows/ci-cd.yml
  • .github/workflows/video-backend-ci.yml
✅ Files skipped from review due to trivial changes (2)
  • .github/workflows/video-backend-ci.yml
  • .github/workflows/ci-cd.yml

google-labs-jules bot and others added 2 commits March 29, 2026 23:42
- Sanitize user-provided filenames using `path.basename` in
  `api/video/[tool]/route.ts` and `api/plugins/install/route.ts`
  to prevent path traversal attacks.
- Update GitHub workflows (`ci-cd.yml`, `audio-ci.yml`,
  `video-backend-ci.yml`) to use `pnpm/action-setup@v4` with Node 22
  to resolve Node 20 deprecation warnings and missing pnpm v3 support.

Co-authored-by: Cukurikik <266119688+Cukurikik@users.noreply.github.com>
Sanitize user-provided filenames using `path.basename` in
`src/app/api/video/[tool]/route.ts` and
`src/app/api/plugins/install/route.ts` to prevent path traversal
attacks where malicious files could be written outside their
designated directories.

Co-authored-by: Cukurikik <266119688+Cukurikik@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant