by nickelpro · 1y ago · 0 comments
Nobody, nobody, writes application servers with the intent of having them exposed to the public internet. Even if they're completely memory safe, we don't do DOS protections like checking for reasonable header lengths, rewriting invalid header fields, dropping malicious requests, etc. Most application servers will still die to slowloris attacks. [1]
We don't do this because it's a performance hog and we assume you're already reverse proxying behind any responsible front-end server, which all implement these protections. We don't want to double up on that work. We implement the HTTP spec with as low overhead as possible, because we expect to have pipelined HTTP/1.1 connections from a load balancer or other reverse proxy.
Your application server, Gunicorn, Twisted, Uvicorn, whatever, does not want to be exposed to the public internet. Do not expose it to the public internet.
I likewise assume that all servers are insecure, always, and we do not want them exposed without a sane load balancer layer.
Your server was probably not made to be exposed to the public internet. Do not expose it to the public internet.
For rust, go, lua (via nginx openresty) and a few others this is a viable path. I probably wouldn't do it with node (or bun or deno), python, or similar but there are languages where in certain circumstances it is reasonable and might be better.
I'm unfamiliar with the common rust frameworks for http, but find it unlikely the situation is very different.
What application servers have you written? I have never seen an application server readme say DON'T EXPOSE DIRECTLY TO THE INTERNET, WE ASSUME YOU USE REVERSE PROXY.
* "We strongly recommend using Guincorn behind a proxy server" [1]
* "As a general rule, you probably want to: ... run behind Nginx for self-hosted deployments." [2]
* "A reverse proxy such as nginx or Apache httpd should be used in front of Waitress." [3]
For some, like uWSGI, they don't even want to talk HTTP (uWSGI supports its own protocol) and it's just assumed you're using a dedicated webserver to talk to public traffic. [4]
[1]: https://docs.gunicorn.org/en/latest/deploy.html
[2]: https://www.uvicorn.org/deployment/
[3]: https://flask.palletsprojects.com/en/stable/deploying/waitre...
[4]: https://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django...
Also don't expose plain text traffic to the internal corpnet where most attack originate from.