CSRF When Disliking an Answer
Categories
(support.mozilla.org :: General, defect)
Tracking
(Not tracked)
People
(Reporter: roldanbrandon62, Assigned: leo)
References
()
Details
(Keywords: reporter-external, sec-moderate, wsec-csrf, Whiteboard: [reporter-external] [web-bounty-form] [verif?])
SUMMARY
The function for voting an answer, works for any request method. This makes it vulnerable to csrf, since get is allowed and get requests has no csrf protection. We can only dislike an answer, since to like an answer, we need to supply a helpful post parameter, which we cant in a get request. The endpoint is
re_path(
r"^/(?P<question_id>\d+)/vote/(?P<answer_id>\d+)$",
views.answer_vote,
name="questions.answer_vote",
),
Combine this with the ability to add img tags in a comment/profile, and we have a on site request forgery that also bypasses the same-site lax.
STEPS TO REPRODUCE
- Have Three Accounts, we will call these three users as user a, user b, and user c
- As user a, make a new question
- As user b, Answer that question. Take note of the id of the question and the id of the answer of user b
- As user c, also make a comment, on it, put
<img src="/en-US/questions/<questionID>/vote/<answerID>">. Replace questionID with the id of user a's question, and replace answerID with user b's answer ID - Now whoever, viewed the answer of user c, will dislike the answer of user b, without them knowing.
POC
Updated•4 years ago
|
Updated•4 years ago
|
Comment 1•4 years ago
•
|
||
Hello,
Thank you for your report.
I can confirm that the voting endpoint supports GET method as well as the POST method and could be vulnerable to CSRF.
One interesting thing I noticed is that a user can only vote once on the answer, except when the user is the one who posted the answer, in this case, they can vote as many times as they want.
Thanks,
Frida
| Reporter | ||
Comment 2•4 years ago
|
||
Awesome, Thanks
| Assignee | ||
Updated•4 years ago
|
Updated•4 years ago
|
| Assignee | ||
Comment 3•4 years ago
|
||
Thanks for this report, I looked into all our uses of the @csrf_exempt decorator and determined that in all but one case we didn't need it.
A fix for this, and those other uses, has been deployed to our staging instance (https://support.allizom.org).
| Reporter | ||
Comment 4•4 years ago
|
||
awesome
| Reporter | ||
Comment 5•4 years ago
|
||
I did also reported the other endpoints with csrf_exempt, but it looks like this fix has also fixed that report. lol
Comment 6•4 years ago
|
||
Hello Leo,
I can confirm that the issue is fixed on staging, I now get 405 method not allowed error when sending the request:
GET /en-US/questions/1207227/vote/1082700 HTTP/2
Host: support.allizom.org
Can you please let us know when the fix is deployed to production?
Thanks,
Frida
| Assignee | ||
Comment 7•4 years ago
|
||
Thanks, this was deployed to production earlier today.
Updated•4 years ago
|
Updated•4 years ago
|
Updated•2 years ago
|
Description
•