Files
nix-config-ryan4yin/hardening
Ryan Yin e9d706aa96 fix(apparmor): correct the sudo profile comment's conclusion
The abort needs havePrivateMountNs == false AND /nix/store still ro:
remountReadOnlyWritable() returns early while the store is writable. Nix
<= 2.34 left it rw until reboot; 2.35 remounts in a private namespace, so
only a freshly booted host hits it. The repro command also uses an open-only
exec 7<..., since cat fails on the read even when the open succeeds.

While here, trim the comments and drop the disabled default_deny/nix
policies plus the explicit killUnconfinedConfinables=false (nixpkgs
default). 82 -> 34 lines.
2026-10-07 20:22:43 +08:00
..

Linux Hardening

Work in progress.

Application sandboxing (nixpak/bubblewrap) and Linux hardening knowledge for this repository. For the repository security policy, architecture and audit status, see SECURITY.md; for temporary exceptions and known gaps, see WORKAROUNDS.md.

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 & process hardening (kernel-hardening.nix): sysctl baseline and unused-module deny list; rationale and verification live in SECURITY.md.

2. Per-App Level

  • Nixpak (nixpaks/): Bubblewrap-based sandboxing for applications
    • Firefox configuration
    • QQ (Chinese messaging app) configuration
    • Telegram Desktop configuration
    • Modular system with reusable components
  • 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
Nixpak Telegram ✅ Active Telegram Desktop sandboxing
Bubblewrap WeChat ✅ Active WeChat specific sandboxing

Directory Structure

hardening/
├── README.md
├── kernel-hardening.nix # sysctl baseline + unused-module deny list
├── apparmor/           # AppArmor security profiles
│   └── default.nix
├── bwraps/            # Direct bubblewrap configurations
│   ├── default.nix
│   └── wechat.nix
└── nixpaks/           # Nixpak application sandboxing
    ├── default.nix
    ├── firefox.nix
    ├── qq.nix
    ├── telegram-desktop.nix
    └── modules/       # Reusable nixpak modules
        ├── custom-policy.nix
        ├── gui-base.nix
        └── network.nix

System Hardening

Application Sandboxing

NOTE

Running untrusted code is never safe, kernel hardening & sandboxing cannot change this; run untrusted code in a VM on an isolated network. The threat model lives in SECURITY.md.

References