Privilege Escalation/IDOR allowing anyone to delete and add tags in a question
An API endpoint for removing tags from a question was missing the permission check that the equivalent web view enforced, so any authenticated user could delete tags on any question. The report also claims the same gap allows adding tags, though only the removal code is shown.
Originally disclosed on Mozilla
- Fixed in 3 months
- Paid in 3 months
- Disclosed after 3 months
SUMMARY
Hi. Normally, the questions.tag_question permission is needed when deleting a tag in a question. Normal users doesnt have this permission. However, i found out, that in the api endpoint, it also allows us to delete tags, and it is missing the permission checks
This is the function for removing a tag
@action(
detail=True, methods=["post", "delete"], permission_classes=[permissions.IsAuthenticated]
)
def remove_tags(self, request, pk=None):
question = self.get_object()
if "tags" not in request.data:
return Response(
{"tags": "This field is required."}, status=status.HTTP_400_BAD_REQUEST
)
tags = request.data["tags"]
for tag in tags:
question.tags.remove(tag)
return Response(status=status.HTTP_204_NO_CONTENT)
As you can see, it lacks the permission check. Here is the original request
@permission_required("questions.tag_question")
@require_POST
def remove_tag(request, question_id):
# FUNCTION BODY HERE
This allow anyone to delete tags in anyone's question
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 API action was declared with only an authentication check and no permission check, unlike the original view which required the tag_question permission.
Impact
Any authenticated user could remove tags from any question, and the report claims tags could also be added, bypassing the intended permission restriction.
What the attacker needed
An authenticated account
The fix
The endpoint should enforce the same tag_question permission as the original view before changing tags.
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.
Some actions on a website are meant to be limited to certain users, and the site checks this before doing them. Here, one way of reaching the same action (an API endpoint) skipped that check, so any logged-in person could change tags on other people's questions. A tag is just a label attached to a post.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.