-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Description
As pointed out in issue #4703 (content deleted now), it is a csrf vulnerability to allow users to access api routes using session cookie without second check.
Currently the CSRF middleware only checks POST requests, and skips API routes. In addition, the reqToken function in routers/api/v1/api.go accepts all signed in users, including authenticated with session cookie. This means a script can make a POST/DELETE request to api routes while user is logged in (cookie present), without user's knowledge or consent. This is not desirable in multi tenant environment.
We have implemented some extra checks internally to limit api routes to access by token/basic auth only, and prohibit access by cookie when the route requires token. This does not affect public routes.
We have searched the code base and haven't found any client side Javascript code accessing protected api routes with cookie. But maybe there are cases we are not aware.
Is this the right approach? Will a PR like this break someone's code in the pipeline (if merged)?