Skip to content

Commit

Permalink
security options update
Browse files Browse the repository at this point in the history
- use icons for jailed firefox and chromium from icon pack
- users options set to default in all VMs
- KASLR option removed as it is by default enabled in kernel
- sysrq disabled only in release build
- fail2ban enabled in net-vm only

Signed-off-by: Ganga Ram <Ganga.Ram@tii.ae>
  • Loading branch information
gangaram-tii committed Jun 13, 2024
1 parent a5ffa7b commit a4481e6
Show file tree
Hide file tree
Showing 10 changed files with 7 additions and 54 deletions.
Binary file removed assets/icons/png/chromium.png
Binary file not shown.
Binary file removed assets/icons/png/firefox.png
Binary file not shown.
8 changes: 4 additions & 4 deletions modules/common/security/firejail/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ in {

launchers =
lib.optional cfg.apps.firefox.enable {
name = "firefox-safe";
name = "Firefox-safe";
path = "/run/current-system/sw/bin/firefox";
icon = "${../../../assets/icons/png/firefox.png}";
icon = "${pkgs.icon-pack}/firefox.svg";
}
++ lib.optional cfg.apps.chromium.enable {
name = "chromium";
name = "Chromium-safe";
path = "/run/current-system/sw/bin/chromium";
icon = "${../../../assets/icons/png/chromium.png}";
icon = "${pkgs.icon-pack}/chromium.svg";
};
};

Expand Down
30 changes: 3 additions & 27 deletions modules/common/security/system.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ in {
Enforce Strong password for each user.
'';
type = lib.types.bool;
default = false;
default = true;
};

min-passwd-len = lib.mkOption {
Expand All @@ -28,14 +28,6 @@ in {
};
};

encrypt_home.enable = lib.mkOption {
description = ''
Enable encryption of user's data stored in 'Home' directory.
'';
type = lib.types.bool;
default = false;
};

root.enable = lib.mkOption {
description = ''
Disable root login.
Expand Down Expand Up @@ -123,16 +115,6 @@ in {
type = lib.types.bool;
default = false;
};
enableASLR = lib.mkOption {
description = ''
Randomize user virtual address space. It disrupts the
predictability of memory layouts and makes it harder for
attackers to exploit memory related vulnerabilities.
May slightly impact performance, may increase boot time.
'';
type = lib.types.bool;
default = false;
};
randomizePageFreeList = lib.mkOption {
description = ''
Randomize free memory pages managed by the page allocator.
Expand Down Expand Up @@ -167,7 +149,7 @@ in {

# There is no possible string to hash to just “!”
users.users.root = lib.mkIf (!cfg.users.root.enable) {
hashedPassword = lib.mkForce "!";
shell = "${pkgs.shadow}/bin/nologin";
};

# Enforce strong password
Expand All @@ -187,9 +169,6 @@ in {
'';
};
};

# Encrypt user's data stored in 'Home' directory
enableFscrypt = cfg.users.encrypt_home.enable;
};

## sudo administartion
Expand Down Expand Up @@ -249,9 +228,6 @@ in {
# Disable ftrace
"kernel.ftrace_enabled" = lib.mkDefault false;

# Randomize address space including heap
"kernel.randomize_va_space" = lib.mkIf (cfg.system-security.misc.enableASLR || cfg.system-security.misc.enable-all) (lib.mkForce 2);

# Restrict core dump
"fs.suid_dumpable" = lib.mkForce 0;

Expand All @@ -262,7 +238,7 @@ in {
"vm.unprivileged_userfaultfd" = lib.mkForce 0;

# Disable SysRq key
"kernel.sysrq" = lib.mkForce 0;
"kernel.sysrq" = lib.mkIf config.ghaf.profiles.release.enable (lib.mkForce 0);

# Disable loading of line descipline kernel module of TTY device
# The line descipline module provides an interface between the low-level driver handling a TTY device
Expand Down
4 changes: 0 additions & 4 deletions modules/microvm/virtualization/microvm/adminvm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,10 @@
withDebug = configHost.ghaf.profiles.debug.enable;
};
security = {
users.strong-password.enable = true;
users.root.enable = false;
users.sudo.enable = true;
system-security.enable = true;
system-security.lock-kernel-modules = lib.mkDefault configHost.ghaf.profiles.release.enable;
network.ipsecurity.enable = true;
network.bpf-access-level = lib.mkForce 1; # Provide BPF access to privileged users
fail2ban.enable = true;
};
};

Expand Down
4 changes: 0 additions & 4 deletions modules/microvm/virtualization/microvm/appvm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,10 @@
withHardenedConfigs = true;
};
security = {
users.strong-password.enable = true;
users.root.enable = false;
users.sudo.enable = true;
system-security.enable = true;
system-security.lock-kernel-modules = lib.mkDefault configHost.ghaf.profiles.release.enable;
network.ipsecurity.enable = true;
network.bpf-access-level = lib.mkForce 1; # Provide BPF access to privileged users
fail2ban.enable = true;
};
};

Expand Down
4 changes: 0 additions & 4 deletions modules/microvm/virtualization/microvm/audiovm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,10 @@
};
services.audio.enable = true;
security = {
users.strong-password.enable = true;
users.root.enable = false;
users.sudo.enable = true;
system-security.enable = true;
system-security.lock-kernel-modules = lib.mkDefault configHost.ghaf.profiles.release.enable;
network.ipsecurity.enable = true;
network.bpf-access-level = lib.mkForce 1; # Provide BPF access to privileged users
fail2ban.enable = true;
};
};

Expand Down
4 changes: 0 additions & 4 deletions modules/microvm/virtualization/microvm/guivm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,10 @@
};

security = {
users.strong-password.enable = true;
users.root.enable = false;
users.sudo.enable = true;
system-security.enable = true;
system-security.lock-kernel-modules = lib.mkDefault configHost.ghaf.profiles.release.enable;
network.ipsecurity.enable = true;
network.bpf-access-level = lib.mkForce 1; # Provide BPF access to privileged users
fail2ban.enable = true;
};
};

Expand Down
4 changes: 0 additions & 4 deletions modules/microvm/virtualization/microvm/microvm-host.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,10 @@ in {
withHardenedConfigs = true;
};
security = {
users.strong-password.enable = true;
users.root.enable = false;
users.sudo.enable = true;
system-security.enable = true;
system-security.lock-kernel-modules = lib.mkDefault config.ghaf.profiles.release.enable;
network.ipsecurity.enable = true;
network.bpf-access-level = lib.mkForce 1; # Provide BPF access to privileged users
fail2ban.enable = true;
};
};

Expand Down
3 changes: 0 additions & 3 deletions modules/microvm/virtualization/microvm/netvm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@
withHardenedConfigs = true;
};
security = {
users.strong-password.enable = true;
users.root.enable = false;
users.sudo.enable = true;
system-security.enable = true;
system-security.lock-kernel-modules = lib.mkDefault configHost.ghaf.profiles.release.enable;
network.ipsecurity.enable = true;
Expand Down

0 comments on commit a4481e6

Please sign in to comment.