Security blindspots for selfhosted website
from psoul@lemmy.world to selfhosted@lemmy.world on 12 Nov 2024 07:24
https://lemmy.world/post/21924208

Hello. I’m pretty new here. I just managed to get my Raspberry Pi setup at home to selfhost a simple website that will act as my portfolio for some art I do.

I’m using WordPress to make the content of the website, meaning it runs on Apache, MariaDB and MySQL in the background. It’s connected via port 80 since I don’t want to pay for SSL certificates to setup https. There will be no accounts or transactions happening on my website. I don’t have anything to manage my dynamic IP but I’ll figure that out later. I’ve deleted the default Pi user on the RPi.

Are there security issues I should address preemptively? I’m worried for instance that I am exposing my home network, making it easier for someone to breach into whatever is connected there.

Any tips on making sure my setup is secure?

#selfhosted

threaded - newest

diminou@lemmy.zip on 12 Nov 2024 07:26 next collapse

Take a look at certbot. You don’t need to pay for ssl and ssl is actually pretty mandatory for anything served on the internet.

Make sure you don’t forward too much ports. And make sure you have a working firewall that only allow those same ports. You should be good to go then.

mhzawadi@lemmy.horwood.cloud on 12 Nov 2024 07:33 next collapse

Also be advised that wordpress will attract all the internet to try and hack in, so make sure you keep everything up to date

pHr34kY@lemmy.world on 12 Nov 2024 07:40 collapse

Setting up fail2ban to block people trying to brute force the admin panel is a good start.

undefined@lemmy.hogru.ch on 12 Nov 2024 08:18 next collapse

I would add from an end-user privacy perspective, they might want HTTPS. If I hit a website not using HTTPS, I pretty much immediately back out. Bad actors like hostile governments and hackers can use seemingly meaningless data against you.

I can’t remember exactly what happened but I remember back when WebMD was fighting against rolling out TLS hackers were able to find medical weaknesses against people.

terminhell@lemmy.world on 13 Nov 2024 01:52 collapse

Not too mention the scary browser warnings. It’s not a good look tbh if this is your portfolio. Lots of great considerations and tips here already though.

psoul@lemmy.world on 12 Nov 2024 22:54 collapse

Noted ! I’ll make sure to set https up.

Tbh, I haven’t heard the word firewall since probably 2005… would my router have a firewall built in or is that something I need to add on, let’s say, the RPi ?

acockworkorange@mander.xyz on 13 Nov 2024 00:20 next collapse

Add it to the Pi. Easier maintenance.

diminou@lemmy.zip on 13 Nov 2024 08:32 collapse

Was going to say exactly the same thing.

Even if your router have one, better safe than sorry!

undefined@lemmy.hogru.ch on 13 Nov 2024 03:22 collapse

Your router probably does have one, but your end devices should too. If your router is some piece of trash ISP-supplied one, it might not even have a firewall for IPv6 (if it even supports IPv6 at all).

iii@mander.xyz on 12 Nov 2024 07:43 next collapse

Keep wordpress up-to-date, and keep the number of plugins you use to a minimum.

rimu@piefed.social on 12 Nov 2024 07:58 next collapse

The WordFence plugin is a must-have for security.

If you use Caddy instead of Apache then you get SSL automatically. You'll need php-fpm as well, tho.

foggy@lemmy.world on 12 Nov 2024 11:03 next collapse

Agreed on word fence.

psoul@lemmy.world on 12 Nov 2024 22:51 collapse

What does WordFence provide that makes it a must have?

rimu@piefed.social on 12 Nov 2024 23:40 collapse

After X attempts to log in, it bans the IP address.

It will scan your wordpress files and alert you if any of them have changed in suspicious ways (hacked).

It can disable the xml-rpc endpoint which is rarely used and is a big vector for hacking.

... and a lot more but those are the main ones for me.

psoul@lemmy.world on 13 Nov 2024 17:50 collapse

Sweet thanks! Will add that ASAP

486@lemmy.world on 12 Nov 2024 08:12 next collapse

Unless you require the dynamic features of Wordpress, you could have a look at some of the static site generators out there (such as Hugo). Having a static site would reduce the attack surface considerably. Also due to the shenanigans happening with Wordpress at the moment, I would be weary of using it.

About SSL, what others have already mentioned, SSL certs are available for free these days, thanks to letsencrypt.

skilltheamps@feddit.org on 12 Nov 2024 08:29 collapse

There are also static export plugins for wordpress. One needs to get rid of comment boxes and such as they don’t work then of course. But if all content is already in WordPress, serving just the static export is a low friction solution.

undefined@lemmy.hogru.ch on 13 Nov 2024 03:24 collapse

I’d almost go through the trouble of getting the content out of Wordpress. The nice thing about static site generators is you can completely switch out the framework, runtime, base Docker image and/or OS at any time.

StrawberryPigtails@lemmy.sdf.org on 12 Nov 2024 10:56 next collapse

since I don’t want to pay for SSL certificates to setup https.

You don’t need to pay for SSL certs anymore, most of the time. You can get them for free from a bunch of different places now. I use Let’s Encrypt. The web server/reverse proxy I use, Caddy is able to automatically get a cert for you, install it, and keep it renewed. The only time you need to pay for a cert is if you are handling financial transactions.

Are there security issues I should address preemptively?

