Неправильно Controlled Modification из Dynamically-Determined Object Attributes (CWE-915) в CourseWriteSerializer (backend/apps/classroom/serializers.py из The Hackers Labs Academy позволяет пользователю, выполняющему роль инструктора, владеющему курсом, переназначить этот курс на любую другую учетную запись через PATCH в /api/classroom/courses/<id>/edit/, несущую значение инструктора. Сериализатор перечисляет инструктора в Meta.fields, в то время как Meta.read_only_fields содержит только id и slug, поэтому поле является записываемым. IsAdminOrOwnerInstructor уполномочивает того, кто может отправить запрос, владельца инструктора или администратора, и он запускается до обновления, но он не ограничивает, какие атрибуты объекта авторизованный запрос может изменить. Внешний ключ Course.instructor не содержит limit_choices_to, поэтому целью может быть любой идентификатор пользователя, включая учетную запись, которая не выполняет роль инструктора, и принимающая учетная запись не принимает участия в изменении.
Как только значение изменилось, IsAdminOrOwnerInstructor решает право собственности на новое значение по следующему запросу, поэтому первоначальному владельцу отказывают в доступе к редактированию курса. Это приводит к тому, что атрибут владения курсом устанавливается на значение, которое запрашивающий не имеет права устанавливать без согласия учетной записи, на которую он установлен.
Показать оригинальное описание (EN)
Improperly Controlled Modification of Dynamically-Determined Object Attributes (CWE-915) in CourseWriteSerializer (backend/apps/classroom/serializers.py) of The Hackers Labs Academy allows a user holding the instructor role who owns a course to reassign that course to any other account, through a PATCH to /api/classroom/courses/<id>/edit/ carrying an instructor value. The serializer lists instructor in Meta.fields while Meta.read_only_fields holds only id and slug, so the field is writable. IsAdminOrOwnerInstructor authorises who may issue the request, the owning instructor or an admin, and it runs before the update, but it does not restrict which attributes of the object an authorised request may change. The Course.instructor foreign key carries no limit_choices_to, so the target may be any user id, including an account that does not hold the instructor role, and the receiving account takes no part in the change. Once the value has changed, IsAdminOrOwnerInstructor resolves ownership from the new value on the next request, so the original owner is refused edit access to the course. This results in the ownership attribute of a course being set to a value the requester is not authorised to set, without the consent of the account it is set to.
Характеристики атаки
Последствия
Строка CVSS v4.0