swagger-api / swagger-api/swagger-codegen

[JAVA][ApiClient.java]: Insecure SSL: Overly Broad Certificate Trust

Open
#8,605 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

[JAVA][ApiClient.java]: Insecure SSL: Overly Broad Certificate Trust

A critical issue was discovered by Fortify in ApiClient.java generated by swagger-codegen:

An SSL/TLS connection is created using the default pre-loaded system Certificate Authorities (CAs), which may allow attackers to intercept encrypted communications by performing man-in-the-middle (MiTM) attacks using certificates signed with compromised root CAs.

Swagger-codegen version

2.3.1

Swagger declaration file content or url
                TrustManager trustAll = new X509TrustManager() {
                    @Override
                    public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {}
                    @Override
                    public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {}
                    @Override
                    public X509Certificate[] getAcceptedIssuers() { return null; }
                };
Command line used for generation

swagger-codegen generate

Steps to reproduce

Scan the generated code using Fortify.

Related issues/PRs

NA

Suggest a fix/enhancement

NA

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The reported output is ApiClient.java, produced by the swagger-codegen generate command; start by locating the Java template or generation entry point that emits the shown TrustManager. Use the Fortify finding as the reproduction, then verify the generated client no longer triggers the overly broad certificate-trust finding.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.