Skip to content
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

Potential Security Vulnerability in X-Forwarded-* Headers for auth-js Introduced in #549 #817

Open
catnaut opened this issue Nov 9, 2024 · 0 comments · May be fixed by #818
Open

Potential Security Vulnerability in X-Forwarded-* Headers for auth-js Introduced in #549 #817

catnaut opened this issue Nov 9, 2024 · 0 comments · May be fixed by #818

Comments

@catnaut
Copy link

catnaut commented Nov 9, 2024

A potential security risk may have been introduced in #549 while addressing #537. Specifically, using X-Forwarded-* headers in @auth/core could enable spoofing if the headers are tampered with.

I reviewed the implementation of @auth/core for the /api/auth/signin page. The render function in src/lib/pages/index.ts uses the signin method to generate the form, setting the callbackUrl from request.url.origin.

(Additionally, this could indicate an internal issue in @auth/core itself: params.callbackUrl ?? "/" defaults to /, even though callbackUrl is already set as request.url.origin.)

Although beorn’s solution is technically correct, it introduces potential security risks. This approach could be exploited if users spoof the HTTP X-Forwarded-For header, potentially creating security vulnerabilities. I think handling the actual request data is better managed through a transparent middleware, such as honojs/hono#3646.

By the way, Hono team are working on discussion the Proxy Helper for the proxy use case to avoid the user writing code for copying headers: honojs/hono#3589

@catnaut catnaut linked a pull request Nov 9, 2024 that will close this issue
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 a pull request may close this issue.

1 participant