Bug 2257722 (CVE-2024-22365) - CVE-2024-22365 pam: allowing unprivileged user to block another user namespace
Summary: CVE-2024-22365 pam: allowing unprivileged user to block another user namespace
Keywords:
Status: NEW
Alias: CVE-2024-22365
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Product Security
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks: 2257717
TreeView+ depends on / blocked
 
Reported: 2024-01-10 15:56 UTC by Patrick Del Bello
Modified: 2024-04-30 10:51 UTC (History)
1 user (show)

Fixed In Version: pam 1.6.0
Doc Type: If docs needed, set a value
Doc Text:
A vulnerability was found in Linux PAM. An unprivileged user that is not yet in a corresponding mount namespace with ~/tmp mounted as a polyinstantiated dir can place a FIFO there, and a subsequent attempt to login as this user with `pam_namespace` configured will cause the `openat()` in `protect_dir()` to block the attempt, causing a local denial of service.
Clone Of:
Environment:
Last Closed:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2024:2438 0 None None None 2024-04-30 10:51:12 UTC

Description Patrick Del Bello 2024-01-10 15:56:40 UTC
The pam_namespace module allows to setup "polyinstantiated directories" when setting up a user's session during login. The typical example is
setting up a private /tmp and/or /var/tmp for every user.
To achieve this a separate mount namespace is setup during login and a bind mount is performed in configured locations. Different methods are
offered for this like a fixed per-user directory that is bind mounted (i.e. per-user contents are persistent and shared between sessions) or
an ephemeral temporary directory (contents are lost after a session is closed).

The PAM module explicitly supports bind mounting of polyinstantiated directories in user controlled locations, like beneath the user's home
directory. Operating with root privileges in user controlled directories comes with a lot of dangers. To avoid them the function `protect_dir()`
implements a special algorithm to protect the target path of a bind mount.

The function follows the target path for the bind mount starting from the file system root. Each path component that is under non-root control
is protected from user manipulation, by bind mounting the path upon itself.

There is one bit missing though: The algorithm is not passing the `O_DIRECTORY` flag to `openat()` and is thus subject to special files like
FIFOs being placed in user controlled directories. This can easily be reproduced e.g. using this configuration entry in the `namespace.conf`
configuration file:

    $HOME/tmp /var/tmp/tmp-inst/ user:create root

An unprivileged user (that is not yet in a corresponding mount namespace with ~/tmp mounted as a polyinstantiated dir) can now place a FIFO
there:

    nobody$ mkfifo $HOME/tmp

A subsequent attempt to login as this user with `pam_namespace` configured will cause the `openat()` in `protect_dir()` to block,
causing a local denial of service.

Comment 3 errata-xmlrpc 2024-04-30 10:51:11 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 9

Via RHSA-2024:2438 https://access.redhat.com/errata/RHSA-2024:2438


Note You need to log in before you can comment on or make changes to this bug.