Skip to content

Fix IDOR vulnerability in saved_views API (Fixes #1761)#2045

Open
YUVRAJ-SINGH-3178 wants to merge 3 commits into
utksh1:mainfrom
YUVRAJ-SINGH-3178:fix-1761-saved-views-idor
Open

Fix IDOR vulnerability in saved_views API (Fixes #1761)#2045
YUVRAJ-SINGH-3178 wants to merge 3 commits into
utksh1:mainfrom
YUVRAJ-SINGH-3178:fix-1761-saved-views-idor

Conversation

@YUVRAJ-SINGH-3178

@YUVRAJ-SINGH-3178 YUVRAJ-SINGH-3178 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Hey! This PR fixes the IDOR vulnerability reported in #1761.

Previously, anyone could mess with other users' saved views by guessing the view ID. To fix this, I completely locked down the saved_views API so everything is strictly scoped to the authenticated user.

Here's what I did:

  • Database: Added an owner_id column to the saved_views table and made the UNIQUE constraint apply to (owner_id, name) instead of just globally on the name.
  • Migration: Wrote a seamless startup migration in database.py that will upgrade the schema and backfill existing views to a default owner so older setups don't break.
  • API Lockdown: Injected the get_current_owner auth dependency into all the routes in saved_views.py and updated every single SQL query (SELECT, INSERT, UPDATE, DELETE) to use WHERE owner_id = ?.

Users can now only touch their own stuff. Let me know if you want any changes!

@utksh1 utksh1 added level:advanced 55 pts difficulty label for advanced contributor PRs type:security Security work category bonus label type:bug Bug fix work category bonus label area:backend Backend API, database, or service work area:security Security-sensitive implementation or tests labels Jul 24, 2026

@utksh1 utksh1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This saved-views IDOR branch has merge conflicts and overlaps the active saved-view ownership work. Please rebase onto current main, resolve against the current migration sequence, and add two-owner API regression coverage before re-review.

@utksh1 utksh1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This saved-views IDOR branch has merge conflicts and overlaps the active saved-view ownership work. Please rebase onto current main, resolve against the current migration sequence, and add two-owner API regression coverage before re-review.

@YUVRAJ-SINGH-3178
YUVRAJ-SINGH-3178 force-pushed the fix-1761-saved-views-idor branch from 97f75ad to e62ecde Compare July 24, 2026 13:14
@YUVRAJ-SINGH-3178

Copy link
Copy Markdown
Contributor Author

I've updated the PR with the following fixes:

  • Added strict cross-owner isolation tests to verify 403 Forbidden is returned when accessing another owner's view.
  • Fixed test auth mocks so they properly test our IDOR protections.
  • Resolved migration conflicts with main to keep the DB schema clean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend Backend API, database, or service work area:security Security-sensitive implementation or tests level:advanced 55 pts difficulty label for advanced contributor PRs type:bug Bug fix work category bonus label type:security Security work category bonus label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants