CVE-2021-46249 (published 2022-02-15T23:15Z)

An authorization bypass exploited by a user-controlled key in SpecificApps REST API in ScratchOAuth2 before commit d856dc704b2504cd3b92cf089fdd366dd40775d6 allows app owners to set flags that indicate whether an app is verified on their own apps.

Severity: MEDIUM
CVSS v2 base score: 4.0 (AV:N/AC:L/Au:S/C:N/I:P/A:N)
CVSS v3 base score: 6.5, MEDIUM (CVSS:3.1/AV:N/AC:L/PR:L/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/ScratchVerifier/ScratchOAuth2
commit_details: repo_url: https://github.com/ScratchVerifier/ScratchOAuth2
author: apple502j
author_date: 2021-04-12 20:43:36+09:00
msg: SECURITY: Deny modification of flags using REST API
Authorization bypass by user-controlled key in SpecificApps REST API in 
ScratchOAuth2 allows app owners to set flags that indicate whether an 
app is verified on their own apps.
repository: repo_url: https://github.com/ScratchVerifier/ScratchOAuth2
repo_name: ScratchVerifier/ScratchOAuth2
description: Since Scratch has no native OAuth, "Fine, I'll do it myself."
repo_language: PHP
owner: ScratchVerifier
file_changes: filename: SpecificApps.php
change_type: ModificationType.MODIFY
diff: @@ -38,6 +38,8 @@ class SpecificApps extends SimpleHandler {
 		$data = $this->getRequest()->getBody()->getContents();
 		$data = json_decode($data, true);
 		if (!$data) return $this->http400();
+		// Users may not modify flags, thus 403
+		if (array_key_exists('flags', $data)) return $this->getResponseFactory()->createHttpError(403);
 		if (
 			array_key_exists('reset_secret', $data)
 			&& !is_bool($data['reset_secret'])

programming_language: PHP