Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tls] Match server_name against SAN IPAddress #381

Closed
wants to merge 1 commit into from

Conversation

XeCycle
Copy link
Contributor

@XeCycle XeCycle commented Jun 16, 2023

This simple change "works for me"; I think it could be useful to some, and worth adding if it does not introduce security holes, although I'm not 100% confident about that. Do you prefer this as-is, or some sort of opt-in switch for this part?

@jlaine
Copy link
Contributor

jlaine commented Jul 4, 2023

Can you please quote the RFC or appropriate spec for this?

We're also going to need an explicit unit test for this

@codecov
Copy link

codecov bot commented Jul 4, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.07 ⚠️

Comparison is base (5757081) 100.00% compared to head (e3d0589) 99.93%.

Additional details and impacted files
@@             Coverage Diff             @@
##              main     #381      +/-   ##
===========================================
- Coverage   100.00%   99.93%   -0.07%     
===========================================
  Files           22       22              
  Lines         4553     4555       +2     
===========================================
- Hits          4553     4552       -1     
- Misses           0        3       +3     
Impacted Files Coverage Δ
src/aioquic/tls.py 99.79% <0.00%> (-0.21%) ⬇️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@jlaine
Copy link
Contributor

jlaine commented Jul 4, 2023

RFC 6125 explicitly considers matching by IP Address to be "out of scope", but I don't know if a subsequent RFC clarifies the expected behaviour:

https://www.rfc-editor.org/rfc/rfc6125.html#section-1.7.2

@XeCycle
Copy link
Contributor Author

XeCycle commented Jul 5, 2023

RFC 9001, Section 4.4 says "for example RFC 2818" which is the old HTTP-over-TLS, although the text does not seem very normative. The linked RFC 2818 simply says "the iPAddress subjectAltName must be present in the certificate and must exactly match the IP in the URI".

There's a discrepancy here: HTTP specifies and uses URI, but QUIC, at the layer below HTTP/3, does not speak URI. So this text can only be taken as an "example", since it apparently cannot be applied as-is.

So I'm not sure what's the IETF opinion on this. However this seems to be a common practice: CloudFlare, on 1.1.1.1, both TCP 443 and UDP 443, serves with their certificate containing SAN IP:1.1.1.1. I did not try any HTTP/3 clients, but as for HTTP 1 or 2 over TCP TLS, these clients accept that cert by default:

  • Firefox
  • Chromium
  • curl (on Linux using OpenSSL)
  • PowerShell Invoke-WebRequest
  • iOS Safari

Just to be clear, I don't think either CloudFlare or these clients are authoritative on this topic; but they give me a feeling that support for this feature is more frequently implemented than not.

Btw when digging those RFCs I noticed a missing piece: RFC 5280, Section 4.2.1.10 specifies that "Name Constraints" can be given in CIDR ranges, and (as I understand it) should be checked; I think this check is not implemented in this PR. I'm unsure how useful it is; this SO question implies Chrome does implement the check. Oh this is so complex I need some more time if we want this constraint implemented together...

@jlaine
Copy link
Contributor

jlaine commented Jul 5, 2023

Ok fair enough I think I'm convinced the usecase is legitimate, thanks for the research!

Implementation-wise, I'm currently considering switching subject validation to service-identity as match_hostname is deprecated, see #368. I see that this package provides support both for validating FQDNs and IP addresses against the SAN.

Also: how do you plan to pass an IP address to the TLS stack? Currently the TLS stack has no concept of the remote party's IP address, only the hostname to use for SNI.

@XeCycle
Copy link
Contributor Author

XeCycle commented Jul 5, 2023

considering switching subject validation to service-identity

Yes, it covers matching of the IP. But it seems name constraints are not covered; I'm feeling that this may be a limitation in the API, because such constraints come from some issuer up the trust chain, but if we take only the end certificate as input we cannot tell if there's a constraint to apply. Either way, switching to that lib should be enough to supersede my PR.

how do you plan to pass an IP address to the TLS stack?

I create QuicConfiguration(server_name=host) which is the IP in string format, thus I said server_name in my title.

@jlaine
Copy link
Contributor

jlaine commented Nov 15, 2023

Superseeded by #390

@jlaine jlaine closed this Nov 15, 2023
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