Skip to content

[BUG]: Referral route auth middleware mismatch #251

Closed

Description

@Aditya8369

Issue Details

Where: backend/routes/referral.routes.js, backend/controllers/referral.controller.js
Problem: router.post('/:id/apply', authenticate, isStudent, applyForReferral) requires student. But applyForReferral also checks currentUser.type !== 'student'. That’s redundant; more importantly, other endpoints that should be role-gated are only authenticate (e.g., sendReferralMessage, getReferralTimeline, getReferralById).
Impact: Potential privilege escalation (authenticated non-owners/non-applicants hitting endpoints).
Fix steps
Add authorization checks (or reuse getReferralAccess) consistently in getReferralTimeline and getReferralById.
Consider splitting routes by access role (poster/applicant/admin).
Keep server-side checks as source of truth; don’t rely on frontend.

Activity

  1. Aditya8369 commented on Jun 1, 2026

    @Aditya8369
    ContributorAuthor

    @omkarhole please assign me this

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

Metadata

Metadata

Assignees

Labels

NSOC'26Issues for the NSOC 2026 programblankUncategorized issue template

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions