Linux desktop application sandbox.
Go to file
Ophestra Umiker 2efedf56c0
All checks were successful
Tests / Go tests (push) Successful in 38s
Nix / NixOS tests (push) Successful in 10m38s
nix: collect fortify ps output
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-12-18 13:48:39 +09:00
.gitea/workflows dist: generate distribution tarball 2024-12-17 14:02:54 +09:00
acl nix: skip acl test 2024-12-16 19:29:01 +09:00
cmd cmd/fsu: check uid range before syscall 2024-12-17 13:01:36 +09:00
comp fortify: rename --dbus-id to --id 2024-12-06 03:26:09 +09:00
dbus add package doc comments 2024-10-28 20:57:59 +09:00
dist dist: generate distribution tarball 2024-12-17 14:02:54 +09:00
fipc fipc: export config struct 2024-12-18 13:45:55 +09:00
helper proc: cleaner extra files 2024-12-06 16:05:04 +09:00
internal fipc: export config struct 2024-12-18 13:45:55 +09:00
ldd add package doc comments 2024-10-28 20:57:59 +09:00
wl system: prevent duplicate Wayland op 2024-12-07 19:45:37 +09:00
xcb xcb: refactor and clean up 2024-12-17 12:46:36 +09:00
.gitignore dist: generate distribution tarball 2024-12-17 14:02:54 +09:00
error.go fmsg: support temporarily withholding output 2024-10-26 23:09:32 +09:00
flake.lock nix: permissive defaults nixos test 2024-12-16 22:56:10 +09:00
flake.nix nix: run Go tests in nixos 2024-12-17 21:16:55 +09:00
go.mod migrate to git.ophivana.moe/security/fortify 2024-10-20 19:50:13 +09:00
LICENSE apply MIT license 2024-07-16 20:49:00 +09:00
main.go fipc: export config struct 2024-12-18 13:45:55 +09:00
nixos.nix nix: implement flake checks 2024-12-16 20:54:28 +09:00
options.md nix: expose no_new_session in module 2024-11-28 00:19:06 +09:00
options.nix nix: implement flake checks 2024-12-16 20:54:28 +09:00
package.nix release: 0.2.3 2024-12-17 14:06:17 +09:00
README.md update README document 2024-12-06 17:04:36 +09:00
test.nix nix: collect fortify ps output 2024-12-18 13:48:39 +09:00

Fortify

Go Reference Go Report Card

Lets you run graphical applications as another user in a confined environment with a nice NixOS module to configure target users and provide launchers and desktop files for your privileged user.

Why would you want this?

  • It protects the desktop environment from applications.

  • It protects applications from each other.

  • It provides UID isolation on top of the standard application sandbox.

If you have a flakes-enabled nix environment, you can try out the tool by running:

nix run git+https://git.ophivana.moe/security/fortify -- help

Module usage

The NixOS module currently requires home-manager to function correctly.

Full module documentation can be found here.

To use the module, import it into your configuration with

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";

    fortify = {
      url = "git+https://git.ophivana.moe/security/fortify";

      # Optional but recommended to limit the size of your system closure.
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { self, nixpkgs, fortify, ... }:
  {
    nixosConfigurations.fortify = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      modules = [
        fortify.nixosModules.fortify
      ];
    };
  };
}

This adds the environment.fortify option:

{ pkgs, ... }:

{
  environment.fortify = {
    enable = true;
    stateDir = "/var/lib/persist/module/fortify";
    users = {
      alice = 0;
      nixos = 10;
    };

    apps = [
      {
        name = "chromium";
        id = "org.chromium.Chromium";
        packages = [ pkgs.chromium ];
        userns = true;
        mapRealUid = true;
        dbus = {
          system = {
            filter = true;
            talk = [
              "org.bluez"
              "org.freedesktop.Avahi"
              "org.freedesktop.UPower"
            ];
          };
          session =
            f:
            f {
              talk = [
                "org.freedesktop.FileManager1"
                "org.freedesktop.Notifications"
                "org.freedesktop.ScreenSaver"
                "org.freedesktop.secrets"
                "org.kde.kwalletd5"
                "org.kde.kwalletd6"
              ];
              own = [
                "org.chromium.Chromium.*"
                "org.mpris.MediaPlayer2.org.chromium.Chromium.*"
                "org.mpris.MediaPlayer2.chromium.*"
              ];
              call = { };
              broadcast = { };
            };
        };
      }
      {
        name = "claws-mail";
        id = "org.claws_mail.Claws-Mail";
        packages = [ pkgs.claws-mail ];
        gpu = false;
        capability.pulse = false;
      }
      {
        name = "weechat";
        packages = [ pkgs.weechat ];
        capability = {
          wayland = false;
          x11 = false;
          dbus = true;
          pulse = false;
        };
      }
      {
        name = "discord";
        id = "dev.vencord.Vesktop";
        packages = [ pkgs.vesktop ];
        share = pkgs.vesktop;
        command = "vesktop --ozone-platform-hint=wayland";
        userns = true;
        mapRealUid = true;
        capability.x11 = true;
        dbus = {
          session =
            f:
            f {
              talk = [ "org.kde.StatusNotifierWatcher" ];
              own = [ ];
              call = { };
              broadcast = { };
            };
          system.filter = true;
        };
      }
      {
        name = "looking-glass-client";
        groups = [ "plugdev" ];
        extraPaths = [
          {
            src = "/dev/shm/looking-glass";
            write = true;
          }
        ];
        extraConfig = {
          programs.looking-glass-client.enable = true;
        };
      }
    ];
  };
}