Skip to content
CSRF Disclosed report Beginner

CSRF When Disliking an Answer

The answer voting endpoint accepted any HTTP method, including GET, which lacked CSRF protection. An attacker could embed an image tag pointing to the dislike URL in a comment, causing any viewer to unknowingly dislike a target answer.

roldanbrandon62 Follow

Originally disclosed on Mozilla

  • Fixed in 7 days
  • Paid in 13 days
  • Disclosed after 7 days

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

Python
    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

The original report as published on Mozilla's Bugzilla, by roldanbrandon62. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The voting endpoint did not restrict HTTP methods and did not enforce CSRF protection on GET requests.

Impact

An attacker could cause any user who views a crafted comment to dislike a targeted answer without their knowledge, and the attack bypasses the SameSite Lax cookie protection.

What the attacker needed

Three user accounts; ability to post comments with images; victim views the malicious comment

The fix

The endpoint should only accept POST requests and require a valid CSRF token for state-changing actions.

How it was found

  1. Create three accounts: user a, user b, and user c.
  2. As user a, create a new question.
  3. As user b, answer that question and note the question and answer IDs.
  4. As user c, post a comment containing an image tag whose source points to the vote URL with the question and answer IDs.
  5. Anyone who views user c's comment will dislike user b's answer without knowing.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

Websites often use a secret token to ensure that actions like voting are done intentionally by the user, not by a malicious site. Here, the voting action could be triggered by simply loading an image, so anyone viewing a comment with that image would cast a vote without realising it.

What is CSRF?

Another site makes a signed-in user's browser perform an action they did not intend.

More by roldanbrandon62

View all

5 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site request forgery (CSRF)

The lesson behind this report.

Another site makes a signed-in user's browser perform an action they did not intend.