-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Caddy on_demand_tls asking ask endpoint for self IP when no FQDN/SNI is used #6294
Comments
Potentially related: |
I don't see that as an issue. Your There are legitimate usecases where IP certs are desirable, like intranet setups, where having On-Demand IP certs is useful. As of v2.8.0-beta.1, you could write your own |
That makes sense, but regardless, why is the internal/private address of caddy being used in the ask request, when the public ip of the nlb was hit? This seems like a bug, no? |
Noting also, my issue isn’t to do with speed, but instead wasting an afternoon trying to figure out how external ips are querying my internal ask endpoint for a private IP. So two issues/questions:
|
Because that's the only thing Caddy has to work with. The public IP isn't on the TCP packet that reaches Caddy. |
This is intended behavior. SNI is not supposed to contain an IP address, but the server may very well be configured to serve an IP address (or any host! many instances are configured as wildcard listeners). As such, when the SNI is missing, it makes sense to assume the IP address.
You can configure on-demand TLS to be used for only the domain names you specify. Whatever you can match in a TLS connection policy: https://caddyserver.com/docs/json/apps/http/servers/tls_connection_policies/ -- so that's currently SNI, ALPN, and remote IP.
No, because the LB accesses Caddy using its internal IP. Closing, as everything is working as intended; but feel free to continue discussion if needed. |
Hmmm, I’m failing to understand how you could even have on demand IP certs - wouldn’t they be limited to the IP of Caddy? As SNI can’t contain a literal IP. Either way, is there currently absolutely no way to just have caddy reject requests with no SNI? Or for its self ip? Would something like this work (can I even dynamically get the caddy self ip?)? #2068 (comment) |
@mholt thanks, I will check it out and see if I can reject my internal range |
SNI can contain whatever the client puts in it -- you can't trust it -- but it's not supposed to contain any IPs.
Hmm, well requests haven't happened before the TLS handshake occurs so I'm not quite sure what you're asking here. |
I want to reject the request, without asking the ask endpoint. |
If you use
Then write a |
Seconding Francis here. I'm still a little confused because there is no request until after the TLS handshake is completed, and not having an 'ask' endpoint opens your server up for abuse. |
Okay no worries, thanks for your help both. I’ll just leave it as it is. All I was thinking was, right now, the session doesn’t get established because the ask endpoint returns a 404. I wanted to not even get as far as asking the ask endpoint (in my case, my ask endpoint is part of my backend service). So, rather than asking the endpoint and getting a 404 and then caddy denying the request, I thought it might be cleaner to just have caddy reject the request and not even make it to the ask end point. But it seems it probably doesn’t really matter. Apologies also if my terminology isn’t 100% correct. |
Ok, so if I understand correctly, what you're actually asking for is for Caddy to completely reject the TLS handshake if SNI is empty? |
Yep, that is correct. |
@captainfalcon23 Gotcha... I went ahead and implemented a quick |
That's awesome @mholt !! Would this be implemented in the caddy config within the tls_connection_policies block like:
|
There is no |
Hello,
I've gone through the Caddy docs and not sure if this is expected behaviour. I have the following fairly simple setup, and Caddy is configured to do on_demand_tls and I have configured an ask endpoint which I control.
AWS NLB -> Caddy -> App
When I query the NLB using the FQDN (either it's default or a custom set one) I see the request is made to my ask endpoint just fine.
However, when a request is made to one of the public IPs of the NLB, the request made to the ask endpoint is actually the address of Caddy itself! Example log from my ask endpoint:
10.0.0.62 = the internal IP of my Caddy.
I have proved this by simply curling my NLB public IPs e.g. (curl https://1.2.3.4) and watching the ask endpoint logs.
I don't understand why this happens - I would imagine if there is no SNI, there should be no "ask" at all? Or at least, it should be asking for the IP queried, not the internal Caddy IP. Ideally, this shouldn't happen and Caddy should just reject the request.
The reason why this is an issue is, anyone on the internet can do a port scan of the NLB and force Caddy to make a request to my ask endpoint. This shouldn't be the case, and Caddy should only respond to FQDN's, in which it can ask the ask endpoint.
Here is a redacted Caddyfile:
The text was updated successfully, but these errors were encountered: