Idor in Image Upload in support.mozilla.org
The image upload endpoint looked up the target object by a model name and primary key taken straight from the URL, without checking that the object belonged to the requesting user. Because one allowed model was the user model, an attacker could change the profile image of any other user by supplying that user's identifier.
Originally disclosed on Mozilla
- Fixed in 3 months
- Paid in 3 months
- Disclosed after 3 months
Hi. While auditing the code of support.mozilla.org, i found this endpoint
'''
re_path(
r"^/image/(?P<model_name>\w+\.\w+)/(?P<object_pk>\d+)$",
views.up_image_async,
name="upload.up_image_async",
),
'''
This is the up_image_async function
'''python
def up_image_async(request, model_name, object_pk):
"""Upload all images in request.FILES."""
# Verify the model agaist our white-list
if model_name not in ALLOWED_MODELS:
message = _("Model not allowed.")
return HttpResponseBadRequest(json.dumps({"status": "error", "message": message}))
# Get the model
m = apps.get_model(*model_name.split("."))
# Then look up the object by pk
try:
obj = m.objects.get(pk=object_pk)
except ObjectDoesNotExist:
message = _("Object does not exist.")
return HttpResponseNotFound(json.dumps({"status": "error", "message": message}))
try:
file_info = upload_imageattachment(request, obj)
except FileTooLargeError as e:
return HttpResponseBadRequest(json.dumps({"status": "error", "message": e.args[0]}))
if hasattr(obj, "clear_cached_images"):
# if the object the image is attached to has a `clear_cached_images` method,
# like questions and answers do, call it
obj.clear_cached_images()
if isinstance(file_info, dict) and "thumbnail_url" in file_info:
return HttpResponse(json.dumps({"status": "success", "file": file_info}))
message = _("Invalid or no image received.")
return HttpResponseBadRequest(
json.dumps({"status": "error", "message": message, "errors": file_info})
)
'''
Here, it get the object, with the model we provided, based on its pk in the object_pk argument. The model could be either of these three "questions.Question", "questions.Answer", "auth.User". and call the upload_imageattachment function on the target object.
Since one of the model is auth.User, we can change the image of other users. There are also models like questions.Question and questions.Answer but cant test it since the site is down
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
Likely the upload view fetched the object purely from the model name and primary key in the URL and never verified that the current user owned or was allowed to modify that object.
Impact
An attacker could overwrite the profile image of any other user, which could be used for impersonation or harassment; the author could not test the question and answer models because the site was down.
What the attacker needed
A free account; knowing a target user's identifier
The fix
The view should check that the requesting user is permitted to modify the looked-up object before attaching any uploaded image.
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.
A website often puts an identifier in the address, such as a number for a photo or a user. If the server trusts that number and does not check that the item belongs to you, you can swap in someone else's number and act on their data. This is called an insecure direct object reference, or IDOR: the site refers to things by a guessable name and forgets to check who is asking.
What is IDOR?
One user can read or change another user's data, usually by changing an identifier the server trusts without checking who is asking. One of the most paid bug classes on web programs.