Every CVE Search/ Get API key

CVE-2021-21430

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

6.2 MediumFix available

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec. Using File.createTempFile in JDK will result in creating and using insecure temporary files that can leave application and system data vulnerable to attacks. Auto-generated code (Java, Scala) that deals with uploading or downloading binary data through API endpoints will create insecure temporary files during the process. Affected generators: java (jersey2, okhttp-gson (default library)), scala-finch. The issue has been patched with Files.createTempFile and released in the v5.1.0 stable version.

Attack profile

How easy it is to exploit

Attack vector
Local
Complexity
Low
Privileges needed
None
User interaction
None

What an attacker can affect

Confidentiality
High
Integrity
None
Availability
None

Exploit likelihood

0.40%Down 0.4 points since May 11, 2021
90%50%10%1%

What each source reports

CVE List Score used 6.2

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

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec. Using File.createTempFile in JDK will result in creating and using insecure temporary files that can leave application and system data vulnerable to attacks. Auto-generated code (Java, Scala) that deals with uploading or downloading binary data through API endpoints will create insecure temporary files during the process. Affected generators: java (jersey2, okhttp-gson (default library)), scala-finch. The issue has been patched with Files.createTempFile and released in the v5.1.0 stable version.

Record
CVE-2021-21430
CVSS 3.1
6.2 MediumCVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
Weakness
CWE-269
Updated
2026-11-02
EUVDEUVD-2021-1049 6.2

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec. Using File.createTempFile in JDK will result in creating and using insecure temporary files that can leave application and system data vulnerable to attacks. Auto-generated code (Java, Scala) that deals with uploading or downloading binary data through API endpoints will create insecure temporary files during the process. Affected generators: java (jersey2, okhttp-gson (default library)), scala-finch. The issue has been patched with Files.createTempFile and released in the v5.1.0 stable version.

Record
EUVD-2021-1049
CVSS 3.1
6.2 MediumCVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
Updated
2026-11-03
GitHub AdvisoriesGHSA-cqxr-xf2w-943w 6.2

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

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:

Record
GHSA-cqxr-xf2w-943w
CVSS 3.1
6.2 MediumCVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
Weakness
CWE-269, CWE-377, CWE-378, CWE-379, CWE-668
Updated
2026-11-02
NVD 6.2

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec. Using File.createTempFile in JDK will result in creating and using insecure temporary files that can leave application and system data vulnerable to attacks. Auto-generated code (Java, Scala) that deals with uploading or downloading binary data through API endpoints will create insecure temporary files during the process. Affected generators: java (jersey2, okhttp-gson (default library)), scala-finch. The issue has been patched with Files.createTempFile and released in the v5.1.0 stable version.

Record
CVE-2021-21430
CVSS 3.1
6.2 MediumCVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
CVSS 3.1
5.5 MediumCVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N
CVSS 2.0
2.1 LowAV:L/AC:L/Au:N/C:P/I:N/A:N
Weakness
CWE-269, CWE-668
Updated
2026-11-02
OSV 5.5

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec. Using File.createTempFile in JDK will result in creating and using insecure temporary files that can leave application and system data vulnerable to attacks. Auto-generated code (Java, Scala) that deals with uploading or downloading binary data through API endpoints will create insecure temporary files during the process. Affected generators: java (jersey2, okhttp-gson (default library)), scala-finch. The issue has been patched with Files.createTempFile and released in the v5.1.0 stable version.

Record
CVE-2021-21430
CVSS 3.1
5.5 MediumCVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N
Updated
2026-11-02
OSVGHSA-cqxr-xf2w-943w 6.2

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

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:

Record
GHSA-cqxr-xf2w-943w
CVSS 3.1
6.2 MediumCVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
Weakness
CWE-269, CWE-377, CWE-378, CWE-379, CWE-668
Updated
2026-11-02

Affected products

Affected packages

Affected packages
PackageAffectedFixed
org.openapitools:openapi-generator
Maven
before 5.1.0
5.1.0
org.openapitools:openapi-generator
Maven
before 5.1.0, plus listed versions
3.0.03.0.13.0.23.0.33.1.0
Show 33 moreShow less
3.1.13.1.23.2.03.2.13.2.23.2.33.3.03.3.13.3.23.3.33.3.44.0.04.0.0-beta4.0.0-beta24.0.0-beta34.0.14.0.24.0.34.1.04.1.14.1.24.1.34.2.04.2.14.2.24.2.34.3.04.3.15.0.05.0.0-beta5.0.0-beta25.0.0-beta35.0.1
5.1.0

History

History
RecordedChangedSources
aliasesEUVD
first indexedCVE List, GitHub Advisories, NVD, OSV

Dates are when Every CVE recorded each change. Upstream dates may differ.

In short

CVE-2021-21430 is a medium vulnerability (CVSS 6.2) in Openapi-generator Openapi Generator, published May 10, 2021. No source lists public exploit code. EPSS puts the chance of exploitation in the next 30 days at 0.40%, the 34th percentile. Fixed in org.openapitools:openapi-generator 5.1.0.

References

MoveEnter Open