Make releaseAllGrades, withdrawAllGrades, etc. POST to prevent CSRF attacks#1512
Make releaseAllGrades, withdrawAllGrades, etc. POST to prevent CSRF attacks#151220wildmanj merged 3 commits intomasterfrom
Conversation
|
I'm assuming that you have tested to ensure that releaseAllGrades and withdrawAllGrades still work? |
damianhxy
left a comment
There was a problem hiding this comment.
Checked that GET routes no longer exist, and POST routes work as expected.
However, it seems that CSRF protection isn't working -- even after deleting the authenticity_token fields in a form (or filling them with garbage) and submitting, the request still succeeds. This needs further investigation
Both methods still work, has been tested.
I can confirm that CSRF doesn't seem to be working as intended. I first tried using postman to send a POST request, which actually failed (didn't release grades), but by making just an html file with a form and using that to send a POST request, I was able to release all grades without being on autolab. This definitely seems to be a bit more tricky than originally thought. |
| action_auth_level :set_repo, :instructor | ||
| action_auth_level :import_svn, :instructor | ||
|
|
||
| protect_from_forgery with: :exception |
There was a problem hiding this comment.
Would be good to figure out why protect_from_forgery inside application_controller.rb isn't sufficient


This PR aims to fix the CSRF vulnerability for 'releaseAllGrades' along with other vulnerable endpoints that previously used GET requests instead of POST.
Thanks to Damien and Fan Pu for the discussion about the security flaw and the useful article here about CSRF and rails:
https://guides.rubyonrails.org/security.html#csrf-countermeasures
Description
assessment page to be POST requests, from GET requests.
the style of the other actions on the page
Motivation and Context
We were sent this issue by huntr.dev, where a contributor pointed out this flaw.
How Has This Been Tested?
Tested mainly through local host, seeing if we can directly access
http://localhost:3000/courses/AutoPopulated/assessments/homework0/releaseAllGradesfrom the browser, which should no longer work (should get an error saying there doesn't exist a GET request with that endpoint).Types of changes
Checklist:
overcommit --install && overcommit --signto use pre-commit hook for lintingOther issues / help required
@damianhxy