[Solved] hardening lighttpd serving WPAD Raspberry PI Zero 2 W
Added by jonathanlee 24 days ago
Hello fellow Lighttpd community members can you please help?
I am running WPAD over lighttpd on a Raspberry Pi Zero. Is there any security hardening that can be done with changing permissions on the /var/www/html files, and or adding users or groups? Or should one just leave it as default?
Thanks, It is very basic as the http server manages wpad only. However not many users out there use WPAD proxy.pac wpad.dat wpad.da files over lighttpd. I have asked several places however no replies.
Thanks for all you do.
Side note I really do not understand why WPAD has never been updated to something like WPAD2.0 protocol because of the associated risks with it. It seems from a security perspective that big tech should update this older protocol.
Replies (3)
RE: WPAD Raspberry PI Zero 2 W - Added by gstrauss 24 days ago
Security hardening of any webserver starts with restricting permissions to only what is needed.
If you do not need the webserver to run as root, then you should run the webserver as a less-privileged user, e.g. I believe Raspberry Pi Zero runs lighttpd as user www-data
by default, but you should check. The Debian-based Raspberry Pi sets up various permissions and locations for lighttpd to write access and error logs, jobs to clean up temp files, etc, so changing user under which the webserver runs requires additional steps to get back the functionality. Prefer to use www-data
.
If you do not need the webserver to be public-facing, make sure to configure the webserver and/or firewall so that the webserver can only serve requests from the local networks.
If you do not need the webserver to do anything besides access files read-only, then you should might consider making the document root owned by a different user and read-only to webserver user.
For lighttpd, if you are only serving read-only files, then you should restrict the size of HTTP requests to a low (non-zero) number. (0 disables the limit) See server.max-request-size
For resource-constrained servers like the Raspberry Pi Zero, you might tune the server to reduce the chance that malicious clients can deny service to others. However, if you're serving wpad, that should be on an internal network, not internet-facing, so you should configure lighttpd to listen only on your internal network IP, and not on a public-facing IP. You could also configure lighttpd and/or your firewall to only allow access to port 80 via the local network.
If you do not need access logs, then you might disable access logging in lighttpd to reduce resource usage.
If you are only serving static files, you might reduce connection timeouts since you expect lighttpd to serve files very quickly.
If you are only serving wpad, then you might reduce the number of keep-alive requests allowed per client before lighttpd closes the connection.
Besides running as non-root, and listening and serving clients only from local network (not internet), which are strongly recommended for security hardening, the rest is resource tuning for availability and performance. Still, even without extra tuning on a Raspberry Pi Zero, you should find that lighttpd can serve thousands of requests per second for a small, static wpad file (proxy.pac or wpad.dat)
See WikiStart and links to
Docs_ConfigurationOptions
Docs_ResourceTuning
Docs_Performance
Side note I really do not understand why WPAD has never been updated to something like WPAD2.0 protocol because of the associated risks with it. It seems from a security perspective that big tech should update this older protocol.
Look up "zero trust architecture" in a search engine.
If you the clients already have pre-installed an SSL certificate for the the proxy you assign, and only uses https, then a malicious wpad won't be able to direct the client to send http requests through a rogue server without certificate failures.
Still, on new networks, if you have not already pre-configured (more secure), then many architectures follow TOFU (trust on first use) principles.
RE: [Solved] hardening lighttpd serving WPAD Raspberry PI Zero 2 W - Added by jonathanlee 20 days ago
Thank you for your reply
RE: [Solved] hardening lighttpd serving WPAD Raspberry PI Zero 2 W - Added by jonathanlee 20 days ago
$HTTP["remoteip"] != "192.168.1.0/27" { url.access-deny = ( "" ) }
Or more granular:
$HTTP["remoteip"] != "192.168.1.0/27" { $HTTP["url"] =~ "^/(?:wpad.dat?|proxy.pac)" { url.access-deny = ( "" ) } }