Skip to content

nixos/security/wrappers: pam may fail if one of the security wrappers has incorrect capabilities set #398934

Open

Description

@aviallon

Nixpkgs version

  • Unstable (25.05)

Describe the bug

If one of the program wrapping fails, the entire suid-sgid-wrappers.service may fail.
Depending on where it fails, this can cause unix_chkpwd to be missing, and in turn, for any login to fail.
Because of this, this issue was very hard to debug. Especially since using nixos-rebuild switch does not break the system immediately, but only after a reboot.

${lib.concatStringsSep "\n" mkWrappedPrograms}

Steps to reproduce

  • Add an incorrect security wrapper, like:
    security.wrappers.fails = {
      source = "${pkgs.hello}/bin/hello";
      owner = "root";
      group = "root";
      capabilties = "cap_sys_nice+ep,cap_sys_nice+pie";
    };
  • nixos-rebuild boot
  • reboot
  • Enjoy your broken system

Expected behaviour

Only the broken wrapper remains broken

Screenshots

No response

Relevant log output

avril 15 18:12:05 luke-skywalker-nixos suid-sgid-wrappers-start[2789]: fatal error: Invalid argument
avril 15 18:12:05 luke-skywalker-nixos suid-sgid-wrappers-start[2789]: usage: setcap [--license] [-f] [-h] [-n <rootid>] [-q] [-v] (-r|-|<caps>) <filename> [ ... (-r|-|<capsN>) <filenameN> ]
avril 15 18:12:05 luke-skywalker-nixos suid-sgid-wrappers-start[2789]:  Note <filename> must be a regular (non-symlink) file.
avril 15 18:12:05 luke-skywalker-nixos suid-sgid-wrappers-start[2789]:  -r          remove capability from file
avril 15 18:12:05 luke-skywalker-nixos suid-sgid-wrappers-start[2789]:  -           read capability text from stdin
avril 15 18:12:05 luke-skywalker-nixos suid-sgid-wrappers-start[2789]:  <capsN>     cap_from_text(3) formatted file capability
avril 15 18:12:05 luke-skywalker-nixos suid-sgid-wrappers-start[2789]:  [ Note: capsh --suggest="something..." might help you pick. ]
avril 15 18:12:05 luke-skywalker-nixos suid-sgid-wrappers-start[2789]:  --license   display the license info
avril 15 18:12:05 luke-skywalker-nixos suid-sgid-wrappers-start[2789]:  -f          force setting even when the capability is invalid
avril 15 18:12:05 luke-skywalker-nixos suid-sgid-wrappers-start[2789]:  -h          this message and exit status 0
avril 15 18:12:05 luke-skywalker-nixos suid-sgid-wrappers-start[2789]:  -n <rootid> write a user namespace (!= 0) limited capability
avril 15 18:12:05 luke-skywalker-nixos suid-sgid-wrappers-start[2789]:  -q          quietly
avril 15 18:12:05 luke-skywalker-nixos suid-sgid-wrappers-start[2789]:  -v          validate supplied capability matches file
avril 15 18:12:05 luke-skywalker-nixos suid-sgid-wrappers-start[2789]: argument: cap_setpcap,cap_sys_nice+ep,cap_sys_nice+pie
avril 15 18:12:05 luke-skywalker-nixos systemd[1]: suid-sgid-wrappers.service: Failed with result 'exit-code'.
avril 15 18:12:05 luke-skywalker-nixos systemd[1]: Failed to start Create SUID/SGID Wrappers

Additional context

No response

System metadata

  • system: "x86_64-linux"
  • host os: Linux 6.14.2-cachyos, NixOS, 25.05 (Warbler), 25.05pre-git
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.28.1
  • nixpkgs: /nix/store/wq80rglj41byc1bbzj3lfj7pgc3k738m-source

Notify maintainers

@infinisil (There aren't any specific OWNER on this module)


Note for maintainers: Please tag this issue in your pull request description. (i.e. Resolves #ISSUE.)

I assert that this issue is relevant for Nixpkgs

Is this issue important to you?

Add a 👍 reaction to issues you find important.

Activity

  1. added
    0.kind: bug
    6.topic: nixos
    on Apr 15, 2025
  2. aviallon commented on Apr 15, 2025

    @aviallon
    ContributorAuthor

    Note: this specific bug happened because of gamemoded's wrapper.
    As it happen, I had made a wrapper for gamemoded long ago, which added cap_sys_nice+pie.
    Later, I activated enabledRenice, which enabled another wrapper. The problem is the following: capabilities were merged, causing this duplicate entry.
    This should not happen, or duplicates should at least be eliminated.

  3. aviallon commented on Apr 28, 2025

    @aviallon
    ContributorAuthor

    I may handle this bug myself if I find enough time to do so.

  4. added
    2.status: stale
    on Oct 26, 2025
  5. amarshall commented on Mar 22, 2026

    @amarshall
    Member

    Just ran into this and was very confused why login was totally broken. Opened PR to add build-time verification #502310

  6. removed
    2.status: stale
    on Mar 25, 2026
  7. added
    2.status: stale
    on Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bug2.status: stale6.topic: nixos

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions