-
Notifications
You must be signed in to change notification settings - Fork 3.1k
fix(auth): added same-origin validation to forget password route, added confirmation for disable auth FF #2447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ed confirmation for disable auth FF
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryThis PR implements critical security improvements to prevent open redirect vulnerabilities in the password reset flow and adds safeguards for the Key Changes:
Security Impact: Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant ForgetPasswordAPI
participant ValidationSchema
participant isSameOrigin
participant getBaseUrl
participant AuthService
Client->>ForgetPasswordAPI: POST /api/auth/forget-password
Note over Client,ForgetPasswordAPI: { email, redirectTo }
ForgetPasswordAPI->>ValidationSchema: Validate request body
alt redirectTo is empty string or undefined
ValidationSchema->>ValidationSchema: Transform to undefined
else redirectTo has value
ValidationSchema->>ValidationSchema: Check if valid URL
ValidationSchema->>isSameOrigin: Validate same-origin
isSameOrigin->>getBaseUrl: Get app base URL
getBaseUrl-->>isSameOrigin: NEXT_PUBLIC_APP_URL
isSameOrigin->>isSameOrigin: Compare origins
alt Different origin
isSameOrigin-->>ValidationSchema: false
ValidationSchema-->>ForgetPasswordAPI: Validation error
ForgetPasswordAPI-->>Client: 400 - Invalid same-origin URL
else Same origin
isSameOrigin-->>ValidationSchema: true
end
end
ValidationSchema-->>ForgetPasswordAPI: Validation passed
ForgetPasswordAPI->>AuthService: Call forgetPassword API
AuthService-->>ForgetPasswordAPI: Success
ForgetPasswordAPI-->>Client: 200 - Success
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 files reviewed, 2 comments
74be085 to
23131d1
Compare
23131d1 to
b5240e3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5 files reviewed, 1 comment
Summary
Type of Change
Testing
Tested manually
Checklist