CVE-2022-24913 (published 2023-01-12T05:15Z)

Versions of the package com.fasterxml.util:java-merge-sort before 1.1.0 are vulnerable to Insecure Temporary File in the StdTempFileProvider() function in StdTempFileProvider.java, which uses the permissive File.createTempFile() function, exposing temporary file contents.

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

Weakness information:
cwe_id: CWE-668
cwe_name: Exposure of Resource to Wrong Sphere
description: The product exposes a resource to the wrong control sphere, providing unintended actors with inappropriate access to the resource.
extended_description: 
            Resources such as files and directories may be inadvertently exposed through mechanisms such as insecure permissions, or when a program accidentally operates on the wrong object. For example, a program may intend that private files can only be provided to a specific user. This effectively defines a control sphere that is intended to prevent attackers from accessing these private files. If the file permissions are insecure, then parties other than the user will be able to access those files.
            A separate control sphere might effectively require that the user can only access the private files, but not any other files on the system. If the program does not ensure that the user is only requesting private files, then the user might be able to access other files on the system.
            In either case, the end result is that a resource has been exposed to the wrong party.
         
         

Fix information:
repo_url: https://github.com/cowtowncoder/java-merge-sort
commit_details: repo_url: https://github.com/cowtowncoder/java-merge-sort
author: Jonathan Leitschuh
author_date: 2022-11-19 02:05:10+00:00
msg: vuln-fix: Temporary File Information Disclosure



This fixes temporary file information disclosure vulnerability due to the use
of the vulnerable `File.createTempFile()` method. The vulnerability is fixed by
using the `Files.createTempFile()` method which sets the correct posix permissions.

Weakness: CWE-377: Insecure Temporary File
Severity: Medium
CVSSS: 5.5
Detection: CodeQL & OpenRewrite (https://public.moderne.io/recipes/org.openrewrite.java.security.SecureTempFileCreation)

Reported-by: Jonathan Leitschuh <Jonathan.Leitschuh@gmail.com>
Signed-off-by: Jonathan Leitschuh <Jonathan.Leitschuh@gmail.com>

Bug-tracker: https://github.com/JLLeitschuh/security-research/issues/18


Co-authored-by: Moderne <team@moderne.io>
repository: repo_url: https://github.com/cowtowncoder/java-merge-sort
repo_name: cowtowncoder/java-merge-sort
description: Basic stand-alone disk-based N-way merge sort component for Java
repo_language: Java
owner: cowtowncoder
file_changes: filename: StdTempFileProvider.java
change_type: ModificationType.MODIFY
diff: @@ -1,6 +1,7 @@
 package com.fasterxml.sort.std;
 
 import java.io.*;
+import java.nio.file.Files;
 
 import com.fasterxml.sort.TempFileProvider;
 
@@ -35,7 +36,7 @@ public class StdTempFileProvider
     @Override
     public File provide() throws IOException
     {
-        File f = File.createTempFile(_prefix, _suffix);
+        File f = Files.createTempFile(_prefix, _suffix).toFile();
         f.deleteOnExit();
         return f;
     }

programming_language: Java