CVE-2023-23939 (published 2023-03-06T19:15Z)

Azure/setup-kubectl is a GitHub Action for installing Kubectl. This vulnerability only impacts versions before version 3. An insecure temporary creation of a file allows other actors on the Actions runner to replace the Kubectl binary created by this action because it is world writable. This Kubectl tool installer runs `fs.chmodSync(kubectlPath, 777)` to set permissions on the Kubectl binary, however, this allows any local user to replace the Kubectl binary. This allows privilege escalation to the user that can also run kubectl, most likely root. This attack is only possible if an attacker somehow breached the GitHub actions runner or if a user is utilizing an Action that maliciously executes this attack. This has been fixed and released in all versions `v3` and later. 775 permissions are used instead. Users are advised to upgrade. There are no known workarounds for this issue.\n

CVSS v3 base score: 7.0, HIGH (CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H)

Weakness information:
cwe_id: CWE-732
cwe_name: Incorrect Permission Assignment for Critical Resource
description: The product specifies permissions for a security-critical resource in a way that allows that resource to be read or modified by unintended actors.
extended_description: When a resource is given a permission setting that provides access to a wider range of actors than required, it could lead to the exposure of sensitive information, or the modification of that resource by unintended parties. This is especially dangerous when the resource is related to program configuration, execution, or sensitive user data. For example, consider a misconfigured storage account for the cloud that can be read or written by a public or anonymous user.
         

Fix information:
repo_url: https://github.com/Azure/setup-kubectl
commit_details: repo_url: https://github.com/Azure/setup-kubectl
author: Oliver King
author_date: 2022-05-27 17:36:08-04:00
msg: lower permissions for chmod (#51)
repository: repo_url: https://github.com/Azure/setup-kubectl
repo_name: Azure/setup-kubectl
description: GitHub Action for installing Kubectl
repo_language: TypeScript
owner: Azure
file_changes: filename: run.test.ts
change_type: ModificationType.MODIFY
diff: @@ -106,7 +106,7 @@ describe('Testing all functions in run file.', () => {
         expect(toolCache.downloadTool).toBeCalled();
         expect(toolCache.cacheFile).toBeCalled();
         expect(os.type).toBeCalled();
-        expect(fs.chmodSync).toBeCalledWith(path.join('pathToCachedTool', 'kubectl.exe'), '777');
+        expect(fs.chmodSync).toBeCalledWith(path.join('pathToCachedTool', 'kubectl.exe'), '775');
     });
 
     test('downloadKubectl() - throw DownloadKubectlFailed error when unable to download kubectl', async () => {
@@ -144,7 +144,7 @@ describe('Testing all functions in run file.', () => {
         expect(await run.downloadKubectl('v1.15.0')).toBe(path.join('pathToCachedTool', 'kubectl.exe'));
         expect(toolCache.find).toBeCalledWith('kubectl', 'v1.15.0');
         expect(os.type).toBeCalled();
-        expect(fs.chmodSync).toBeCalledWith(path.join('pathToCachedTool', 'kubectl.exe'), '777');
+        expect(fs.chmodSync).toBeCalledWith(path.join('pathToCachedTool', 'kubectl.exe'), '775');
         expect(toolCache.downloadTool).not.toBeCalled();
     });
 

programming_language: TypeScript
filename: run.ts
change_type: ModificationType.MODIFY
diff: @@ -57,7 +57,7 @@ export async function downloadKubectl(version: string): Promise<string> {
     }
 
     const kubectlPath = path.join(cachedToolpath, kubectlToolName + getExecutableExtension());
-    fs.chmodSync(kubectlPath, '777');
+    fs.chmodSync(kubectlPath, '775');
     return kubectlPath;
 }
 

programming_language: TypeScript