Skip to content

🔒 Fix IDOR vulnerability in post updates - #79

Open
Sparkier wants to merge 1 commit into
mainfrom
fix-idor-post-update-17914967494521786957
Open

🔒 Fix IDOR vulnerability in post updates#79
Sparkier wants to merge 1 commit into
mainfrom
fix-idor-post-update-17914967494521786957

Conversation

@Sparkier

@Sparkier Sparkier commented Aug 1, 2026

Copy link
Copy Markdown
Owner

🎯 What: The vulnerability fixed
Fixed an Insecure Direct Object Reference (IDOR) on the PATCH /api/post/[id] route where a user could modify keywords of a post they do not own.

⚠️ Risk: The potential impact if left unfixed
Previously, the code only checked for a database error from Supabase on update, but without .select(), Supabase returns success even if no rows match the filter id = params.id and creator = session.user.email. This allowed unauthorized users to proceed past the check, resulting in the endpoint deleting and re-inserting keywords for posts they did not own, which is a major security flaw.

🛡️ Solution: How the fix addresses the vulnerability
Appended .select() to the Supabase update query and checked the returned data payload. If it is null or empty, it throws a 404 Not found or unauthorized error, preventing the execution from reaching the subsequent keyword deletion/insertion logic. Also added a comprehensive test to verify this behavior correctly blocks unowned post modifications.


PR created automatically by Jules for task 17914967494521786957 started by @Sparkier

Adds `.select()` to the Supabase `update` operation for posts to return affected rows, throwing a 404 error if empty. This fixes an IDOR vulnerability where unowned post updates silently passed, allowing unauthorized deletion and insertion of keyword associations in subsequent queries.

Co-authored-by: Sparkier <5690524+Sparkier@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 Aug 1, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
vis-positions Ready Ready Preview Aug 1, 2026 11:14am

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