Medium

Creation of Temporary File in Directory with Insecure Permissions in auto-generated Java, Scala code

  • Disclosed: 11.05.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.

This vulnerability exists due to the use of the JDK method File.createTempFile. This method creates an insecure temporary files that can leave application and system data vulnerable to exposure.

Auto-generated code (Java, Scala) that deals with uploading or downloading binary data through API endpoints will create insecure temporary files during the process. For example, if the API endpoint returns a PDF file, the auto-generated clients will first download the PDF into a insecure temporary file that can be read by anyone on the system.

Affected generators:

Patches

The issue has been patched by changing the generated code to use the JDK method Files.createTempFile and released in the v5.1.0 stable version.

This vulnerability has the same root cause as CVE-2021-21364 from the swagger-api/swagger-codegen project as this project and that one both share the same original source tree. https://github.com/swagger-api/swagger-codegen/security/advisories/GHSA-hpv8-9rq5-hq7w

For more information

If you have any questions or comments about this advisory:

Affected software

Click a technology to see all vulnerabilities affecting it.

PlatformPackageVulnerable versionsFixed in
Java / Kotlin (Maven) org.openapitools:openapi-generator < 5.1.0 5.1.0

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-269, CWE-377, CWE-378, CWE-379, CWE-668
Platform
Java / Kotlin (Maven)
Package
org.openapitools:openapi-generator
Disclosed
11.05.2021
Updated
11.10.2026 12:22

Sources and licenses

OSV / GitHub Advisory Database - GHSA-cqxr-xf2w-943w - CC BY 4.0

Vulnerability history: org.openapitools:openapi-generator

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
2
First → latest
05.2021 05.2022
Without a fix
0
Exploited in attacks
0

Severity breakdown

  • High 1
  • Medium 1

Disclosures per year

  1. 2021: 1
  2. 2022: 1
  3. 2023: 0
  4. 2024: 0
  5. 2025: 0
  6. 2026: 0
  1. High · 7.4 CVE-2019-11405 < 4.0.0-20190419.052012-560 4.0.0-20190419.052012-560
  2. Creation of Temporary File in Directory with Insecure Permissions in auto-generated Java, Scala code this entry
    Medium · 6.2 CVE-2021-21430 < 5.1.0 5.1.0

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.