Creating a Debian 13 minimal sys-net with hardening

This guide is for users who want to change their default (XFCE-based) sys-net to a hardened, minimal Debian 13 setup.

Do I need to change my current sys-net?

Likely, no. A default disposable sys-net provided by a fresh Qubes OS installation is reasonably secure for most users. It already isolates your physical hardware and network drivers from the rest of your system. It automatically spoofs your wireless MAC address, prevents hostname leaks and sets your DHCP client ID to match your MAC address to improve your privacy. (Note that only MAC spoofing of wired connections is not enabled by default.)

For the majority of users, relying on the default configuration is safer than a customized minimal sys-net, because it removes the potential risk of manual misconfiguration.

Only for advanced users

This setup requires Linux knowledge. Only follow this guide if you have the willingness to verify the configurations and if your threat model or hardware requires it. You can find the benefits of hardening sys-net further down, directly under the steps.

Steps: Creating a hardened Debian 13 minimal based sys-net

1. Install a fresh Debian minimal. In Dom0 terminal:

qvm-template install debian-13-minimal

2. Install only the essential packages required. In this guide, we choose IWD over wpa_supplicant to reduce the attack surface and to improve resource efficiency.

Note: Since passwordless root is not installed, you will need to open a terminal by running qvm-run -u root debian-13-minimal xterm from Dom0 Xfce4-terminal. Also you’ll need to know how to use xterm.

In debian-13-minimal, run:

  1. For systems with an Intel Wi-Fi card::
sudo apt update && sudo apt install -y qubes-core-agent-networking qubes-core-agent-network-manager network-manager iwd firmware-iwlwifi --no-install-recommends

  1. For systems with a MediaTek Wi-Fi card:
sudo apt update && sudo apt install -y qubes-core-agent-networking qubes-core-agent-network-manager network-manager iwd firmware-mediatek --no-install-recommends

3. Set IWD as WIFI backend and configure Network Manager with the following: (in debian-13-minimal)

sudo nano /etc/NetworkManager/conf.d/90-spoofing.conf
[main]
dhcp=internal

[device]
wifi.scan-rand-mac-address=no
wifi.backend=iwd

[connectivity]
enabled=false
uri=
interval=0

[connection]
ipv4.dhcp-send-hostname=0
ipv6.dhcp-send-hostname=0
wifi.cloned-mac-address=preserve
ethernet.cloned-mac-address=random
ipv4.dhcp-client-id=mac

4. Configure IWD to spoof MAC

Note: Spoofing your MAC address increases privacy. But in some specific threat models, MAC address spoofing may decrease overall security or make you stand out.

Enable MAC spoofing. (in debian-13-minimal)

sudo nano /etc/iwd/main.conf
[General]
AddressRandomization=once
#AddressRandomization=network
AddressRandomizationRange=full

When configuring MAC spoofing, the AddressRandomization should match your threat model.

Once: It will keep the same spoofed MAC address till you reboot sys-net.
Network: Every network sees a completely different spoofed MAC address.

In this configuration once is active.

5. Hardening. (in debian-13-minimal)

These modifications can break other applications, keep in mind that this template should be only used for your sys-net.

sudo nano /etc/modprobe.d/99-security.conf
# If you have Intel
options iwlwifi p2p_disable=1

# If you have MediaTek
# options mt76_core disable_p2p=1

6. Hardening Part 2. Adding hardening sysctl lines. Keep in mind that this setup is tailored for blending in, but with important security improvements included. For example net.ipv4.tcp_timestamps = 0 is more secure but it makes you stand out more, so in this configuration, it is set as 1, what is default. (in debian-13-minimal)

sudo nano /etc/sysctl.d/99-qubes-net-hardening.conf

# Hardening rules/overrides
kernel.kexec_load_disabled = 1
kernel.sysrq = 0
kernel.kptr_restrict = 2
kernel.yama.ptrace_scope = 2
abi.vsyscall32 = 0
dev.tty.ldisc_autoload = 0

net.core.bpf_jit_harden = 2
kernel.unprivileged_userns_clone = 0
vm.memfd_noexec = 2
vm.mmap_rnd_bits = 32
vm.mmap_rnd_compat_bits = 16

fs.protected_fifos = 2

net.ipv4.tcp_rfc1337 = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.default.arp_ignore = 1
net.ipv4.conf.all.drop_gratuitous_arp = 1
net.ipv4.conf.default.drop_gratuitous_arp = 1
net.mptcp.enabled = 0

# as debian default 1
net.ipv4.tcp_timestamps = 1

kernel.panic_on_oops = 1
kernel.oops_limit = 1
kernel.warn_limit = 1
kernel.panic = 10
kernel.traceoff_on_warning = 1

7. Hardening Part 3 (in debian-13-minimal)

sudo nano /etc/security/limits.d/99-disable-coredumps.conf
* hard core 0
* soft core 0

8. Create a DVM Template

Go to Settings, Create New Qube and select Disposable Template
Name it “debian-13-minimal-dvm” and set debian-13-minimal as template.
Set netvm as none

9. Configure debian-13-minimal-dvm to make sys-net sending TTL as 64, to blend in with other Linux devices. Run qvm-run -u root debian-13-minimal-dvm xterm in Dom0 to have root permission to do this steps.

(In debian-13-minimal-dvm)

sudo nano /rw/config/rc.local
# Check name of vm first
REAL_VM_NAME=$(qubesdb-read /name)

# Only set TTL rule if it is vm sys-net
if [ "$REAL_VM_NAME" = "sys-net" ]; then
    # Create the table if it doesn't exist
    nft add table ip target_mangle
    # Create the chain linked to the postrouting hook
    nft add chain ip target_mangle outbound_normalize '{ type filter hook postrouting priority mangle ; }'
    # Force TTL to 64 for all outward traffic (except local loopback)
    nft add rule ip target_mangle outbound_normalize oif != "lo" ip ttl set 64
fi

10. Create sys-net

Already using a disposable sys-net?
Simply change the template to the new created debian-13-minimal-dvm.

Not using a disposable sys-net yet?
Go to settings, create New Qube, choose Named Disposable. Name it sys-net-2.
Set debian-13-minimal-dvm as template and netvm as none
Make sure to enable “provides network”
Make sure to assign your network card in devices tab.
Make sure to enable minimal-netvm in service tab, save all.
Shut down you current sys-net and test your new sys-net-2.

When everything works, change the netvm of your sys-firewall to your created new sys-net-2. Delete your old sys-net and rename sys-net-2 to sys-net.

11. Hardening Part 4, with kernel boot options. Forcing security policy by kernel.

Run in Dom0, Xfce terminal:

qvm-prefs sys-net kernelopts "page_alloc.shuffle=1 init_on_alloc=1 init_on_free=1 ipv6.disable=1 randomize_kstack_offset=on slab_nomerge"

Done!

Some reasons for a minimal sys-net with hardening

Security reasons

Since sys-net is treated as untrusted, we can assume that a sophisticated attacker could gain control over your sys-net vm. Qubes OS is designed to protect the rest of your system from such attacks because your sys-net is isolated.

And if you use a disposable sys-net, an attacker loses all access and must start from scratch after a reboot. That is one of Qubes OS’s powerful tools to protect your system. Hardening sys-net sounds useless.

However, sophisticated attackers with access to your sys-net may still try to use their time inside an active session to break out of the VM and/or gain persistent access. While this is rare, it remains a technical possibility. (One that most users can ignore, but high-risk users must consider.)

Defense-in-depth

In the past, many vulnerabilities in Linux and Xen have been discovered that could affect Qubes OS as well. We can assume that there are almost certainly similar, unknown/unpatched zero-day vulnerabilities in both the Linux kernel and the Xen hypervisor. Hardening sys-net must be seen as defense-in-depth.

By using a minimal template, you remove extra code and tools an attacker could use. By restricting root access and separating user privileges, you limit their options. This makes it much harder for them to gain full control inside your sys-net in the first place.

Overcoming hardware limitations

Using a minimal sys-net with IWD uses less RAM and CPU resources than a sys-net based on a default XFCE template. Switching (correctly) to a minimal sys-net will lead in general to better overall performance.

Devices with limited RAM may also experience issues or crashes when updating a bloated template. An issue I experienced myself on my 8GB RAM device. Using a minimal template allows you to update a smaller essential template separately, which helps prevent resource issues during template updates.

While some hardening steps in this setup are optional if your goal is to reduce resource usage, keeping them is still beneficial for the security reasons mentioned above.

Warning

This template should only be used for sys-net and potentially for sys-firewall. Using this template for other tasks and installing extra software will introduce risks and stability issues. Only install more if you know what you are doing. In that case, consider installing apparmor and modify some sysctl lines.

Final note about this thread

This thread didn’t start out as a guide, so some of the comments below might seem unrelated.

12 Likes

I agree with your mindset and general points. However, it would do some good to provide hard evidence.

Can you provide a reproducible demonstration?

3 Likes

In this specific situation (desire to reduce attack surface), he installed IWD to get a smaller attack surface and get rid of WPA Supplicant, and his NetworkManager spoofing was conflicting with IWD spoofing, results in leaking his MAC and DHCP client id. Also hist hostname was leaking, even he thought settings ipv4.dhcp-send-hostname=false will stop it. He read this somewhere. False did not stopped his hostname leaking, 0 did the job.

This was the fix, to enable spoofing only in IWD conf file and tell NetworkManager below not to spoof at all to prevent conflicts.

[device]
wifi.scan-rand-mac-address=no
wifi.backend=iwd

[connection]
ipv4.dhcp-send-hostname=0
ipv6.dhcp-send-hostname=0
wifi.cloned-mac-address=preserve
ethernet.cloned-mac-address=preserve
ipv4.dhcp-client-id=mac

A typical type of misconfigurations that can happen when people just copy paste settings and don’t verify. Those leaks would not had happen if he used the default Debian xfce sys-net. My post is not meant for active and advanced users, but for the majority who just read discussions here and are often not a member at all. The default sys-net is good enough in general.

5 Likes

Would cloning the default fedora template and removing the browser improve anything safely and simply for sys-net? Or is there a simpler method like disabling the browser in the default dvm?

2 Likes

i would also agree with your statement tommy, though would this not have also happened on any other sys-net by installing iwd and use a misconfiguration? i would suggest why not write up a community guide to give users a step by step guide with all necessary steps to setup a well configured minimal sys-net. like firewall, mac adress cloning/randomizing, i personally dislike autoconnect, in case sys-net is affected and you login it automatically connects, and Mr x can go on with his rampage. I also think running services on a system affect the attack layer. less services listening, means less attack surface, not necessarily better as if you have a wrong firewall setting or your mac is not randomized could spill your device and make you easily identifiable.

2 Likes

I assume (maybe incorrectly) that when people talk about minimal templates they in fact mean minimal templates with the extra packages that the official documentation states (eg sys-net in this particular case). I would be interested in any other packages I need to install to get that extra level of protection. As far as I can tell no other manual configuration is required.

2 Likes

Thanks for the feedback. That is exactly what i want to make clear, “if you are not advanced, keep it like it is and you are more secure”. As i stated for most users there is no reason to configure sys-net at all, even when not minimal. And his hostname leakage had specifically to do with minimal only.

The user i mentioned was mainly a specific IWD situation i noticed myself recently out of many minimal only related issues. Even in this case, to reduce attack surface and choose for IWD, comes from the same desire to do everything to reduce attack surfaces and missing that new risks are being introduced.

There are plenty of other examples that has to do with minimal only, including this hostname leak, that has to do with minimal template. And yes, I would love to provide a guide of the correct way to use Debian minimal for sys-net, but it is something tailored. I could place some general guide, but i want people to see it more as a checklist instead of an official guide.

A clone and remove browser is generally better since it reduces attack surface. But you will have to update more templates and the question is if it is really necessary.

Depends on your threat model, at least install apparmor. (even appormor have not much to arm on a minimal). But minimal means as less code as possible and that will make your sys-net secure. As long as you make sure all leaks are closed, you are fine.

3 Likes

A reproducible demonstration was asked here, so I bring a measurement. The result was not what I expected myself.

I tested on the same machine, wired ethernet, sys-net one by one on three templates: debian-13-minimal, Kicksecure 18 CLI, and the default debian-13-xfce. I looked at the applied state and not at the config files: whether permaddr is present on the interface, what the actual hostname is, and the NetworkManager journal.

All three behave the same.

The MAC on ethernet is not spoofed on any of them, the default full template included. There is no permaddr field, so what goes out is the factory address of the card. The randomization settings that come out of the box are only about wifi.

The hostname on all three arrives from the network. NetworkManager does a reverse lookup of the address it got and takes the name from there, it is written in the journal literally. The qube itself does not send any name.

So for a wired connection the claim that a badly configured minimal is worse than the default does not reproduce. The default does not spoof the MAC on ethernet either. Your examples, iwd against NetworkManager and the hostname option, are about wifi, my measurement does not cover them and does not contradict them.

The practical conclusion is the same for every template: MAC spoofing on ethernet has to be switched on explicitly, nowhere it is there by default. And to verify the real state instead of the settings, like you say, I fully agree, this is exactly how it was found.

3 Likes

Hi guys!

I am new to the methods for establishing security.

On the other hand, I detect different view of the developer and the user.

The user’s point of view is debian-xfce, fedora-xfce are for installing packages, some of which are recommended by colleagues (journalists, teachers, …) . Qubes based on those templates have a risk of security concerns. On the other hand, most users only install GUI applications. The users themselves do not destroy security measures of the minimal templates and qubes directly based on such templates.

A possible tree of dependence of templates/qubes reflecting the user’s idea can be like below.

  • minimal template “without GUI” (no xfce, no gnome, …). I am not sure the GUI interface like the menu is outside sys-net, sys-usb, … or is inside sys-net, sys-usb, … .
    • derived template for stronger security measures.browsers, pdf-viewers and the other software involving hidden access to the network and the filesystem are “disabled”. For the user, the short expression is “do not install anything here”.
      • sys-net
      • sys-usb
      • sys-firewall
    • derived template for GUI. For the user, the short expression is “This is the place to install your software”.
      • work
      • personal
      • untrusted
2 Likes

A follow up to my earlier measurement here, where it turned out the MAC is not spoofed on wired ethernet on any of the three templates, the default one included. So I switched spoofing on and measured the same machine before and after.

The config, one file in the network template:

[main]
hostname-mode=none

[connection]
ethernet.cloned-mac-address=random
wifi.cloned-mac-address=random
ipv4.dhcp-send-hostname=false
ipv6.dhcp-send-hostname=false
ipv4.dhcp-client-id=mac

Before: no permaddr field at all, and the current address starts with the vendor prefix of the board. After: permaddr shows the factory address and the current one is random with the locally administered bit set. The kernel only shows permaddr when the address actually differs, so its absence was the proof that nothing was being spoofed.

About the hostname, and this is the part I think gets missed most often. There are two different leaks. One is the qube sending its name, which the send-hostname settings cover. The other is NetworkManager doing a reverse lookup of the address it was given and accepting the name from the network, after which the qube calls itself whatever the router knows it as. On my machine the network qube was named after the host the router remembers from the OS that used to be installed on that hardware. Disabling sending does nothing against this, you need hostname-mode=none.

The practical point: verify the state, not the setting. Look for permaddr on the interface and at the actual hostname. The setting can be present and have no effect, that is exactly what I had.

2 Likes

I tested the line ethernet.cloned-mac-address=preserve from your checklist on my own machine. Wired connection here, no iwd.

With preserve: there is no permaddr field on the interface at all, and what goes out is the factory address with the vendor prefix of the board. With random: permaddr appears and shows the factory one, while the current address is random with the locally administered bit set. Only that single line differs, everything else is the same, same machine, two restarts in a row.

The kernel only shows permaddr when the current address differs from the factory one. Its absence is the proof that nothing is being spoofed.

I understand the checklist is written for wifi and that in your setup the spoofing is done by iwd, where it works as described. But the ethernet line is in the list, iwd does nothing for a wired link, and the summary section says the sys-net spoofs your mac. Someone on ethernet will end up with the real address and be convinced of the opposite. That is exactly the scenario you warn about at the start of the topic.

Would it make sense to add a note that the spoofing section assumes wifi with iwd, and that a wired connection needs random in NetworkManager instead?

The rest of the checklist I applied and it works. The TTL normalization and the sysctl set are especially useful, thanks for those.

2 Likes

IWD only spoofs WIFI Card addresses. Set indeed random in NM for ethernet only. I edited the settings for people who use ethernet and want to spoof. And good that you verify, that is the whole purpose of this post. Only do something advanced if you can verify. But keep in mind, spoofing ethernet is for most people irrelevant and not really needed, compared to WIFI card spoofing which broadcast your hardware IDs. Ethernet is usually plugged in a trusted (often permanent) device, so spoofing makes less sense and no hardware ID’s can be intercepted locally in the air. That is why it is often not spoofed at all, even by privacy focused users.

You are welcome.

2 Likes

Thanks for fixing it that fast. And thanks for the topic itself, I have been reading what you write for a long time and it helped me more than once.

About whether spoofing on ethernet is worth it, I agree with you. For a machine that sits on one desk and is plugged into its own network there is not much point. Nothing goes into the air, there is nothing to intercept from outside.

Let me add my own case to that, if I may. I run a system that lives entirely in RAM and keeps nothing about itself between boots. The whole point is that two sessions on the same hardware cannot be tied to each other. And the hardware address turns out to be the only thing that survives a reboot. Everything else is gone, that one stays the same in the logs of the network. You do not need to listen to the air for it, the side you connect to is enough.