WordPress itself has a generally good reputation for security, though depending on how the current drama goes, that may change. WordPress security problems have almost always stemmed from plugins or poor password hygiene. Remove any plugins you are not actively using, keep the ones you are using updated, and use a good password that you don’t use anywhere else. A password wallet like Bit Warden can generate and store such passwords for you.

Better on the security front would be to evaluate whether you actually need something like WordPress at all. A static site would likely be far more secure. There’s less moving parts that might be vulnerable.

While you could program a static site yourself, it’s more common nowadays to use a static site generator like Hugo to build the site. You set it up once for how you want the site to look and then you write your posts in markdown or whatever your particular generator uses.

I don’t have anything to manage my dynamic IP

Most domain name providers have some sort of setup for dealing with dynamic IP addresses, a program called ddclient is pretty common and is available in most repos.

StrawberryPigtails@lemmy.sdf.org on 12 Nov 2024 11:02 next collapse

To add to this, you might check out some of the free Hugo themes here: themes.gohugo.io/tags/portfolio/

psoul@lemmy.world on 12 Nov 2024 22:50 collapse

Wow lots of info. I’ll check all of this out. You have a good point that I don’t need wordpress. Hugo looks interesting, thanks for the advice!

And yes, as said above, I’ll look into the free SSL certs to setup https.

i_am_not_a_robot@discuss.tchncs.de on 12 Nov 2024 14:25 next collapse

It may or may not be a concern to you, but if you are hosting it from your home then people will be able to determine your IP and rough physical location.

If you’re on American cable internet and expecting a lot of traffic, your upload speed may become a problem.

psoul@lemmy.world on 12 Nov 2024 22:47 collapse

Your first point is a good point. I guess it’s ok for now if my rough location is accessible. It’s not like my art is worth anything.

Regarding upload speed, yeah I know it could become an issue but since it’s just a portfolio website, I don’t expect more than a dozen visits a month.

WhyJiffie@sh.itjust.works on 13 Nov 2024 04:43 collapse

scraping bots are expected to visit it, nowadays more than in previous years. a few of them are search engines, but there’s a lot of scraping for AI training, both on text and image data.

Shimitar@feddit.it on 12 Nov 2024 17:19 next collapse

Go https, today there is no real reason not to and tons of good reasons to do it.

Let’s encrypt is 100% free and using their certbot its also automated and easy to do.

psoul@lemmy.world on 12 Nov 2024 22:44 collapse

Thanks, I’ll look into it. I didn’t know there were free SSL certs out there

Rin@lemm.ee on 13 Nov 2024 09:31 collapse

Yeah, afaik, you just need to install letsencrpyt and then run the command with sudo. It’ll scan your apache conf and generate you an ssl version. Just make sure to include your domain name in the ServerName directive

teawrecks@sopuli.xyz on 12 Nov 2024 18:20 next collapse

Let’s Encrypt is good practice, but IMO if you’re just serving the same static webpage to all users, it doesn’t really matter.

Given that it’s a tiny raspi, I’d recommend reducing the overhead that WordPress brings and just statically serve a directory with your site. Whether that means using wp static site options, or moving away from wp entirely is up to you.

The worst case scenario would be someone finding a vulnerability in the services that are publicly exposed (Apache), getting persistence on the device, and using that to pivot to other devices on your network. If possible, you may consider putting it in a routing DMZ. Make sure that the pi can only see the internet and whatever device you plan to maintain it with. That way even if someone somehow owns it completely, they won’t be able to find any other devices to hack.

[deleted] on 13 Nov 2024 09:35 collapse

.

[deleted] on 13 Nov 2024 03:58 next collapse

.

Rin@lemm.ee on 13 Nov 2024 09:35 next collapse

If you care enough to set up, you can use cloudflare. They do some basic caching, certs, ddos protection for free.

Evotech@lemmy.world on 13 Nov 2024 10:31 next collapse

Definitely use cloudflare in front of your website

Boomkop3@reddthat.com on 13 Nov 2024 10:36 next collapse

In my experience cloudflare has an issue with being slow

Sproutling@lemmy.ml on 13 Nov 2024 21:36 collapse

Yes and no. It’s great for hiding your IP and preventing DDOS attacks, but it does require you to use their certs, which means they technically have access to your data. Cloudflare is pretty trustworthy, but the risk is still there.

Evotech@lemmy.world on 13 Nov 2024 21:39 collapse

If the option is no certs…

psoul@lemmy.world on 13 Nov 2024 20:40 collapse

Alright everyone, thank you so much for your thoughtful recommendations! To sum it up, here’s what I have done:

  • I used let’s encrypt’s Certbot to get my SSL certs and setup https, auto-renew every 3 months and I setup a reminder to update Certbot every month.
  • I setup a permanent redirect from http to https in Apache
  • I installed a firewall on the Pi, only 80, 443 and [22 from my computer to the RPi] are open. I couldn’t find the firewall settings on my router but I assume they exist since I had to forward 80 and 443 there.
  • installed the following plugins: WordFence and WP Fail2Ban
  • changed the user password on the pi to a better longer one

I think I should be all set, shouldn’t I?

Sproutling@lemmy.ml on 13 Nov 2024 22:00 collapse

You may want to consider dockerizing your services just for maintainability and isolation from your host. I recommend something like Nginx Proxy Manager to serve as the “main entrance” for your docker network and to handle Let’s Encrypt for you.

werefreeatlast@lemmy.world on 14 Nov 2024 20:26 collapse

I second this. I didn’t understand that until…you know, like you install the latest python or something and then your website is proof! Gone. Dockerization gives it a little bit of stability.