Files
nix-config/hardening
Ryan Yin af0ef6d154 flake.lock: Update
Flake lock file updates:

• Updated input 'nixpkgs-patched':
    'github:ryan4yin/nixpkgs/d373b16187b32770d99f6ff54a133d9543e68702?narHash=sha256-75W3YfzkkKvpE3/wtHMihlT9kOnQZxWpLoshw1xu0T8%3D' (2026-03-20)
  → 'github:ryan4yin/nixpkgs/4425024452e93ce3d10e11bcd9b47f1dfa78593b?narHash=sha256-pu3loLm4gvcbh8iibeYDGgPHOVFXb8sAKEzJ9AxX5L4%3D' (2026-06-03)

fix: qq
2026-06-03 11:56:48 +08:00
..
2026-04-28 12:43:32 +08:00
2026-06-03 11:56:48 +08:00

Linux Hardening

Work in progress.

Goal

  • System Level: Protect critical files from being accessed by untrusted applications.
    1. Such as browser cookies, SSH keys, etc.
  • Per-App Level: Prevent untrusted applications(such as closed-source apps) from:
    1. Accessing files they shouldn't.
      • Such as a malicious application accessing your browser's cookies, SSH Keys, etc.
    2. Accessing the network when they don't need to.
    3. Accessing hardware devices they don't need.

Current Structure

1. System Level

  • AppArmor (apparmor/): AppArmor profiles and configuration
  • Kernel & System Hardening (profiles/): System-wide hardening profiles

2. Per-App Level

  • Nixpak (nixpaks/): Bubblewrap-based sandboxing for applications
    • Firefox configuration
    • QQ (Chinese messaging app) configuration
    • Modular system with reusable components
  • Firejail (legacy): SUID-based sandboxing (not used)
  • Bubblewrap (bwraps/): Direct bubblewrap configurations
    • WeChat sandboxing configuration

Current Implementation Status

Component Status Notes
AppArmor Profiles 🚧 WIP Basic structure in place
Nixpak Firefox Active Firefox sandboxing via nixpak
Nixpak QQ Active QQ application sandboxing
Bubblewrap WeChat Active WeChat specific sandboxing
System Profiles 🚧 WIP Hardened system configurations

Directory Structure

hardening/
├── README.md
├── apparmor/           # AppArmor security profiles
│   └── default.nix
├── bwraps/            # Direct bubblewrap configurations
│   ├── default.nix
│   └── wechat.nix
├── nixpaks/           # Nixpak application sandboxing
│   ├── default.nix
│   ├── firefox.nix
│   ├── qq.nix
│   └── modules/       # Reusable nixpak modules
│       ├── gui-base.nix
│       └── network.nix
└── profiles/          # System hardening profiles
    └── default.nix

Kernel Hardening

System Hardening

Application Sandboxing

NOTE

Running untrusted code is never safe, kernel hardening & sandboxing cannot change this.

If you want to run untrusted code, please use a VM & an isolated network environment, which will provide a much higher level of security.

References