CVE-2021-21428
Creation of Temporary File in Directory with Insecure Permissions in the OpenAPI-Generator online generator
Openapi generator is a java tool which allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec. openapi-generator-online creates insecure temporary folders with File.createTempFile during the code generation process. The insecure temporary folders store the auto-generated files which can be read and appended to by any users on the system. 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
- High
- Availability
- High
Exploit likelihood
What each source reports
CVE List Score used
9.3
Creation of Temporary File in Directory with Insecure Permissions in the OpenAPI-Generator online generator
Openapi generator is a java tool which allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec. openapi-generator-online creates insecure temporary folders with File.createTempFile during the code generation process. The insecure temporary folders store the auto-generated files which can be read and appended to by any users on the system. The issue has been patched with Files.createTempFile and released in the v5.1.0 stable version.
- Record
CVE-2021-21428- CVSS 3.1
- 9.3 Critical
CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H - Weakness
- CWE-269
- Updated
- 2026-11-02
EUVDEUVD-2021-0893
9.3
Openapi generator is a java tool which allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec. openapi-generator-online creates insecure temporary folders with File.createTempFile during the code generation process. The insecure temporary folders store the auto-generated files which can be read and appended to by any users on the system. The issue has been patched with Files.createTempFile and released in the v5.1.0 stable version.
- Record
EUVD-2021-0893- CVSS 3.1
- 9.3 Critical
CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H - Updated
- 2026-11-03
GitHub AdvisoriesGHSA-23x4-m842-fmwf
9.3
Creation of Temporary File in Directory with Insecure Permissions in the OpenAPI-Generator online generator
Impact
On Unix like systems, the system's temporary directory is shared between all users on that system. A collocated user can observe the process of creating a temporary sub directory in the shared temporary directory and race to complete the creation of the temporary subdirectory.
This vulnerability is local privilege escalation because the contents of the outputFolder can be appended to by an attacker. As such, code written to this directory, when executed can be attacker controlled.
openapi-generator-online creates insecure temporary folders with File.createTempFile during the code generation process. The insecure temporary folders store the auto-generated files which can be read and appended to by any users on the system.
Vulnerable Code
This vulnerability exists due to a race condition between the deletion of the randomly generated temporary file and the creation of the temporary directory.
File outputFolder = File.createTempFile("codegen-", "-tmp"); // Attacker knows the full path of the file that will be generated
// delete the file that was created
outputFolder.delete(); // Attacker sees file is deleted and begins a race to create their own directory before the code generator
// and make a directory of the same name
// SECURITY VULNERABILITY: Race Condition! - Attacker beats the code generator and now owns this directory
outputFolder.mkdir();
Patches
The issue has been patched by changing the underlying logic to use Files.createTempFile and has been released in the v5.1.0 stable version.
This vulnerability has the same root cause as CVE-2021-21363 from the swagger-api/swagger-codegen project as this project and that one both share the same original source tree.
See: https://github.com/swagger-api/swagger-codegen/security/advisories/GHSA-pc22-3g76-gm6j
For more information
If you have any questions or comments about this advisory:
- Open an issue in OpenAPI Generator Github repo
- Email us at [email protected]
- Record
GHSA-23x4-m842-fmwf- CVSS 3.1
- 9.3 Critical
CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H - Weakness
- CWE-269, CWE-377, CWE-378, CWE-379, CWE-668
- Updated
- 2026-11-02
NVD
9.3
Openapi generator is a java tool which allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec. openapi-generator-online creates insecure temporary folders with File.createTempFile during the code generation process. The insecure temporary folders store the auto-generated files which can be read and appended to by any users on the system. The issue has been patched with Files.createTempFile and released in the v5.1.0 stable version.
- Record
CVE-2021-21428- CVSS 3.1
- 9.3 Critical
CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H - CVSS 3.1
- 7.0 High
CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H - CVSS 2.0
- 4.4 Medium
AV:L/AC:M/Au:N/C:P/I:P/A:P - Weakness
- CWE-269, CWE-668
- Updated
- 2026-11-02
OSV
7.0
Openapi generator is a java tool which allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec. openapi-generator-online creates insecure temporary folders with File.createTempFile during the code generation process. The insecure temporary folders store the auto-generated files which can be read and appended to by any users on the system. The issue has been patched with Files.createTempFile and released in the v5.1.0 stable version.
- Record
CVE-2021-21428- CVSS 3.1
- 7.0 High
CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H - Updated
- 2026-11-02
OSVGHSA-23x4-m842-fmwf
9.3
Creation of Temporary File in Directory with Insecure Permissions in the OpenAPI-Generator online generator
Impact
On Unix like systems, the system's temporary directory is shared between all users on that system. A collocated user can observe the process of creating a temporary sub directory in the shared temporary directory and race to complete the creation of the temporary subdirectory.
This vulnerability is local privilege escalation because the contents of the outputFolder can be appended to by an attacker. As such, code written to this directory, when executed can be attacker controlled.
openapi-generator-online creates insecure temporary folders with File.createTempFile during the code generation process. The insecure temporary folders store the auto-generated files which can be read and appended to by any users on the system.
Vulnerable Code
This vulnerability exists due to a race condition between the deletion of the randomly generated temporary file and the creation of the temporary directory.
File outputFolder = File.createTempFile("codegen-", "-tmp"); // Attacker knows the full path of the file that will be generated
// delete the file that was created
outputFolder.delete(); // Attacker sees file is deleted and begins a race to create their own directory before the code generator
// and make a directory of the same name
// SECURITY VULNERABILITY: Race Condition! - Attacker beats the code generator and now owns this directory
outputFolder.mkdir();
Patches
The issue has been patched by changing the underlying logic to use Files.createTempFile and has been released in the v5.1.0 stable version.
This vulnerability has the same root cause as CVE-2021-21363 from the swagger-api/swagger-codegen project as this project and that one both share the same original source tree.
See: https://github.com/swagger-api/swagger-codegen/security/advisories/GHSA-pc22-3g76-gm6j
For more information
If you have any questions or comments about this advisory:
- Open an issue in OpenAPI Generator Github repo
- Email us at [email protected]
- Record
GHSA-23x4-m842-fmwf- CVSS 3.1
- 9.3 Critical
CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H - Weakness
- CWE-269, CWE-377, CWE-378, CWE-379, CWE-668
- Updated
- 2026-11-02
Affected products
Affected packages
| Package | Affected | Fixed |
|---|---|---|
org.openapitools:openapi-generator-onlineMaven |
before 5.1.0 | 5.1.0 |
org.openapitools:openapi-generator-onlineMaven |
before 5.1.0, plus listed versions 3.0.03.0.13.0.23.0.33.1.0 Show 33 moreShow less3.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
| Recorded | Changed | Sources |
|---|---|---|
| aliases | EUVD | |
| first indexed | CVE List, GitHub Advisories, NVD, OSV |
Dates are when Every CVE recorded each change. Upstream dates may differ.
In short
CVE-2021-21428 is a critical vulnerability (CVSS 9.3) 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.35%, the 28th percentile. Fixed in org.openapitools:openapi-generator-online 5.1.0.
References
github.com/OpenAPITools/openapi-generator/security/advisories/GHSA-23x4-m842-fmwf
github.com/OpenAPITools/openapi-generator/pull/8788
github.com/swagger-api/swagger-codegen/security/advisories/GHSA-pc22-3g76-gm6j
github.com/OpenAPITools/openapi-generator/blob/c6530519975341d7784a252132b2f0854f488901/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/service/Generator.java
nvd.nist.gov/vuln/detail/CVE-2021-21428
github.com/advisories/GHSA-23x4-m842-fmwf
github.com/OpenAPITools/openapi-generator