HACKER Q&A
📣 convexpolygon

How does my school block DoH?


My school has a bring-your-own-device wifi which obviously necessitates blocking of certain categories of websites. Previously I used to be able to bypass their DNS blocking using DoH, but now this does not work anymore. Instead, trying to access a blocked website gets me a wrong/unsafe certificate warning followed by a Fortinet/Fortiguard blockpage when I click continue. Upon inspection I can see that the certificate is issued by Fortinet, which explains the warning. On non-blocked websites I do not get a warning and the certificate appears correct.

How does this work? Is this some kind of MITM-Attack on me (I do not remember having had to install any special certificates, but I do not know how to check this)? Is there a convenient way to bypass this (i. e. not Tor et al.)?

I respect the IT companys efforts to secure the schools network (The IT company is universally hated by the entire school - They block the sites the teachers want to use, the youtube videos sometimes used for lessons, make the schools computers slow through McAfee and other bloat and prevent us learning about computer networks in class by blocking school-pc-to-school-pc connections in the firewall. Oh, and they also recently took in all the school issued I-Pads for an update only to delete all personal files on them; fortunately I do not use these out of principle, although I believe everyone managed to recover from cloud backups), but I would like to understand what they are doing to the network. Furthermore I am concerned about the legality of what they are doing (German law) and if they are able to read my private data that flows through the network (the network is personal login only, which would make that even worse). Also I find it disconcerting that my school blocks hrw.org (i. e. human rights watch) which I believe sends a wrong message.

If there is any testing I can/need to do for further analysis I would appreciate you telling me. Thank you! This is actually my first post here on HN as a long time lurker.


  👤 schoen Accepted Answer ✓
It's possible that they're now telling the firewall to block sites based on SNI or IP address, which is separate from the DNS mechanism.

If you know the correct IP address for a site, you can use curl or openssl to connect to the blocked site by IP address (but still sending SNI), like

  openssl s_client -connect 93.184.215.14:443 -servername example.com
You can also try not sending SNI, which will remove one means that the firewall might be using to block your connection, but will also likely make the connection not work for server-side reasons if it's hosted on a shared server or CDN.

  openssl s_client -connect 93.184.215.14:443 -noservername
Once you're connected, you can speak the HTTP protocol to the server manually:

  GET / HTTP/1.1
  Host: example.com
  Connection: close

and see what HTML home page content you get.

The output from the openssl s_client command will also show what certificate(s) were sent to you by the other end, and you can look at them using the openssl x509 command for more details about their contents. But you can see very quickly whether the purported issuer is Fortinet or a public certificate authority.

The curl version looks like

  curl -v --resolve example.com:443:93.184.215.14 https://example.com/
There you're telling it what IP address to use (rather than querying DNS for it).

> Is this some kind of MITM-Attack on me (I do not remember having had to install any special certificates, but I do not know how to check this)?

If the MITM attack were successful, you would not get a certificate error. The certificate error is the intended result of a failed attack, because it shows that you did not get a secure connection to the site you were trying to reach.

> Is there a convenient way to bypass this (i. e. not Tor et al.)?

