Skip to content

Fix: Resolve IDOR on Fetching Replies API#276

Merged
knoxiboy merged 5 commits into
knoxiboy:mainfrom
riddhima25bet10005-a11y:fix-268
May 26, 2026
Merged

Fix: Resolve IDOR on Fetching Replies API#276
knoxiboy merged 5 commits into
knoxiboy:mainfrom
riddhima25bet10005-a11y:fix-268

Conversation

@riddhima25bet10005-a11y
Copy link
Copy Markdown
Contributor

Description

Fixes an Insecure Direct Object Reference (IDOR) vulnerability in the \GET /api/replies\ endpoint where an unauthenticated or unauthorized user could fetch replies of private doubts belonging to classrooms they were not enrolled in.

The endpoint now correctly validates the classroom membership of the requesting user when fetching replies for a classroom-scoped doubt.

Fixes #268

Changes Made

  • Added classroom membership validation check in \�pp/api/replies/route.ts\
  • Included \membershipsTable\ in the Drizzle schema imports
  • Also resolved a test suite syntax error in \�ote/route.ts\ to ensure CI passes

Checklist

  • I have tested my changes locally
  • I have followed the GSSoC '26 contribution guidelines
  • The code is clean and well-documented

@vercel
Copy link
Copy Markdown

vercel Bot commented May 24, 2026

@riddhima25bet10005-a11y is attempting to deploy a commit to the Karan Mani Tripathi 's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot requested a review from knoxiboy May 24, 2026 13:33
@github-actions github-actions Bot added gssoc gssoc'26 GSSoC program issue type:bug Bug fix labels May 24, 2026
@riddhima25bet10005-a11y
Copy link
Copy Markdown
Contributor Author

Hey @knoxiboy
Kindly review and approve.

@knoxiboy knoxiboy removed the gssoc label May 24, 2026
@knoxiboy knoxiboy added the level:advanced Advanced level task label May 24, 2026
@riddhima25bet10005-a11y
Copy link
Copy Markdown
Contributor Author

@knoxiboy reviewed?

Copy link
Copy Markdown
Owner

@knoxiboy knoxiboy left a comment

Choose a reason for hiding this comment

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

Automated review: Thank you for starring the repository! The PR is approved.

Note: This PR currently has merge conflicts with the main branch. Please resolve the merge conflicts so we can complete the merge!

@knoxiboy knoxiboy removed the size:s label May 25, 2026
@riddhima25bet10005-a11y
Copy link
Copy Markdown
Contributor Author

Hey @knoxiboy
I have resolved the conflicts in base branch.
Kindly review and merge.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 aims to fix an IDOR vulnerability in GET /api/replies by enforcing classroom membership checks before returning replies for classroom-scoped doubts. It also includes unrelated UI updates to the site footer.

Changes:

  • Added a classroom membership authorization check to GET /api/replies for doubts with classroomId.
  • Updated the footer component formatting and added new “Resources” links (e.g., Public Doubts, Bookmarks).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
app/api/replies/route.ts Adds classroom membership validation to prevent unauthorized access to replies for classroom-scoped doubts.
components/Footer.tsx Adds new footer links and refactors rendering/styling/accessibility attributes.
Comments suppressed due to low confidence (1)

components/Footer.tsx:35

  • This file includes user-facing footer/navigation changes (new Resources links and styling tweaks), but the PR description only mentions the replies IDOR fix and a test syntax fix. Please either update the PR description to include this UI change or split it into a separate PR to keep the security fix reviewable/auditable.
    {
      title: "Resources",
      links: [
        { label: "Public Doubts", href: "/public-rooms" },
        { label: "Bookmarks", href: "/bookmarks" },
        { label: "Privacy Policy", href: "/privacy-policy" },
        { label: "Terms of Service", href: "/terms-of-service" },
        { label: "About", href: "/about" },
        { label: "FAQs", href: "/faq" },
      ],

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/api/replies/route.ts
Comment on lines +46 to +48
const [membership] = await db.select().from(membershipsTable).where(
and(eq(membershipsTable.userEmail, email), eq(membershipsTable.classroomId, doubt.classroomId))
);
Comment thread app/api/replies/route.ts
Comment on lines +52 to +54
} else if (doubt.classroomId && !email) {
console.warn(`Anonymous user attempting to access replies for doubt ${doubtId} in classroom ${doubt.classroomId}`);
}
Comment thread app/api/replies/route.ts
Comment on lines +45 to +51
if (doubt.classroomId && email) {
const [membership] = await db.select().from(membershipsTable).where(
and(eq(membershipsTable.userEmail, email), eq(membershipsTable.classroomId, doubt.classroomId))
);
if (!membership) {
return NextResponse.json({ error: "Access denied to this classroom's doubt replies" }, { status: 403 });
}
@knoxiboy
Copy link
Copy Markdown
Owner

Hi there! 👋 Thanks for your contribution to DoubtDesk.

It looks like there are currently some merge conflicts between your branch and the main branch. Could you please pull the latest changes from main, resolve the conflicts, and push the updates to this branch?

Once the conflicts are resolved and the PR is clean, we'll be able to merge it!

@github-actions github-actions Bot added size/m and removed size/l labels May 25, 2026
@riddhima25bet10005-a11y
Copy link
Copy Markdown
Contributor Author

Hey @knoxiboy
From my side I have resolved the branch conflicts.
Kindly confirm.

@knoxiboy knoxiboy merged commit 540108d into knoxiboy:main May 26, 2026
3 of 4 checks passed
@github-actions github-actions Bot added gssoc:approved Approved for GSSoC mentor:knoxiboy Reviewed by mentor knoxiboy quality:clean Clean code quality and removed size/m labels May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved Approved for GSSoC gssoc'26 GSSoC program issue level:advanced Advanced level task mentor:knoxiboy Reviewed by mentor knoxiboy quality:clean Clean code quality type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IDOR on Fetching Replies (GET /api/replies)

3 participants