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

Examples should limit requests to POST #90

Closed
dogben opened this issue Jun 20, 2018 · 1 comment
Closed

Examples should limit requests to POST #90

dogben opened this issue Jun 20, 2018 · 1 comment
Assignees

Comments

@dogben
Copy link

dogben commented Jun 20, 2018

In the examples in the documentation at https://github.com/gorilla/csrf/blob/master/README.md and https://github.com/gorilla/csrf/blob/master/doc.go, the handlers do not check that the request method is POST (or other modification request types).

According to the documentation, this package "[o]perates on a 'whitelist only' approach where safe (non-mutating) HTTP methods (GET, HEAD, OPTIONS, TRACE) are the only methods where token validation is not enforced." However, the method used is decided by the client, so unless the server disallows these whitelisted requests, the CSRF protection can be bypassed by changing the method to a GET.

E.g. with the attached example:

go run csrf-example.go&
curl -X GET http://localhost:8000/delete/foo
You've passed the CSRF check!
Deleting foo

Perhaps people should know that they need to check the request method when there's no body, but it would be good to remind people of this by including the check in the examples for this package.
csrf-example.txt

@elithrar
Copy link
Contributor

elithrar commented Jun 20, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants