Skip to content

Will Be Installing Arch Soon on a Fresh Box With Security as My Priority. What Are Your Favorite Hardening Techniques (Simple and Complex)?

Removed before it was archived.

Edited 24 Jul 2019. We only hold this version.

42 points48 comments
Open on Reddit
About this post
Posted
Archived
Deleted on
Edited
Score
42 · 100% up
Kind
Text
ID
ce4ef7

52 comments

unknown author14 hidden

Deleted before we saved it.

36 points
unknown author13 hidden

Deleted before we saved it.

5 points

Have you tried the program opensnitch? It's available on the AUR.

I haven't tried it yet, but its supposed to be an application based firewall based on Littlesnitch (Mac program) and of course open.

4 points

I looked a tiny bit into AppArmor, and I got the impression you could use it to do your own application-based firewall. The kernel support for AppArmor is enabled in the normal Arch kernel.

The profile files look pretty simple. You could just ignore everything that AppArmor can do and only look into how the network stuff works.

Then you'd write a script that can show the names of the applications that were blocked from using the network, and a script to create and remove a profile for an application.

1 points
unknown author8 hidden

I would say for "security people" Arch isn't the easiest. You don't get mandatory access controls, and packages are distributed mostly as is.

If you were on red hat, packages might come with selinux contexts, but on Arch, you're on your own if that's what you need.

With that in mind, security can mean lots of different things. No firewall is going to stop you from leaking your Facebook password. So I suppose to that end I would recommend using a password manager encrypting your email when you can.

Use encrypted chat programs.

Don't use your email password as your bank password.

You can look up full disk encryption on the wiki to prevent evil maid attacks. I do recommend that. Who knows when you might lose your laptop.

I would also say docker containerization, even for laptops. If weechat ever decides to download a rogue script, at least it can't see my files. I know that recommendation might be controversial, since who knows that bugs might be provided in the container, but that's another thing you might want.

19 points
unknown author4 hidden

Deleted before we saved it.

1 points
unknown author1 hidden

Cool. I think most people probably have a basic setup. Maybe you should make a wiki article for hardened Arch :) I'd read it.

3 points

Look into Qubes for maximum security and privacy, using it is pretty inconvenient and tough on resources but it's very interesting.

2 points

If you want more control over your packages, you could try Gentoo at some point!

1 points

Would making your own containers be a good idea?

I mean it's not too hard to slap something together with docker.

1 points

You need to keep the containers up to date however and verify that the whole docker supply chain is safe.

6 points

Do you know your threat model? Can you describe it? Without knowing what you're defending against, it's hard to recommend anything.

13 points

Just make sure to set your su password same as your user password :)

5 points

On the complex side: Make your system stateless (it will always boot in exactly the same state each time) and immutable (not even root can change it). Basically that means no updates ever as those change the system state. Considering how often arch changes -- means a lot of reinstalls:-)

It can be done, but you need to automate the install process.or it is no fun. I usually have my server create one or two fresh installations per day for all my machines. Switching into a new installation then only requires a reboot. That is fine for my laptop and thanks to fail-over does not matter for servers.

3 points

Why would you re-install rather than update, what do you win with that?

1 points

What do I win?

The system is stateless: Each boot will result in exactly the same software running in exactly the same configuration. There is no way for that to change, so it does not matter what an attacker does on a system, any change will be undone on reboot. There is no way - not even for root - to do a persistent change to a system that is not detected, cryptography makes sure of that. That makes for a very resilient system that are damn hard to break.

Of course if an attacker manages to break into a system once, that attacker can just repeat the exercise after a reboot:-) The same exploit will work again.

Several known system states (== installation images) can exist next to each other. That makes rollbacks to earlier states effortless.

The diffs between images is rather small, so you can archive lots of them with a backup system doing deduplication. So you can keep lots of old states and document your entire system history that way. Such an archive is nice to have to figure out when your systems contained a certain bug or security problem. You also get full system backups for free.

Doing fully automatic reinstalls regularly also guarantees that you can recreate your system at any time (e.g. when a laptop gets lost or a HDD dies) -- provided you are fully stateless or have backups of extra state like user data.

1 points

encryption with strong password that is different from user passwords or use a key... but encrypt your disks that is pretty much step one

2 points

Dm-crypt full disk encryption. It's pretty simple if you follow the walkthroughs on the archwiki. Just don't forget your passphrase ;)

2 points

SELinux Air gap the system in a Faraday cage Encrypted / and /boot Secure Boot Figure out TPM Install a firewall if you must connect Close open ports (networking) Strong passwords and at least 2FA Ensure physical security Lock it in a safe and never use it.

2 points

