Skip to content

agent helper: support separate socket-activated service to run without SETUID#501

Merged
jrybar-rh merged 1 commit intopolkit-org:mainfrom
bluca:remove_setuid_inet
Mar 25, 2025
Merged

agent helper: support separate socket-activated service to run without SETUID#501
jrybar-rh merged 1 commit intopolkit-org:mainfrom
bluca:remove_setuid_inet

Conversation

@bluca
Copy link
Member

@bluca bluca commented Sep 16, 2024

SETUID binaries are considered harmful, as te execution context is under the control of unprivileged attackers.

Enhance the polkit pam agent helper with a new mode: when running under systemd, add a socket-activated service that the helper will run under, as root. The agent talks to this service via AF_UNIX instead of spawning it, and STDIN/STDOUT are connected as before. The helper can make use of PID FDs and SO_PEERCRED to reliably identify the caller. In order to do this, a third version of the auth D-Bus method is added, that also takes a subject, built using the PID FD.
If the AF_UNIX socket is not present, the agent will fork the helper as before, with no changes.

Fixes #169

@bluca bluca force-pushed the remove_setuid_inet branch 2 times, most recently from adcc469 to f2206c2 Compare September 17, 2024 14:54
…t SETUID

SETUID binaries are considered harmful, as te execution context is
under the control of unprivileged attackers.

Enhance the polkit pam agent helper with a new mode: when running
under systemd, add a socket-activated service that the helper will
run under, as root. The agent talks to this service via AF_UNIX
instead of spawning it, and STDIN/STDOUT are connected as before.
The helper can make use of PID FDs and SO_PEERCRED to reliably
identify the caller. In order to do this, a third version of the
auth D-Bus method is added, that also takes a subject, built using
the PID FD.
If the AF_UNIX socket is not present, the agent will fork the
helper as before, with no changes.

Fixes polkit-org#169
@bluca
Copy link
Member Author

bluca commented Dec 17, 2024

@jrybar-rh gentle ping

@jrybar-rh
Copy link
Member

@jrybar-rh gentle ping

Gentle ack.

Though, I probably won't have time to review this till mid-Jan. But I will try to get to this asap.

@@ -113,7 +127,47 @@ main (int argc, char *argv[])
goto error;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Luca, formally it all looks good, thanks for the hard work! Just to clear out the purpose, we still have a SUID binary (because of pam stack), but at least it runs in systemd-sandbox, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! The SUID bit can be removed from the agent binary, and things should work without it on systemd systems. I have left support for the SUID mode in, for legacy systems that don't have socket activation

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Socket activation is manual on purpose, or WantedBy is missing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's manual on purpose on the service, as that is only triggered by the socket unit

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the socket has to be manually started first so the new code takes effect. I've just tried that on a fresh VM.
Just asking. I've got no problem adding a line in %post in rpm spec.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the socket unit itself has a WantedBy

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, I had it right before my eyes. On the first run on VM, something weird happened and the polkit helper service unit failed after boot for some reason, so I started to wonder... It went all good on second provision.

@jrybar-rh jrybar-rh merged commit c007940 into polkit-org:main Mar 25, 2025
@bluca bluca deleted the remove_setuid_inet branch March 25, 2025 19:46
skissue added a commit to skissue/nixpkgs that referenced this pull request Dec 24, 2025
Polkit v127 no longer requires a SUID `polkit-agent-helper-1` and instead
recommends using a socket-activated `polkit-agent-helper` service[1].

[1] <polkit-org/polkit#501>
skissue added a commit to skissue/nixpkgs that referenced this pull request Dec 24, 2025
Polkit v127 no longer requires a SUID `polkit-agent-helper-1` and instead
recommends using a socket-activated `polkit-agent-helper` service[1].

[1] <polkit-org/polkit#501>
github-merge-queue bot pushed a commit to NixOS/nixpkgs that referenced this pull request Dec 30, 2025
Polkit v127 no longer requires a SUID `polkit-agent-helper-1` and instead
recommends using a socket-activated `polkit-agent-helper` service[1].

[1] <polkit-org/polkit#501>
pythonpoet pushed a commit to pythonpoet/nixpkgs that referenced this pull request Jan 24, 2026
Polkit v127 no longer requires a SUID `polkit-agent-helper-1` and instead
recommends using a socket-activated `polkit-agent-helper` service[1].

[1] <polkit-org/polkit#501>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

polkit-agent-helper-1 is setuid root and runnable by ordinary users, does it need to be?

2 participants