If you have an account on a Unix server elsewhere, you can use ssh -D to create a local SOCKS proxy that forwards web requests through the remote server (assuming that the network doesn't also prevent you from making SSH connections to the server!).


👤 habitue
Wrong / unsafe cert warning means you haven't installed their certs. They're trying to mitm you, but your browser is protecting you.

It's almost certainly SNI, it's the plaintext hostname. Servers rely on it being present to route, so the only way around it is to tunnel through the firewall with a vpn


👤 sprinkly-dust
From my understanding, they are somehow able to intercept DoH and block queries to restricted domains. Perhaps it is through unencrypted Server Name Indication, hard IP blocking, or otherwise.

If you have access to a cloud VPS server, I would suggest you try running an Outline VPN Server instance. https://getoutline.org. By far, it is the most resilient to interception tactics. It was designed for easy use by journalists to bypass censors. Shadowshocks is harder to detect them other VPN types like Wireguard because those don't try to hide themselves at all. They (the IT department) would need some serious kit to detect that kind of traffic and differentiate it from https.

Although, beware that using it 24/7 will still look suspicious to any IT Admin because then all your traffic is going to a single weird server.


👤 notepad0x90
how I've seen it done is by blocking all public DoH servers at the DNS and ip+port level. This isn't hard at all and there are plenty of public and non-public sources that maintain such lists. Since you mentioned forti* and block pages, it is likely that they're using their internal CA instead of a public one which explains the warning you're getting on your device. Fortinet also has the ability to categorize, inspect and block DoH/DoT, check this out:

https://docs.fortinet.com/document/fortigate/7.0.0/new-featu...

For German law, as I understand it, so long as they don't keep logs of traffic they can block whatever they want. Or, they can keep logs that anonymize the source ip and user completely. What they can't do is block a website and record the IP that was making the request without permission from the user that generated the traffic.


👤 convexpolygon
Thanks for all the great answers, I will have to do some reading and testing tomorrow. I knew about the possibillity of IP blocks, but I did not know about SNI, I will have to look into it.

As far as I now understand Forti* seems to be pretty advanced software, so I will see if I can get around it. I have my own cellular, I mostly want to know what they are doing behind the scenes.

Do I understand it correctly that they are deciding based on SNI/IP whether to let my packets through to the destination server - which provides me with an encrypted connection and the correct SSL Certificate such that they can not decrypt my data - or, in the case of a blocked site, reroute my packets to the Forti-Blockpage using the Forti Certificate such that I get a warning? So this is in essence completely decoupled from the DoH step, as at least one person commented.

I do not really have practical experience with networking apart from having ssh'd into a machine inside the same network a few times, so I might use my cellular to see whether its the firewall blocking me or my own stupidity.

What is the general practice on HN for updates, should I find some interesting results? Do I just post comments in this same thread?


👤 PreInternet01
At least Firefox supports a way for LANs to disallow DoH usage via regular-DNS responses: https://kb.isc.org/docs/using-response-policy-zones-to-disab...

Possibly, Chrome/Edge support the same or similiar mechanisms, but I haven't checked recently.

Alternatively, your school uses a HTTPS middlebox that knows how to distinguish DoH requests from regular SSL traffic to 1.1.1.1.

In any case, this is most likely not an 'attack' on you, and characterizing it as such is unlikely to lead to fruitful discussions around the policy.


👤 StephenEven
If you are getting a certificate warning then the dns lookup is succeeding but the (tcp) packets are under inspection (decrypted by the firewall and then re-encrypted). DoH only encrypts the DNS name resolution, which is only one method used by orgs to inspect traffic.

To solve this you need a VPN so that the packets are encrypted by something in addition to TLS


👤 9x39
The simple answer is that it works as you suspected by performing a MITM attack on you (after all, your traffic flows through it), which permits the firewall to snoop on your traffic and perform various analyses.

As others have said, the SNI is not encrypted, so it can do basic category blocking even if your browser doesn't trust the certificate you saw. If it was a school-issued device, the certificate would have been preinstalled as a trusted certificate in the device's root store.

Your options are limited - why not try and see if you can find a gap in the rules via a tunnel or VPN from your device? You could try commercial offerings like Proton, or setup your own OpenVPN, Wireguard, or even try an SSH tunnel. Modern next-gen firewalls (NGFWs) like Fortinet are going to able to detect and block (if configured) many of these techniques, but you never know what's actually configured until you try.


👤 depingus
TLS (websites) on your personal device is not being MITM by the Fortigate. TLS on your school's devices are.

The page you're not seeing with the certificate error is just the "This site is blocked by FortiGuard" page. You're not seeing it because you don't have their cert installed in your device (which is good, don't install it). If you visit a blocked site on a school device, you'll see the page.

Sorry, I don't know how the Forti's block DoH.

To everyone recommending VPNs, SSH, etc: the Fortigate does application control and is going to catch like 99% of those shenanigans.

Side note: Bypassing the network guardrails setup by a school or workplace is usually against their usage agreement. Even if you're not bypassing for nefarious reasons, it's probably not worth the potential consequences of getting caught.


👤 commandersaki
Sydney Airport free wifi has the same setup with Fortigate/Fortinet. They whitelist acceptable domains/websites and prevent access to everything else by supplying their own certificate etc. I couldn't find a way to escape the hostile network, so I resorted to tethering.

I know this to be the case because I couldn't access https://mydomain.net - as it was deemed unacceptable content on their mitm splash page.


👤 userbinator
and prevent us learning about computer networks in class by blocking school-pc-to-school-pc connections in the firewall

That usually tends to cause people to learn more about networks to circumvent those blocks, at least in my experience a few decades ago; but perhaps the population has become too subservient now for most of them to do so.


👤 can16358p
They are very likely keeping track of blocked domains'/DoH servers' IP addresses and have a routing rule that routes packets to those websites to somewhere else, very likely something like "this site is blocked" kind of informational webpage on their servers, but since this is HTTPS the certificates don't match (since the IP department doesn't have the private key of the actual website's certificate) so you get a certificate warning.

I wouldn't accept that certificate, and if you have already done so, I'd remove it immediately from my device's certificate store.


👤 cyberax
Are you sure you're using DoH? Try to monitor the traffic with Wireshark. Then make sure that your school is not just MiTM-ing the DoH server you've set up.

👤 gedy
> My school has a bring-your-own-device wifi which obviously necessitates blocking of certain categories of websites

With cell phones able to access whatever outside your network, what is the purpose of blocking if it's bring-your-own-device? I appreciate the need to follow "policy" and CYA, but this seems a bit pointless if you've already done the basics of your Wifi's default DNS with a blacklist of certain sites.