It's hard to say without a proper threat model. Here's a basic and pretty functional setup for day to day stuff: Dm-crypt/LUKS + Firejail + firewall (I prefer firewalld but any will do) + custom AppArmor/Tomoyo profiles where needed + Wayland (tough this is debatable, I guess) + select use of docker and VMs when needed. You may want to add a hardened kernel to that but I'd rather stay on the mainline kernel.

PS: if using ssh, disable password logins.

2 points

Besides what everyone is saying if you want really just interested about security then you should try qubes. It is an operative system which priorities security above all and all applications run on different virtual machines.

1 points

Qubes is pretty intense resource-wise, I don't think it's suitable for a laptop

1 points

Set a BIOS password, grub password and encrypt system.

​

Restrict ssh access by username and group.

# vi /etc/ssh/sshd_config

AllowUsers user1 user2

AllowGroups group1 group2

And this: restrict ssh access to key-based only.

PubkeyAuthentication yes

PasswordAuthentication no

​

Firewalld, the applet and firewall-cmd work very well for managing your zones and filters.

​

Tighten down Firefox by running in firejail with apparmour.

Apply recommendations from https://panopticlick.eff.org/

​

Explore using Systemd-nspawn containers as the support is built-in with systemd. https://wiki.archlinux.org/index.php/Systemd-nspawn

​

If you run Steam, put it into it's own systemd-nspawn container to isolate 32-bit binaries from the main 64-bit system.

​

Use a Yubikey and a password manager (local or remote).

1 points

I guess it's natural to use pass with yubikey

1 points

Arch doesn't necessarily imply secure or minimalist. Alpine Linux might be suited to your purpose as well.

1 points

Run anything that touches the internet, or that you are not too sure of as separate "sandboxed" users.

​

This example is for the user called username and runs Firefox as a different sandboxed user (username_web). I've tested it for MATE, but I can't see why it won't work for anything with .Xauthority...

​

I based it off the following article:

http://www.la-samhna.de/library/firefox.html

​

Create your sandbox user with a free UID/GID (I always do my username with _function, so have username_web, username_notes, username_email etc):

sudo groupadd --gid 1012 username_web

sudo useradd -m --uid 1012 --gid 1012 -c "Sandbox - Web" username_web

​

Allow the sandbox user to enter your home directory and read your .Xauthority (I haven't seen the need to allow it to update it...):

sudo setfacl -m u:username_web:x /home/username

sudo setfacl -m u:username_web:r /home/username/.Xauthority

​

Allow your user to edit and do stuff to the sandbox user's home directory. You may need to run this again in the future if something moves a file into the home directory as facl's only inherit on create. I personally using inotify (via incrontab) to monitor a "download" directory and do a clamscan, set rights etc.

sudo setfacl -R -m m:rwX /home/username_web/

sudo setfacl -Rd -m m:rwX /home/username_web/

sudo setfacl -R -m u:username:rwX /home/username_web

sudo setfacl -Rd -m u:username:rwX /home/username_web

sudo setfacl -Rd -m u:username_web:rwX /home/username_web

sudo setfacl -R -m u:username_web:rwX /home/username_web

​

Create a script to run Firefox as the sandboxed user:

sudo su -

mkdir /usr/local/scripts

vi /usr/local/scripts/run-firefox.sh

​

Which contains:

#!/bin/bash

​

HOST=$(hostname)

XAUTH=$(xauth -f "/home/${SUDO_USER}/.Xauthority" list | grep ${HOST} | tail -n 1)

​

su - ${SUDO_USER}_web -c "export DISPLAY=:0; xauth add ${XAUTH}; firefox"

​

Make it executable:

chmod +x /usr/local/scripts/run-firefox.sh

​

Allow your user to run the script as root (I just have all various sandbox scripts comma separated here):

sudo visudo -f /etc/sudoers.d/sandbox

​

Which contains:

username ALL = NOPASSWD: /usr/local/scripts/run-firefox.sh

​

Then as your normal user you can run Firefox with:

sudo /usr/local/scripts/run-firefox.sh

1 points

You can setup 2-step authentication with PAM

1 points
unknown author

Deleted before we saved it.

0 points

You could have a look at flatpaks, those exist for e.g.a lot of gnome apps. They allow for regulated access to the user data / system, similar to how Android does it. I'm not sure though how much effort is done to keep the permissions as minimal as possible, granting all permissions makes an app "just work" without much effort for the packaging guy, right. Also you can partly tweak the permission per each flatpak application through the Gnome settings (kinda similar how e.g. LineageOS allows you to do so). It really is quite interesting, for example https://github.com/flatpak/flatpak/wiki/Portals explains how the user can e.g. open a file with the flatpak app just as he is used to, while the app not having read access to the home directory.

0 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.