Skip to content

🛡️ Sentinel: [CRITICAL] Fix IDOR in file deletion#154

Open
xb1g wants to merge 1 commit into
mainfrom
sentinel-fix-upload-delete-idor-3789603280855221130
Open

🛡️ Sentinel: [CRITICAL] Fix IDOR in file deletion#154
xb1g wants to merge 1 commit into
mainfrom
sentinel-fix-upload-delete-idor-3789603280855221130

Conversation

@xb1g

@xb1g xb1g commented Mar 28, 2026

Copy link
Copy Markdown
Collaborator

🚨 Severity: CRITICAL
💡 Vulnerability: In app/api/upload/route.ts, the DELETE endpoint used fileName.includes('submissions/${user.id}/') to verify that the file being deleted belonged to the requesting user. Since cloud storage keys (like S3/B2) are treated as literal strings, an attacker could theoretically bypass this by constructing a key that contains their user ID as a substring (e.g., other-user/submissions/${attacker_id}/target-file.jpg). This is an Insecure Direct Object Reference (IDOR) and authorization bypass.
🎯 Impact: An attacker could delete other users' files by crafting a file name that contains their own ID as a substring.
🔧 Fix: Updated app/api/upload/route.ts to use .startsWith('submissions/${user.id}/') instead of .includes(). This enforces a strict hierarchical boundary check for file ownership. Added a security comment explaining the fix. Also added a journal entry in .jules/sentinel.md.
Verification: Verified using pnpm lint and pnpm test. Code review passed successfully.


PR created automatically by Jules for task 3789603280855221130 started by @xb1g

Co-authored-by: xb1g <70068561+xb1g@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.

@vercel

vercel Bot commented Mar 28, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pseed Ready Ready Preview, Comment Mar 28, 2026 4:04am

@xb1g
xb1g force-pushed the sentinel-fix-upload-delete-idor-3789603280855221130 branch from 53f5ed0 to 4de54f3 Compare May 11, 2026 17:28
Copilot AI review requested due to automatic review settings May 11, 2026 17:28
@vercel

vercel Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

Unable to deploy a commit from a private repository on your GitHub organization to the wachaa1319's projects team on Vercel, which is currently on the Hobby plan. In order to deploy, you can:

  • Make your repository public or
  • Upgrade to Pro. A Pro subscription is required to deploy from a private organization repository.

To read more about collaboration on Vercel, click here.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens the DELETE handler in the upload API to prevent an IDOR authorization bypass when deleting user submission files stored in Backblaze B2 (S3-compatible), ensuring users can only delete objects within their own submissions prefix.

Changes:

  • Replaced the ownership check from fileName.includes(...) to fileName.startsWith(...) to enforce a strict prefix boundary for submissions/${user.id}/.
  • Added inline security commentary explaining the rationale and bypass scenario.
  • Added a Sentinel journal entry documenting the vulnerability and prevention guidance.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
app/api/upload/route.ts Strengthens file deletion authorization by enforcing a strict submissions/{userId}/ prefix check.
.jules/sentinel.md Documents the IDOR issue and the preferred prevention pattern for path-key authorization checks.

Comment thread .jules/sentinel.md
**Prevention:** When you need to display user-provided SVGs and you don't need to manipulate their internal paths via CSS/JS, do not use `dangerouslySetInnerHTML`. Instead, render the SVG securely by encoding it as a data URI (`data:image/svg+xml;charset=utf-8,${encodeURIComponent(svgData)}`) and using it as the `src` attribute of a standard `<img>` tag. This forces the browser to treat the SVG strictly as an image, entirely disabling any embedded script execution.

## 2025-03-08 - IDOR Vulnerability in File Deletion via string.includes()
**Vulnerability:** In `app/api/upload/route.ts`, the `DELETE` endpoint used `fileName.includes('submissions/${user.id}/')` to verify that the file being deleted belonged to the requesting user. Since cloud storage keys (like S3/B2) are treated as literal strings, an attacker could theoretically bypass this by constructing a key that contains their user ID as a substring (e.g., `other-user/submissions/${attacker_id}/target-file.jpg`).
@xb1g
xb1g force-pushed the sentinel-fix-upload-delete-idor-3789603280855221130 branch from 4de54f3 to ba37318 Compare May 11, 2026 17:37
@xb1g
xb1g force-pushed the sentinel-fix-upload-delete-idor-3789603280855221130 branch from ba37318 to f459922 Compare May 11, 2026 17:39
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 11, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
web f459922 May 11 2026, 06:21 PM

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.

2 participants