👤 tetris11
Are you sure it's a DNS problem? The school might just be blocking TLDs or even known IPs before routing the correctly resolved addresses back to you.

👤 leetrout
DoH = DNS over HTTPS

👤 aduitsis
https://support.mozilla.org/en-US/kb/configuring-networks-di...

(You need to setup your DNS to respond in a certain way for a canary domain)


👤 unethical_ban
If I recall correctly, DoH makes calls to IP addresses like https://1.1.1.1 . I assume the security device is able to detect the lack of hostname/SNI and block accordingly.

👤 alt227
> if they are able to read my private data that flows through the network

IMO if you are connected to somebody elses network, you should always assume they can read your private data or any data sent over that network.


👤 SSLy
Probably SNI in HTTPS not being encrypted.

👤 1vuio0pswjnm7
Commenters seem to be convinced the school is filtering on SNI. That could be true. Based on past replies I have received, some HN commenters also believe that the entire web requires SNI. This is not true.

For example, the website hrw.org cited by the OP does not require SNI. The following request succeeds:

   printf 'GET / HTTP/1.1\r\nHost: www.hrw.org\r\nConnection: close\r\n\r\n' \
   |openssl s_client -connect 23.185.0.2:443 -ign_eof -noservername
Unfortunately so-called "modern" browsers disregard this fact and the implications of SNI on web users. They send SNI to every website, irrespective of whether it is required or not. One CDN may offer ECH to encrypt SNI if TLS1.3 is used and the client supports ECH. But one CDN is not the entire web. Needless to say, hrw.org is not using this CDN.

Personally I use clients that do not send SNI by default and localhost-bound forward proxies that allow me to enable or disable sending SNI for any given website.

Interesting that a student would be familiar with "MITM" and "DoH" but oblivious to SNI. SNI predates and defeats any alleged "DNS privacy" of DoH. No MITM needed.

Another test would be to run a local DoH proxy, e.g., AdGuard's "dnsproxy". This way one can avoid the remote certificate check that the so-called "modern" browser is probably trying to perform periodically when using DoH. The computer owner can serve their own self-signed certificate.


👤 cushpush
Yeah, people were shocked when my service allows people to login with any email, but after a while, you need to certify you are the owner by clicking a link only that e-mail can get. What's not to love.

👤 redprince
> Instead, trying to access a blocked website gets me a wrong/unsafe certificate warning followed by a Fortinet/Fortiguard blockpage when I click continue.

This is likely the Fortigate SSL/TLS deep inspection (<https://docs.fortinet.com/document/fortigate/7.6.0/best-prac...>). In short: The Fortigate conducts an organizationally sanctioned MITM attack on your web browsing. You would not get any warning if the public key of the certification authority on the Fortigate had been installed on your client. In corporate Windows environments this is usually done via group policies.

Some websites may appear not to be subjected to deep inspection if those websites were exempt from SSL/TLS deep inspection. They'd be using SNI or the CN / SAN contents of the certificate presented by the website to make a policy decision against an allow or deny list of sites.

Another possible scenario would be that you have the MITM CA installed but the block page your browser gets redirected to by the Fortigate was signed by another CA / self signed. But that would certainly be a misconfiguration on the Fortigate.

Anyway. Your web browser allows you to inspect the certificate and more crucially the certificate chain used to verify the validity of a certificate. Look at the root certificate when you suspect a connection to be inspected. If the name of the root CA isn't already giving it away, you should be able to verify that it is a benign public CA by googling for it.

Given the rest of your experience, I'm guessing the IT staff wants to increase control over what applications and sites can be used over the school network. It is rather easy to detect and block DoH and other possible filter evasions when you can decrypt all communication.

> Also I find it disconcerting that my school blocks hrw.org (i. e. human rights watch) which I believe sends a wrong message.

You can check how a site is categorized by the Fortigate here: https://www.fortiguard.com/webfilter

Currently https://www.hrw.org/ is categorized as "Advocacy Organizations" in the group "Adult / Mature Content". I'm going to guess the whole "Adult / Mature Content" group has been blocked and you found a striking example of over blocking.

Now... what can you do about it? The easiest and least troublesome solution would be to just ignore the nosy IT infrastructure and use the school computers and their network just for the work assigned to you. I'm guessing you have unfiltered access to the Internet off campus anyway. Or you could tether you device to your mobile phone and bypass all filtering that way.

Subverting the school's attempts to limit your access is certainly a possibility given sufficient tenacity to learn and a certain kind of creativity with a tendency to cause mischief. But I'll leave it to you to figure out the details. When your actions get you into trouble: You have asked for it. Act accordingly.


👤 gjsman-1000
> Also I find it disconcerting that my school blocks hrw.org (i. e. human rights watch) which I believe sends a wrong message.

There are many organizations more worthy of attention and respect than the grifter.

https://en.m.wikipedia.org/wiki/Criticism_of_Human_Rights_Wa...