Repository navigation
Closed
Labels
enhancementNew features or improvements of some kind, as opposed to a problem (bug)frozen-due-to-ageIssues closed and untouched for a long time, together with being locked for discussionskip-changelogBugs that have never been in a released stable version, and as such excluded from the release notes
Milestone
Description
When trying to run a relay using the syncthing/relaysrv docker image on a multihomed server (e.g. Kubernetes), I get the following:
2020/12/14 21:21:41 main.go:138: strelaysrv v1.3.4 "Fermium Flea" (go1.13.8 linux-amd64) [email protected] 2020-01-14 07:01:03 UTC
2020/12/14 21:21:41 main.go:144: Connection limit 838860
2020/12/14 21:21:41 main.go:157: Failed to load keypair. Generating one, this might take a while...
2020/12/14 21:21:41 main.go:183: ID: ZEHCSIS-ZBH4DQM-W6K75CQ-AACASFF-PTVRV3H-DDMZXJN-WQYBNZJ-6NAKVAH
2020/12/14 21:21:41 main.go:233: URI: relay://212.129.50.60:22067/?id=ZEHCSIS-ZBH4DQM-W6K75CQ-AACASFF-PTVRV3H-DDMZXJN-WQYBNZJ-6NAKVAH&pingInterval=1m0s&networkTimeout=2m0s&sessionLimitBps=0&globalLimitBps=2099200&statusAddr=:22070&providedBy=Roberto Santalla (@rsroobre)
2020/12/14 21:21:41 main.go:236: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2020/12/14 21:21:41 main.go:237: !! Joining default relay pools, this relay will be available for public use. !!
2020/12/14 21:21:41 main.go:238: !! Use the -pools="" command line option to make the relay private. !!
2020/12/14 21:21:41 main.go:239: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2020/12/14 21:21:41 pool.go:16: Joining https://relays.syncthing.net/endpoint
2020/12/14 21:21:41 pool.go:45: https://relays.syncthing.net/endpoint failed to join due to IP address not matching external address. Aborting
If I'm not mistaken, the last line is telling me the address in which I've set the relay server to listen is different from the IP my machine uses to make requests to the world. I think this is a fair use case for multihomed servers.
Is there any possibility of removing this check? My relay server has been up & running publicly for several years, having to remove it because I'm migrating my server to K8s would deeply sadden me :(
Thanks in advance for your time
Metadata
Metadata
Assignees
Labels
enhancementNew features or improvements of some kind, as opposed to a problem (bug)frozen-due-to-ageIssues closed and untouched for a long time, together with being locked for discussionskip-changelogBugs that have never been in a released stable version, and as such excluded from the release notes
Activity
AudriusButkevicius commentedon Dec 14, 2020
Have you checked --help?
--ext-address is there for this specific reason.
nadiamoe commentedon Dec 14, 2020
Hi @AudriusButkevicius ,
Thanks for the quick response. I think I was too scarce on the post above, as I forgot to post the config I'm using (which includes
--ext-address):st-relay.roobre.esresolves to212.129.50.60, which can be seen in the log I posted above. This is also the address where the input port is mapped and therefore where I expect clients to connect to. I double-checked that the port is correctly mapped and accessible from the outside by runningnc -vv st-relay.roobre.es 22067from my llocal machine.However, the machine hosting the relay server is performing requests to the internet from a different IP address, which I think might be confusing the relay pool. Could this be the case?
Thanks!
nadiamoe commentedon Dec 14, 2020
I made a quick search and it would seem that the error I'm seeing is reported here:
syncthing/cmd/strelaysrv/pool.go
Line 81 in 466e8a5
Which is, in turn, returned by the pool server here:
syncthing/cmd/strelaypoolsrv/main.go
Line 386 in 466e8a5
It would seem that this is indeed a check in the relay pool server, which rejects clients when the advertised address is different from the one making the request. I still want to make a point saying that this might not be an uncommon scenario for dedicated servers. Would you be open to reconsider this? Perhaps if I understood the motivation behind this check (security maybe?) we could discuss an alternative approach.
Thanks again for your time.
AudriusButkevicius commentedon Dec 14, 2020
Why is it dialing out a different gateway than it expects to get connections back?
nadiamoe commentedon Dec 14, 2020
@AudriusButkevicius This is not uncommon in multihomed environments, or in this case, in Kubernetes. It is designed that way so the machine can have its own IP address, while at the same time the services hosted in it are accessed through other addresses, for example behind load balancers. In this case there is not the case (the address in which the relay server listens will not change), but it is different from the one the host uses because of this. This also allows to decouple the service from the machine is being run on, which is useful for clusters.
It is not really my choice, it is "just how Kubernetes works", if you want to say it like that.
I might, however, ask the opposite question: Why is the relay server assuming that a particular host can only have one address?
AudriusButkevicius commentedon Dec 14, 2020
So I can't really see a good reason why the check is there.
We perform a connection test anyway.
Sorry for closing this early, but from your original report it looked to me like you are just looking for --ext-address.
calmh commentedon Dec 15, 2020
I think the check is reasonable as-is, in that I think we want the relay pool to only accept voluntary submissions. That the announcement comes from the actual relay is one way to check that. Without the check I could announce someone else's supposedly secret relay to the relay pool without their consent.
Of course there are other solutions to this, but they would require changing the relay protocol (or at least handshake) I think.
nadiamoe commentedon Dec 15, 2020
Hi,
Thanks for the explanation, I think I understand the problematic now. It is true that removing the check could open the door for a malicious agent to spam submissions on behalf of other hosts.
A possible solution that comes to my mind is adding some sort of "negotiation phase" to the relay, in a way similar to the following:
http://external-address:22070/tokenhttp://external-address:22070/tokenand compares the token with the one it dispensed.In my mind (I haven't looked too much at the code) this could be implemented as a part of the discovery phase, rather than the relay protocol itself. In addition, this step could be triggered only if the advertised address and source address do not match (i.e. in this section of the code), making the change non-breaking.
Of course this adds a bit of weight on the pool server, as it would need to keep track of these tokens at least for a short while.
What do you think about this approach? If you think it is worth implementing, I could try and write a PoC and PR with it.
calmh commentedon Dec 15, 2020
Yeah, that's something like what I was thinking of when I said another solution, though I was thinking the token would end up in the relay handshake. Your idea is better. Another option would be to do the registering with the relay certificate as client certificate. The relay pool server can then do the connect back to whatever address and accept it as long as the presented certificate is the same.
nadiamoe commentedon Dec 15, 2020
By this, do you mean reusing the certificate for the HTTP registration? I think that might be more complex, as it would require setting up https and would break existing configurations.
calmh commentedon Dec 15, 2020
The request to register with the pool server is a HTTPS POST to https://relays.syncthing.net/endpoint. The relay has a TLS certificate that is uses for relay connections. The relay server could present that certificate as a client certificate in the HTTPS POST. Then, when the relay pool does the connection check it can compare the certificate presented by the relay with that used in the registration request. If it's the same certificate we know it's the same relay server.
AudriusButkevicius commentedon Dec 15, 2020
Anyways, all of these are non-trivial in terms of effort to implement and to support migration/rollout for existing relays.
Do we really think we'll do this?
I doubt it, hence my heart is going back towards close as won't fix.
nadiamoe commentedon Dec 15, 2020
Ok, I understand now. Sending the certificate on announcement is an easy change, and if said cert is already sent by the relaysrv to the pool in the connection check, asserting that it is the same shouldn't be much of a change either.
I think that these mechanisms could be implemented only in the case the remote IP check fails. Rather than returning an error, the pool server could store a flag like "verification pending" and check the certificate in the connect phase only if this flag is set. That way the change would not be breaking, right?
In the end it's up to you to decide, but please keep in mind that you can count on me to lend a hand with a PR for the solution :)
calmh commentedon Dec 15, 2020
Someone might, at some point.
AudriusButkevicius commentedon Dec 15, 2020
Sure, if you want to file a PR fixing this, I won't stop you.
Global discovery client/server already does this certificate validation to prevent this same spoofing, in case you are looking for inspiration.
We don't need any sort of verification pending state, if the cert is there, we ignore host mismatch and do cert based validation in the "test that the relay actually works" part. If the cert is not there, we stick to host checking.
nadiamoe commentedon Dec 15, 2020
Looks like we have an approach then!
Thanks for your feedback and ideas, I'll allocate some time to work on a PR implementing it :)
cmd/relaypoolsrv: Allow validation of relay join requests by certific…
Merge branch 'main' into conref
cmd/relaypoolsrv: Allow validation of relay join requests by certific…
LINKIWI commentedon Aug 10, 2021
@calmh @roobre I see that #7217 was merged quite some time ago but I'm still seeing
IP address not matching external addresswhen joining the public pool athttps://relays.syncthing.net/endpointand when the origin IP is different from the-ext-addressdeclared IP. This behavior is reproducible onv1.15.0as well as on db302b1 when built from source.I verified that the client (relay server) is properly sending along its cert and key in the initial request to the pool server. Is there some other client-side configuration I'm missing? Or is it simply the case that #7217 has not yet been delpoyed to
relays.syncthing.net?