So the threat here is not “someone nearby is picking up the signal”, it is “the same observer sees it is the same device again”. For a laptop at someone else’s desk, or for a machine that should look new every time, a cable is no better than wifi in that respect.

But that is a narrow case and your wording is right for most readers. I would only say not “not needed” but “not needed if the machine is permanent and the network is trusted”, then people can tell whether it is their case or not.

In case it is useful, here is how this can be checked in practice. One line, nothing to install, run it inside the network qube:

ip -d link show <interface> | grep -o 'permaddr [0-9a-f:]*'

With preserve the output is empty. There is no permaddr field at all and what goes out is the factory address.

With random you get permaddr xx:xx:xx:xx:xx:xx, that is the factory one, and the current address is a different, random one.

The kernel only shows permaddr when the current address differs from the factory one. So the absence of that field is not “no information”, it is direct proof that nothing is being spoofed. I find this easier than reading the settings, because a setting can be there and do nothing, which is exactly what I had.

A generated address can be told apart from a factory one by the second bit of the first byte, it is set on a locally administered address.

The way I would test it: change exactly one line, restart the qube, look. One machine, two restarts in a row, nothing else touched, otherwise you cannot tell what actually did it.

One more observation while we are on verifying. When I turned on iwd for wifi on the machines that have it, the wired side did not break. NetworkManager keeps spoofing ethernet, iwd takes care of the wireless one. So it ends up being one settings file for all the machines instead of “here like this, there like that”. I will check the wireless half separately and report back.

2 Likes

Glad to know and good luck with testing.

Just to make sure you double check, IWD spoofs differently than NetowrkManager. It shows the spoofed MAC only (as if it is not spoofed) so without permaddr. The system thinks it is the permaddr since it gets spoofed in a much earlier state than NM. But on format you can tell if it a spoofed one or not.

3 Likes

Thanks, that is an important correction and I would have walked right into it.

If I understood you right: iwd sets the address earlier than the kernel records the factory one, so there is no permaddr field at all, which is exactly what it looks like when nothing is being spoofed. So my check is valid for ethernet, where NetworkManager does the spoofing, and gives a false negative on wifi.

That leaves the address itself to look at on wifi: the second bit of the first byte is set on a locally administered one.

I will check it on a machine that has wifi and report back. Good that you said it first, otherwise I would have seen “not spoofed” and gone off fixing something that was not broken.

2 Likes

Thanks, that looks pretty neat.

That’s a lot of installed stuff though. Mac spoofing, Hostname randomisation etc. can be done quite easily with OpenBSD Sys-Net.

OpenBSD can also be made quite minimal by only installing Base during the install.

It can also be stripped down.

I wonder how this would compare to that. (It’s much more difficult to make it disposable though.)

2 Likes

Exactly. Also in case of a NetworkManager crash/error while connected, the system might fall (in worse case) back to the permaddr while still connected and expose your real permaddr. The benefit of IWD spoofing is that even when a crash happens the default and only MAC is still the spoofed MAC.

Thanks for the feedback.

Absolutely. OpenBSD has security benefits, can be made minimal etc. Making it disposable is harder, but still doable for advanced users. The reasons i choose debian minimal over OpenBSD is cause it has no native Qubes integration (Xen protocols), what introduces new risks.

And for users in high surveillance states, it’s fingerprinting and behavior is different than the mass and that makes those users like journalists etc standing out. It is like you tell adversaries, “if you have limited money and resources to check everyone more deeply, spend it on this OpenBSD user and go check his laptop, since he might have something to hide for us”.

2 Likes

which threat model is this for and is there common issues?

3 Likes

I had an issue within a dvm spawned that i could not access the saved configs for networks adjusted. With root it showed on

nmcli general permissions

all results with yes, using a normal user it showed on org.freedesktop.NetworkManager.network-control and
org.freedesktop.NetworkManager.settings.modify.system
auth.
As i purged passwordless root (what caused the issue) though as i dont like to allow passwordless root, a simple polkit adjustement is needed.
/etc/polkit-1/rules.d/49-polkit-networkmanager-user.rules
polkit.addrules(function(action, subject)
{
if (subject.user === "user" &&
(action.id === "org.freedesktop.NetworkManager.settings.modify.system" ||
axtion.id === "org.freedesktop.NetworkManager.network-control"))
{
return.polkit.Result.YES;
}
}};

2 Likes

This setup is for security on purpose without pass wordless root. To edit the dvm configuration files, like rc.local, you have to run in Dom0 qvm-run -u root debian-13-minimal-dvm xterm first. Than you have the permissions to edit files in dvm.

2 Likes