Skip to content

fix: check certificate IP SANs when detecting mismatched certificates - #1026

Merged
Mzack9999 merged 2 commits into
projectdiscovery:devfrom
RaphaelFakhri:fix/mismatched-ip-san
Oct 23, 2026
Merged

Mzack9999 merged 2 commits into
projectdiscovery:devfrom
RaphaelFakhri:fix/mismatched-ip-san

Conversation

@RaphaelFakhri

Copy link
Copy Markdown
Contributor

Summary

-mm flags a certificate as mismatched when the target is an IP address listed in the certificate's IP SANs, because the mismatch check only uses the subject CN and DNS SANs. For example, tlsx -u 1.1.1.1 -mm reports [mismatched] for a certificate that lists 1.1.1.1 as an IP SAN.

This change:

  • Adds the certificate IP addresses to the names passed to IsMisMatchedCert in clients.Convertx509toResponse (ctls, openssl) and ztls.ConvertCertificateToResponse (ztls).
  • Compares IP addresses by value in IsMisMatchedCert, so IPv6 targets match regardless of notation.

Tests

  • TestIsMisMatchedCert: new IPv4 and IPv6 cases.
  • TestConvertx509toResponseMisMatchedIP: a certificate with IP SANs is not mismatched for those IPs and is mismatched for another IP.
  • TestMisMatchedIPAddressSAN: a ztls handshake against an httptest TLS server on 127.0.0.1 is not reported as mismatched.
$ go test ./pkg/tlsx/clients/ ./pkg/tlsx/ztls/ -run 'TestIsMisMatchedCert|TestConvertx509toResponseMisMatchedIP|TestMisMatchedIPAddressSAN'
ok  	github.com/projectdiscovery/tlsx/pkg/tlsx/clients
ok  	github.com/projectdiscovery/tlsx/pkg/tlsx/ztls

The new tests fail without the fix. golangci-lint run reports 0 issues on the changed packages.

Before and after against 1.1.1.1:

$ tlsx -u 1.1.1.1 -mm -silent   # before
1.1.1.1:443 [mismatched]
$ tlsx -u 1.1.1.1 -mm -silent   # after
1.1.1.1:443

Fixes #1025

@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: adcec08f-fd0b-4ec8-82d9-efd0e59cc29f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@Mzack9999
Mzack9999 merged commit 30fe5b5 into projectdiscovery:dev Oct 23, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants