Closed Bug 1762103 Opened 4 years ago Closed 4 years ago

CSRF When Disliking an Answer

Categories

(support.mozilla.org :: General, defect)

defect

Tracking

(Not tracked)

RESOLVED FIXED

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

  1. Have Three Accounts, we will call these three users as user a, user b, and user c
  2. As user a, make a new question
  3. As user b, Answer that question. Take note of the id of the question and the id of the answer of user b
  4. 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
  5. Now whoever, viewed the answer of user c, will dislike the answer of user b, without them knowing.

POC

https://youtu.be/wbh95Pm-p9M

Flags: sec-bounty?
Status: UNCONFIRMED → NEW
Component: Other → General
Ever confirmed: true
Product: Websites → support.mozilla.org
Type: task → defect

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

Awesome, Thanks

Assignee: nobody → lmcardle

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).

awesome

I did also reported the other endpoints with csrf_exempt, but it looks like this fix has also fixed that report. lol

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

Thanks, this was deployed to production earlier today.

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Flags: sec-bounty? → sec-bounty+
Group: websites-security
You need to log in before you can comment on or make changes to this bug.