-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
url_preview_ip_range_blacklist not honored #9417
Comments
I don't see too many recent, relevant changes to There have been significant changes to the IP Blacklisting config however. The IPs for |
Probably unrelated, but I'm using an outbound proxy (through HTTP_PROXY and HTTPS_PROXY env var) |
It is up to your proxy to prevent access to internal IPs in this case since the proxy does the DNS resolution, etc. I don't think anything has changed with proxies in the past few releases but maybe we're using them in more places now? |
I though synapse was doing the DNS resolution to handle the blacklists/whitelist before passing the request to the proxy (because it was working as expected before, and I was using the very same proxy config) |
Maybe the changes in #9084 caused this, but it should have previously just connected directly to the proxy and passed on the URL to request. |
To add a bit more information about this, it seems that the HTTP client used for URL previews is not shared with anything else: synapse/synapse/rest/media/v1/preview_url_resource.py Lines 147 to 154 in 0a00b7f
This was not changed recently. #9084 changed the In that conversation there was a discussion that no where in the code did we use blacklisting + proxying until #8821, although it seems this was slightly mistaken as we have always done this for URL previews. As far as I can tell the change to the reactor should have no affect on either an HTTP or HTTPS proxy as the name resolver only ever runs on the proxy's host, not on the destination. I believe this is also true of the CONNECT proxy, but the code is a bit harder to follow. I'd be surprised if this behavior changed, but regardless I think you want to be configuring your proxy to not connect to private IPs. (I'd be surprised if this wasn't the default?) Maybe we should be calling this out in the documentation. Out of curiosity, what proxy are you using? @Bubu do you have any thoughts on whether this behavior changed with #9084? |
Using squid. The VM running synapse does have access to some of the private IP for technical reason (local repo mirror, local API etc.). I will indeed have to fine tune the ACL on squid (or completly disable url previewing), but it's strange that it's needed now while it was working before |
It would help to confirm which version it broke in FTR! 👍 |
I'd have thought that this didn't change anything regarding blacklisting of the final destination but unfortunately the code around the proxy connection stuff is sufficiently complex that it's mostly guesswork without diving into the codebase again :-/. |
I switched to url_preview_url_blacklist, which I must admit makes more sense when using a proxy. It's working well. So maybe, this would just need a small doc update to indicate that url_preview_ip_range_blacklist shouldn't be used when using a proxy. |
I'm going to close this as the main issue seems to be resolved. If anyone fancies putting up a PR to update the docs on |
So to boil this down into some useful documentation going forward, the issue was that adding an IP range to Would it be better to just ignore this option when a proxy is in use? |
Was that the actual issue? It doesn't seem to match the OP's report. It feels like HTTP_PROXY and HTTPS_PROXY should be exempt from
I'd think if someone is setting |
Oh indeed, that was the conclusion I arrived from given later comments, but from the original report it looks like the problem is much simpler. The documentation that needs to be added would be something along the lines of "The That coupled with allowing If that all sounds right I can put it into a new issue 🙂 |
This is already true as of #9084.
I agree that this is what might make this less confusing. |
Description
URL preview is not honoring url_preview_ip_range_blacklist anymore since 1.25 (or was it 1.26 ?)
Steps to reproduce
I have enabled url_preview in my config and configured ip blacklist so private IP are not previewed
This used to work as expected, but since a few versions, it's not honoring url_preview_ip_range_blacklist anymore. URL corresponding to private IP are being previewed. I haven't noted the exact version in which the problem was introduced but I think it was either 1.25.0 or 1.26.0
Version information
The text was updated successfully, but these errors were encountered: