CVE-2021-3964 (published 2021-12-01T12:15Z)

elgg is vulnerable to Authorization Bypass Through User-Controlled Key

Severity: MEDIUM
CVSS v2 base score: 4.3 (AV:N/AC:M/Au:N/C:N/I:P/A:N)
CVSS v3 base score: 5.9, MEDIUM (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N)

Weakness information:
cwe_id: CWE-639
cwe_name: Authorization Bypass Through User-Controlled Key
description: The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.
extended_description: 
            Retrieval of a user record occurs in the system based on some key value that is under user control. The key would typically identify a user-related record stored in the system and would be used to lookup that record for presentation to the user. It is likely that an attacker would have to be an authenticated user in the system. However, the authorization process would not properly check the data access operation to ensure that the authenticated user performing the operation has sufficient entitlements to perform the requested data access, hence bypassing any other authorization checks present in the system.
            For example, attackers can look at places where user specific data is retrieved (e.g. search screens) and determine whether the key for the item being looked up is controllable externally. The key may be a hidden field in the HTML form field, might be passed as a URL parameter or as an unencrypted cookie variable, then in each of these cases it will be possible to tamper with the key value.
            One manifestation of this weakness is when a system uses sequential or otherwise easily-guessable session IDs that would allow one user to easily switch to another user's session and read/modify their data.
         
         

Fix information:
repo_url: https://github.com/elgg/elgg
commit_details: repo_url: https://github.com/elgg/elgg
author: Jerôme Bakker
author_date: 2021-11-16 10:29:30+01:00
msg: fix(groups): prevent misuse of group membership actions

Only allow actions to be executed for authorised requests.
repository: repo_url: https://github.com/elgg/elgg
repo_name: Elgg/Elgg
description: A social networking engine in PHP/MySQL
repo_language: PHP
owner: elgg
file_changes: filename: delete_invite.php
change_type: ModificationType.MODIFY
diff: @@ -13,8 +13,12 @@ $group = elgg_call(ELGG_IGNORE_ACCESS, function() use ($group_guid) {
 	return get_entity($group_guid);
 });
 
-if (!$user && !($group instanceof \ElggGroup)) {
-	return elgg_error_response();
+if (!$user && !$group instanceof \ElggGroup) {
+	return elgg_error_response(elgg_echo('error:missing_data'));
+}
+
+if (!$user->canEdit() && !$group->canEdit()) {
+	return elgg_error_response(elgg_echo('actionunauthorized'));
 }
 
 // If join request made

programming_language: PHP
filename: delete_request.php
change_type: ModificationType.MODIFY
diff: @@ -9,8 +9,12 @@ $group_guid = (int) get_input('group_guid');
 $user = get_user($user_guid);
 $group = get_entity($group_guid);
 
-if (!$user && !($group instanceof \ElggGroup)) {
-	return elgg_error_response();
+if (!$user && !$group instanceof \ElggGroup) {
+	return elgg_error_response(elgg_echo('error:missing_data'));
+}
+
+if (!$user->canEdit() && !$group->canEdit()) {
+	return elgg_error_response(elgg_echo('actionunauthorized'));
 }
 
 // If join request made

programming_language: PHP
filename: join.php
change_type: ModificationType.MODIFY
diff: @@ -18,10 +18,14 @@ $group = elgg_call(ELGG_IGNORE_ACCESS, function() use ($group_guid) {
 	return get_entity($group_guid);
 });
 
-if (!$user || !($group instanceof \ElggGroup)) {
+if (!$user || !$group instanceof \ElggGroup) {
 	return elgg_error_response(elgg_echo('groups:cantjoin'));
 }
 
+if (!$user->canEdit() && !$group->canEdit()) {
+	return elgg_error_response(elgg_echo('actionunauthorized'));
+}
+
 // join or request
 $join = false;
 if ($group->isPublicMembership() || $group->canEdit($user->guid)) {

programming_language: PHP
filename: leave.php
change_type: ModificationType.MODIFY
diff: @@ -9,10 +9,14 @@ $group_guid = (int) get_input('group_guid');
 $user = get_user($user_guid);
 $group = get_entity($group_guid);
 
-if (!$user || !($group instanceof \ElggGroup)) {
+if (!$user || !$group instanceof \ElggGroup) {
 	return elgg_error_response(elgg_echo('groups:cantleave'));
 }
 
+if (!$user->canEdit() && !$group->canEdit()) {
+	return elgg_error_response(elgg_echo('actionunauthorized'));
+}
+
 if ($group->getOwnerGUID() === $user->guid) {
 	// owner can't be removed
 	return elgg_error_response(elgg_echo('groups:cantleave'));

programming_language: PHP