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

Certain API endpoints are vulnerable against CSRF attacks. #687

Open
svgils opened this issue Jan 11, 2024 · 1 comment
Open

Certain API endpoints are vulnerable against CSRF attacks. #687

svgils opened this issue Jan 11, 2024 · 1 comment
Labels
api security Something causes a potential security risk

Comments

@svgils
Copy link
Collaborator

svgils commented Jan 11, 2024

API endpoints that both enable CORS and allow every (*) origin, as well as require authentication, are susceptible to Cross Site Request Forgery attacks.
This can happen since the browser will attach the authentication cookies to every request to the LXCat domain. By allowing every origin, this can give malicious 3rd parties access to unauthorized data through the use of the logged in users' credentials.

Possible solutions:

  1. Use (anti)-CSRF tokens. These tokens get sent when a session is created (not as a cookie!), and are added to the query part of the request URL. This works since scripts on 3rd party domains do not have access to this token, and thus can not add the correct token to the request.
  2. Ignore session cookies when the request origin is foreign, only accept access token. ( Would still be susceptible to origin spoofing. Although browsers don't allow this, man in the middle attacks are still a risk. )
@svgils svgils added security Something causes a potential security risk api labels Jan 11, 2024
@svgils
Copy link
Collaborator Author

svgils commented Jan 11, 2024

It seems there is already a csrf-token cookie present besides the session-token, and both cookies have the SameSite policy set to Lax, meaning it will only be included with requests originating from the LXCat domain. However, since older browsers might not have support for the SameSite cookie policy, it might still be necessary to move the csrf-token out of the cookies.
Current support for SameSite encompasses approximately 95% of all users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api security Something causes a potential security risk
Projects
None yet
Development

No branches or pull requests

1 participant