CVE-2021-21364: Local Information Disclosure Vulnerability in io.swagger:swagger-codegen

io.swagger:swagger-codegen Updated 02 Oct 2025

Summary

11/03/2021
Yes i
Moderate
6.2

CVE-2021-21364: Generated Code Contains Local Information Disclosure Vulnerability. Affects io.swagger:swagger-codegen versions < 2.4.19. Fixed in 2.4.19. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

The io.swagger:swagger-codegen package is a code generation tool that generates client libraries, server stubs, and API documentation from an OpenAPI Specification. It is widely used in the development of RESTful APIs. However, it is vulnerable to a local information disclosure vulnerability.

Vulnerability Detail

The vulnerability in io.swagger:swagger-codegen arises from the use of the File.createTempFile method from the JDK. This method creates a file inside the system temporary directory with insecure permissions (-rw-r--r--). As a result, the contents of this file can be viewed by all other users on the system. While this vulnerability is considered moderate in severity, it can lead to the exposure of sensitive information to unauthorized actors. The vulnerability has been assigned a CVSS score of 6.2.

How To Fix

Minimum fixed version

2.4.19

This is the first release that contains the fix.

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

If updating to the patched version is not immediately feasible, users can manually update the generated source code to use the java.nio.files.Files temporary file creation instead of java.io.File. This can be done by replacing instances of File.createTempFile with Files.createTempFile(prefix, suffix).toFile() or Files.createTempFile(Paths.get(tempFolderPath), prefix, suffix).toFile().

Conclusion

The io.swagger:swagger-codegen package is vulnerable to a local information disclosure vulnerability. Users are advised to update to version 2.4.19 or later to fix the vulnerability. If immediate update is not possible, manual code changes can be made to mitigate the risk. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for io.swagger:swagger-codegen →

Share this vulnerability

FAQ

The vulnerability allows for the disclosure of sensitive information to unauthorized actors. While it is considered moderate in severity, it can still pose a risk to the confidentiality of data.

You can use the Vulert Playground at Vulert Scanner to check if your application is affected by this vulnerability. Simply upload your pom.xml file and Vulert will analyze it for open-source vulnerabilities in real-time.

Yes, if updating to the patched version is not immediately feasible, you can manually update the generated source code to use the java.nio.files.Files temporary file creation instead of java.io.File. Refer to the 'workaround' section for the necessary code changes.

The CVSS score of this vulnerability is 6.2, indicating a moderate severity level.

For more information, you can refer to the original vulnerability report or contact the Swagger team at security@swagger.io.

Related vulnerabilities

Recent vulnerabilities recorded for io.swagger:swagger-codegen.

How To Fix

Minimum fixed version

2.4.19

This is the first release that contains the fix.

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback