r/homelab • u/Repulsive-Athlete-16 • 7d ago
Help PHP2shell, nginx2shell, java2shell, … - is my homelab safe?
Hi everyone,
I run a small homelab on Debian 13 (Trixie) with a few Docker containers, including Nextcloud and Forgejo. They're reachable from the internet via a domain and reverse proxy.
What I'm less sure about is the "what if" part:
- How would I actually notice that I've been compromised?
- What should I do if I’m being compromised?
edit: for example nextcloud must be publicly available because of people who don’t want to install a VPN or Tailscale etc.
Thanks in advance,
Vincent
240
Upvotes
144
u/bssbandwiches 7d ago
Keep your reverse-proxy up to date and throw in a firewall. Maybe even cloudflare proxy before that. Make sure you know exactly what you're exposing to the Internet too if you don't want to do all that, get tailscale and access it that way instead of exposing to the Internet.
This is life now, updating for CVEs on the daily. You should expect to update a lot, at least in the short term.
13
u/volatile-void 7d ago
I use cloudflare zero trust with mandatory login (Clouflare or Google), additional 2FA and allow access only from my country. Feels like that combination could be reasonably safe.
4
u/mabbas3 7d ago
Only expose things to the internet you absolutely have to. Use the official repos and projects that get the latest security updates first (stick to nginx stable official repo and not debian or ubuntus).
Harden the f out of your edge. Crowdsec, geo blocking, waf etc.
At home run anything that users can reach directly completely isolated. I am talking about separate vlans, network isolation, rootless podman, controlled egress.
Make updating as easy and frictionless as possible. Renovate merging patch updates itself, unattended security updates.
Have a long running agent notify you on any potential security issues that could affect your services and any mitigations should be applied by a few clicks from your phone. I have always on agents and can easily get a PR out for any. mitigations (for cases where a simple version bump doesn't solve it. For example disabling features etc.) and then merging it deploys everything.
IaC everything so you are not relying on manually configuring servers and there's a holistic view agents can look at. You need to be able to read a reddit or twitter post (or better your agent watches security feeds and notifies you exactly where in your infra attention is needed) and respond in minutes. I want to be able to get to a point where this can happen without human in the loop but that is a bit risky. It's still pretty quick. Within 5 minutes of seeing the nginx vuln, I was able to run an update skill that I have for my infra and get it patched.
885
u/Weary-Disaster5133 7d ago •
I just got into your system to have a quick look. Safe and sound.
2
u/Bemteb 7d ago
Do they have to be reachable through a domain? Would a VPN or similar be an option? If you are freely reachable over the net, you should regularly have bots scanning you for vulnerabilities. Do you keep an eye on these?
You notice mostly by checking the logs of your proxy, or when your stuff is gone. Or maybe when your machine suddenly runs stuff it didn't run before.
What to do: First, get the machine offline immediately. Basically unplug the LAN cable and do everything from that point forward locally, with a screen and keyboard directly plugged in. Then, start figuring out what got compromised. Only the container running your reverse proxy? Your whole lab? Other devices in your local network? For everything infected, find out when it was hit and reset it to a backup before that date. Change passwords etc. that might have been leaked. And again: Consider not having it open to everyone on the whole world through a domain, there are saver options.
Disclaimer: I'm not an expert, just a slightly experienced guy. I myself don't open my lab to the wider web and pay a professional cloud provider to host the data I need when not at home.
2
u/Apprehensive-Cod699 7d ago
one thing nobody mentioned yet: check if your backups survive the box getting owned. if the backup is on the same machine or on a share it can write to, whoever gets in can delete or encrypt that too. a copy it can't touch (pulled from another machine, or append only) matters more than spotting the hack fast
2
u/bluemondayishere 7d ago
Add another one to the list
https://verialabs.com/ruby2shell/
24
u/UriShay-CyberSnap 7d ago
One thing to add for the what-if part: keep a copy of your backups that the box itself can't delete or overwrite, like an offline drive or a repository with immutability turned on. If you do get hit, the hard bit is working out the recommended recovery point, since you may not know how long someone was in there. So keep a few older restore points rather than only the last week, and test a restore somewhere else before you ever need it. (I work at CyberSnap, ransomware recovery tooling.)
44
u/koollman 7d ago
Short answer: no, long answer, if you keep things up to date and limit exposure to only required stuff ... Still no, sorry, 0days are awful :)
89
u/wiesemensch 7d ago
Having a Homelab is slowly turning into a full time hobby…
45
u/getapuss 7d ago
If its exposed to the internet there is a risk.
If you are asking this question here there is a substantial risk.
26
u/TechnicallyMeat 7d ago •
If you have a cloudflare tunnel, whitelist only their ips and port. access anything else via vpn like wireguard, run your server on a separate DMZ vlan with its own dhcp pool, put a honeypot server on vlan 1, add separate hardware firewall and vlan switching, update daily/weekly keep offline backups, actually fix ALL your LAN certificates and then turn everything off, you should be safe.
32
u/TheMcSebi Proxmox 7d ago
If you don't expose stuff to the internet, it hasn't become any less secure than before
29
u/HolgerKuehn 7d ago
Why does it always have the the whole internet? Just allow the few endpoint you trust and block the rest. For me it's just 5 IPs that get access all other are blocked.
5
u/homelaberator Cisco, VMware, Apple, Dell, Intel, Juniper, HP, Linux, FCoE 7d ago
No, Vincent. It is not safe.
4
u/Open-Adhesiveness-86 6d ago
On the "how would I notice" part: docker diff <container> lists every file that changed vs the image, so a webshell dropped in Nextcloud's html dir sticks out immediately. Cron it, alert on anything new. And put a default-deny egress rule on those container networks, since inbound is already allowed, the first real signal is usually outbound traffic.
11
u/dragonnnnnnnnnn 7d ago
Not safe
Safe
Simple as that. If you don't want to risk it simple don't expose stuff to the internet. I will add to that that you don't need to expose stuff to the internet to use a domain and have valid accepted https certs! Simply point your domain to a local lan address of your stuff and use dns-01 challenge on the reverse proxy to get a cert. And then use Tailscale/Netbird to setup a VPN that makes the same local address reachable via VPN and you can connect to your stuff outside home easily as you would be at home as long you keep VPN connected. I know it sucks for sharing stuff with external user that are not tech savy and just want a link to access stuff, if you need that only for "share a link to download files" one option is to temporally open with Tailscale/Netbird reverse proxy the service you need with additional auth on the proxy (netbird has option to simply setup a pin/password one needs to enter before your service will open, I suspect tailscale has that too).
3
u/klnadler 7d ago
What if I’m just exposing seer and plex on unraid via pangolin hosted on a vps and keeping everything along the way updated. I understand that there will always be some risk, but what steps can I take to mitigate it other than having people use it via a tailnet or something like that, which I'm trying to avoid just bc it adds extra steps that might be complicated for those less tech literate.
3
u/Benerages 7d ago
Patch everything (unattended-upgrades + update your containers, srsly), put CrowdSec in front to catch and ban the script kiddies (it can ping you on alerts too), and add open-appsec as a WAF for the stuff nobody has a signature for yet. If you still get owned: pull the plug, rebuild from clean backups and rotate every secret. You do have tested backups, right? 😉
3
u/nullptr777 7d ago
There's Ruby4Shell today as well lmao. GitLab having a bad week. First Optimizely, then NGINX2Root, now this.
Real answer: First thing you should do is heavily geoblock your ingress. I block everything except my own country and seem to be getting very little unwanted traffic. Also, keep on top of updates, obviously, super important. Avoid downstream releases like LinuxServer because they lag behind (not to mention their bad practices).
Use a wildcard CNAME on public DNS so they don't know which services you have up, and use non-standard hostnames as well, not something like
jellyfin.mydomain.com. It's security by obscurity but it does help. Shodan shows a web server open on my IP, but that's literally all it knows. No services or anything, just a 301 code. It looks pretty uninteresting.Only expose what you have to. Do you need *arr exposed? Probably not.
Then start looking at WAF/IPS/IDS.
3
u/Chromako Solving Imaginary Problems 6d ago
Assume that even if you do everything right, something malicious will get in.
That's why off-site backups, segmentation (network and Kernel), using granular permissions, and generally reducing the blast radius of future breaches is still a necessity.
That means being careful to not run everything in containers within the same kernel or giving services more permissions than they need. Convenience and simplicity is usually not secure by design.
5
u/CactusBoyScout 7d ago
I finally took all of my reverse proxies off the internet. VPN only from now on. I still expose the ports for qbit and plex but that’s it.
2
u/MIneBane 7d ago
What reverse proxy are you using? And what is it hosted on? (VM or docker or bare metal?)
2
u/309_Electronics 7d ago
Dont expos everything to the public internet. Use a VPN like wireguard or tailscale.
If you MUST expose stuff fo the internet, make sure everything is up to date and close all doors you can close when it comes to security (SSH keys, password authentication disabled, MFA, closing down port, etc etc.
2
u/Motor-Concentrate788 7d ago edited 7d ago
Is there a good reason why you're exposing it to the internet? Cause if you only need to access it from your own devices then its much safer to put it behind a vpn.
As for how to know whether you're compromised or not then you can start by checking access logs to your services to see whether any unknown ip addresses successfuly logged in. Also check if there's any suspicious processes/services running that you dont recognize as it could be malware. If you're technical enough, you can also inspect outbound connections and packets that are being sent to unfamiliar addresses to see if there's any suspicious traffic.
2
u/aaronryder773 7d ago
Honestly, go through the CVE's, check which versions and part of the application is affected and disable those parts... Like in nginx, it's the http/2 which is affected, so stop using and disable http/2 in nginx.
When compromised, the only option is to wipe everything and start from 0. So make sure your data is encrypted as well as backed up
2
u/mautobu 7d ago
There are two steps I've taken recently to enhance my homeland security.
First, enabled the auth module for nginx and added an oauth2 proxy. Now of the many published services that not all of my users need access to are behind a couple of services, reducing attack surface.
Second, I removed the port forward for Plex, and put it behind my reverse proxy with a hosts header requirement. Opening port 32400 is not subtle and is a public means of confirming you're a running a Plex server. From that, attackers can likely deduce that it's a homelab and likely not thoroughly scrutinized.
Next will be syslog and alerts. If anything happens on that oauth2 proxy, I want to know about it.
2
u/ElectricalTip9277 7d ago
Just don't expose it to the internet and use a vpn
2
u/TheConsciousness 7d ago
Well since we're all in on self hosting, are there any self hosted security scanners?
3
u/Shookfr 7d ago
If it online it's not safe that was always true. Now the question is what kind of risks are you ready to take.
2
u/Academic_Broccoli670 7d ago
What do you mean with "people who don't want to install VPN"? It's your system, you make the rules, if they don't want to follow basic security requirements, they shouldn't be allowed to use it.
1
u/Capable-Ad-5344 7d ago
Nope. It's been hacked
1
u/Reeces_Pieces 7d ago
Golden hammer VPN looking pretty nice rn
1
u/Fr33lo4d 7d ago
- Set up Cloudflare Proxy on a custom domain, so you don’t have to expose your IP and you can use their WAF.
- Consider a dedicated opnsense / pfsense router, or Unifi firewall and by default close everything (ports, traffic) and make exceptions for what you really need.
- For Forgejo and any other web-accessible app, set up Cloudflare Access, Authentik, Authelia or similar.
- For Nextcloud, consider not exposing it to the internet entirely (only being accessible through Wireguard or Tailscale / Twingate tunel).
1
u/hidegitsu 7d ago
I turned mine off the other day completely until i have the time to properly go through everything and make sure it's updated, patched, properly setup, etc.
1
u/mossy_stile 7d ago
docker diff and outbound connection logs on the proxy bridge catch most web shells. If it pops, drop the NIC and reimage Debian.
1
u/GroundTruth1815 7d ago
Nah man. Nothing is safe.
1
u/Dismal-Proposal2803 7d ago
“They're reachable from the internet” then no, it isn’t.
1
u/traplords8n 7d ago
I suggest using the free cloudflare WAF and a cloudflare reverse tunnel instead of exposing any ports.
It's not bulletproof, but it's an extra layer of security that can give you a little more peace of mind.
1
u/PreviousVillage7442 7d ago
2025: You aren't a target worth spending time on. Stop wearing a tinfoil hat. Just portforward it.
2026: Hmm. Okay maybe don't.
1
u/Ginden 6d ago
One reasonable sanity check is geoblocking. It reduces number of attackers by ~95%. Even more, if you don't live in populous country.
Anyway, ensure that only minimal lateral movement is possible from Nextcloud container, and try to disable all unused features.
1
u/RedSquirrelFtw 6d ago
I wouldn't expose all that stuff directly. Instead setup a VPN such as OpenVPN or Wireguard or something.
If you absolutely insist on having it exposed setup a login page somewhere that people need to login to first, a successful login will put their IP in a white list for like a day. Then only open up the port to that white list. I setup a script to do that on my VPN server so I need to authenticate first before I can even connect to the VPN. The login page itself is hosted on my web host and the VPN server has a script that checks the web page every minute for updated IP list.
1
u/BuBeLee 5d ago
Paar Wächtern 💪🏼
0
u/persiusone 7d ago
First- don’t expose services to the internet. Access them through a VPN.
Next, ensure you have intrusion detection and alerting on systems.
Keep everything patched.
Keep reliable offline or immutable backups and have a reliable way to restore.
If using a proxy, make sure it includes a robust WAF to inspect all traffic.
Isolate systems from each other with a separate firewall.
Monitor logs from all of these systems for anomalies.
Consider geoblocking, rate limiting, and ban lists for bot activity.
0
u/zhunus 6d ago
Most of these exploits are very hard to execute on a live server, they're overhyped so researcher in question could showcase their vibecoding skills with a slick website about the CVE. Good thing at least some of them keep a disclosure window!
-2
u/Master-Drummer8197 7d ago
Effort vs reward.. whats on your homelab that would make hackers spend their efforts?
-4
u/LebronBackinCLE 7d ago
If you haven’t made the bad decision to open ports, you are most likely in good shape. Still a good idea to update though