Skip to content

fix: remove duplicate imports and routes in authRoutes.js - #1201

Open
saidai-bhuvanesh wants to merge 1 commit into
Nitya-003:mainfrom
saidai-bhuvanesh:fix/duplicate-imports-routes-authRoutes
Open

fix: remove duplicate imports and routes in authRoutes.js#1201
saidai-bhuvanesh wants to merge 1 commit into
Nitya-003:mainfrom
saidai-bhuvanesh:fix/duplicate-imports-routes-authRoutes

Conversation

@saidai-bhuvanesh

@saidai-bhuvanesh saidai-bhuvanesh commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #1202

backend/routes/authRoutes.js registered the wallet-authentication and profile routes twice:

Route First registration (kept) Second registration (removed)
GET /nonce authLimiter bare, no limiter ❌
POST /wallet-login authLimiter bare, no limiter ❌
POST /wallet-register registerLimiter bare, no limiter ❌
POST /set-fallback-password protect bare ❌
PUT /profile documented ✅ bare ❌

Only DELETE /profile was unique to the second block.

Why this is a security issue

Express matches routes in registration order, but the second (bare) block re-registered the rate-limited wallet routes without their limiters. Re-registration creates a shadow path an attacker can hit to brute-force wallet authentication / nonce enumeration without throttling — exactly the abuse the authLimiter/registerLimiter middleware exists to prevent. It is also a maintenance hazard (which handler actually runs?) and applies middleware twice.

Fix

Delete the entire duplicate single-quoted block (old lines 91–96), keeping:

  • the documented, rate-limiter-protected first definitions (/nonce, /wallet-login, /wallet-register, /set-fallback-password, PUT /profile), and
  • the unique DELETE /profile route (moved up next to PUT /profile).

Every route is now registered exactly once, with its rate limiter / protect middleware intact. node --check backend/routes/authRoutes.js passes.

Note: the separate parse-error issue #1197 (a bare { ... } = require(...) destructuring block) is no longer reproducible on main — the file already has a single const { ... } = require('../controllers/authController') import and parses cleanly. This PR is scoped to the duplicate-route defect in #1202.

Files

  • backend/routes/authRoutes.js

Security checklist

  • No new dependencies
  • No secrets / env changes
  • Rate limiting preserved on all wallet-auth routes

This PR was created by an AI agent (OpenHands) on behalf of @saidai-bhuvanesh.

@vercel

vercel Bot commented Aug 6, 2026

Copy link
Copy Markdown

@saidai-bhuvanesh is attempting to deploy a commit to the Nitya Gosain's projects Team on Vercel.

A member of the Team first needs to authorize it.

@saidai-bhuvanesh
saidai-bhuvanesh force-pushed the fix/duplicate-imports-routes-authRoutes branch from 81faf22 to f50de85 Compare August 8, 2026 16:58
backend/routes/authRoutes.js defined the wallet-auth and profile routes
twice — once with rate limiters (lines 68-76) and again as a bare
single-quoted block (lines 91-96) that re-registered /nonce,
/wallet-login, /wallet-register, /set-fallback-password and
PUT /profile without the swagger docs, leaving only DELETE /profile
unique. Duplicate route registration is a security and correctness
hazard: the second registration shadows the first and, for the
rate-limited wallet routes, an attacker could hit the unprotected
shadow route to brute-force wallet auth.

Remove the duplicate block entirely, keeping the documented,
rate-limiter-protected first definitions plus the unique
DELETE /profile route. Every wallet auth route now has exactly one
registration with its rate limiter intact.

Closes Nitya-003#1202
@saidai-bhuvanesh
saidai-bhuvanesh force-pushed the fix/duplicate-imports-routes-authRoutes branch from f50de85 to aefe0f1 Compare August 15, 2026 03:47
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.

[BUG] Duplicate imports and routes in backend/routes/authRoutes.js

1 participant