Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PAM behaviour differs between Linux/FreeBSD, causing fork-unsafety on BSD #888

Open
squell opened this issue Oct 21, 2024 · 1 comment · May be fixed by #886
Open

PAM behaviour differs between Linux/FreeBSD, causing fork-unsafety on BSD #888

squell opened this issue Oct 21, 2024 · 1 comment · May be fixed by #886
Assignees
Labels
bug Something isn't working freebsd

Comments

@squell
Copy link
Member

squell commented Oct 21, 2024

Potential steps to reproduce:

  • su is missing setuid.
  • PAM is configured to unconditionally allows the user to authenticate as itself even when the program that runs PAM is not doesn't have euid set to 0.
  • The user runs su $(whoami) when not root.
  • Su considers the user authenticated and attempts to setuid and fails.

On Linux PAM will ask the user to authenticate even when the user wants to run su to become itself. On FreeBSD PAM will allow su to be used without authentication when the target is the same as the calling user. I'm not sure how to configure Linux PAM to get the FreeBSD behavior in a test.

The problem is that this behaviour causes sudo to return after having forked, closing file descriptors that have already been closed, etc.

See the linked PR.

@squell squell added bug Something isn't working freebsd labels Oct 21, 2024
@squell squell linked a pull request Oct 21, 2024 that will close this issue
@bjorn3
Copy link
Collaborator

bjorn3 commented Oct 21, 2024

Any error between close_the_universe and exec would have this problem. The exact repro I mentioned is just one of the ways this can theoretically happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working freebsd
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants