Medium

Generated Code Contains Local Information Disclosure Vulnerability

  • Disclosed: 11.03.2021
  • Updated: 11.10.2026 12:22

Impact

This vulnerability impacts generated code. If this code was generated as a one-off occasion, not as a part of an automated CI/CD process, this code will remain vulnerable until fixed manually!

On Unix-Like systems, the system temporary directory is shared between all local users. When files/directories are created, the default umask settings for the process are respected. As a result, by default, most processes/apis will create files/directories with the permissions -rw-r--r-- and drwxr-xr-x respectively, unless an API that explicitly sets safe file permissions is used.

Java Code

The method File.createTempFile from the JDK is vulnerable to this local information disclosure vulnerability.

Patches

Fix has been applied to the master branch with:

included in release: 2.4.19

Workarounds

Users can remediate the vulnerability in non patched version by manually (or programmatically e.g. in CI) updating the generated source code to use java.nio.files.Files temporary file creation instead of java.io.File, e.g. by changing

java
    if (tempFolderPath == null)
      return File.createTempFile(prefix, suffix);
    else
      return File.createTempFile(prefix, suffix, new File(tempFolderPath));

to

java
    if (tempFolderPath == null)
      return Files.createTempFile(prefix, suffix).toFile();
    else
      return Files.createTempFile(Paths.get(tempFolderPath), prefix, suffix).toFile();

or generally changing:

java
File.createTempFile(prefix, suffix);

to

java
Files.createTempFile(prefix, suffix).toFile();

References

For more information

If you have any questions or comments about this advisory:

Original vulnerability report

I'm performing OSS security research under the GitHub Security Lab Bug Bounty program. I've been using a custom CodeQL query to find local temporary directory vulnerabilities in OSS with three custom CodeQL queries.

The code generated by the Swagger Generator contains a local information disclosure vulnerability. The system temporary directory, on unix-like systems is shared between multiple users. Information written to this directory, or directories created under this directory that do not correctly set the posix standard permissions can have these directories read/modified by other users.


This code exists in the code generator, in the generated code.

In this case, I believe this is only a local information disclosure. IE. another user can read the information, not replace it.

In particular, the method File.createTempFile from the JDK is vulnerable to this local information disclosure vulnerability.

This is because File.createTempFile creates a file inside of the system temporary directory with the permissions: -rw-r--r--. Thus the contents of this file are viewable by all other users locally on the system.

The fix here is to switch to the Files API, instead of File as that appropriately sets the file permissions.

Affected software

Click a technology to see all vulnerabilities affecting it.

PlatformPackageVulnerable versionsFixed in
Java / Kotlin (Maven) io.swagger:swagger-codegen < 2.4.19 2.4.19

References

CVSS score 6.2/10
CVSS vector
CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
Weakness (CWE)
CWE-200, CWE-378, CWE-732
Platform
Java / Kotlin (Maven)
Package
io.swagger:swagger-codegen
Disclosed
11.03.2021
Updated
11.10.2026 12:22

Sources and licenses

OSV / GitHub Advisory Database - GHSA-hpv8-9rq5-hq7w - CC BY 4.0

Vulnerability history: io.swagger:swagger-codegen

All published vulnerabilities of this package (Java / Kotlin (Maven)), newest first. Shows whether this is a one-off slip or a package that needs watching.

Total entries
4
First → latest
10.2018 03.2021
Without a fix
0
Exploited in attacks
0

Severity breakdown

  • High 2
  • Medium 1
  • Low 1

Disclosures per year

  1. 2018: 2
  2. 2019: 0
  3. 2020: 0
  4. 2021: 2
  5. 2022: 0
  6. 2023: 0
  7. 2024: 0
  8. 2025: 0
  9. 2026: 0
  1. Generated Code Contains Local Information Disclosure Vulnerability this entry
    Medium · 6.2 CVE-2021-21364 < 2.4.19 2.4.19
  2. High · 8.8 CVE-2017-1000208 < 2.2.2 2.2.2
  3. High · 8.8 CVE-2017-1000207 < 2.2.2 2.2.2

Know which vulnerabilities affect your application

With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.

Connect your application
DockRay newsletter

Application security in your inbox

Important vulnerabilities, actionable guidance and practical advice for your applications. Choose your technologies and follow what matters to your project.

  • A daily digest of new vulnerabilities, critical ones included.
  • Notifications about important updates.
  • Practical advice on application security and monitoring.

Leave empty to receive updates for every technology.

Free to subscribe. Unsubscribe with one click in any email.