-
Notifications
You must be signed in to change notification settings - Fork 0
🛡️ Sentinel: [CRITICAL] Fix Host Header Injection in Auth Callback #781
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
🛡️ Sentinel: [CRITICAL] Fix Host Header Injection in Auth Callback #781
Conversation
Refactored `resolveRedirectPath` in `src/app/auth/callback/route.ts` to strictly validate redirect URLs against the configured `NEXT_PUBLIC_SITE_URL` via `getSiteUrl()`. This prevents Host Header Injection attacks where a malicious `X-Forwarded-Host` header could redirect users to an attacker-controlled domain. - Modified `resolveRedirectPath` to ignore `origin` and `forwardedHost` inputs and use `getSiteUrl()` instead. - Updated `GET` handler to use `getSiteUrl()` for constructing the base redirect URL. - Updated tests in `src/app/auth/callback/route.test.ts` to reflect the new signature and verify security against spoofed hosts. - Removed `package-lock.json` as the project uses pnpm.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Pull request overview
This PR addresses a critical Host Header Injection vulnerability in the authentication callback route. Previously, the code trusted X-Forwarded-Host or origin headers, which could allow attackers to redirect authenticated users to malicious sites by spoofing headers.
Changes:
- Refactored
resolveRedirectPathto validate redirects strictly against the configuredNEXT_PUBLIC_SITE_URLinstead of trusting request headers - Updated the
GEThandler to consistently usegetSiteUrl()for all redirect URL construction - Enhanced unit tests to verify the new security behavior with proper environment variable mocking
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/app/auth/callback/route.ts | Removed header-based host validation, now uses configured site URL exclusively for redirect validation and construction |
| src/app/auth/callback/route.test.ts | Updated tests to mock NEXT_PUBLIC_SITE_URL and validate that only matching hosts are accepted, rejecting forwarded hosts |
| // getSiteUrl() typically does not have trailing slash, but good to be safe. | ||
| // Actually getSiteUrl implementation: return `...` (no trailing slash usually). | ||
| // But redirectPath from resolveRedirectPath always starts with / due to isInternalUrl check. |
Copilot
AI
Jan 18, 2026
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.
These comments are verbose and somewhat redundant. The first sentence makes the point, but then it goes on to explain implementation details that are already evident from the code itself. Consider simplifying to just the key insight: "Ensure redirectPath starts with / to avoid double slashes if siteUrl has trailing slash".
| // getSiteUrl() typically does not have trailing slash, but good to be safe. | |
| // Actually getSiteUrl implementation: return `...` (no trailing slash usually). | |
| // But redirectPath from resolveRedirectPath always starts with / due to isInternalUrl check. |
timothyfroehlich
left a comment
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.
@jules Critical security fix for Host Header Injection vulnerability in auth callback. All CI checks passing.
This PR addresses a Host Header Injection vulnerability in the authentication callback route.
Previously, the
resolveRedirectPathfunction trustedX-Forwarded-Hostororiginheaders to validate and construct redirect URLs. This could allow an attacker to spoof the host header and redirect authenticated users to a malicious site.The fix involves:
resolveRedirectPathto strictly validate the redirect target against the trustedNEXT_PUBLIC_SITE_URL(retrieved viagetSiteUrl()).GEThandler to usegetSiteUrl()when constructing the absolute redirect URL.NEXT_PUBLIC_SITE_URL.This ensures that redirects always go to the configured application domain.
Additionally,
package-lock.jsonwas removed as the project usespnpm.PR created automatically by Jules for task 17823098564230585764 started by @timothyfroehlich