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.
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
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
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
- Create three accounts: user a, user b, and user c.
- As user a, create a new question.
- As user b, answer that question and note the question and answer IDs.
- As user c, post a comment containing an image tag whose source points to the vote URL with the question and answer IDs.
- 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.