CVE-2024-22365: pam: pam_namespace misses O_DIRECTORY flag in `protect_dir()` (CVE-2024-22365)

Published Jan 10, 2024
·
Updated

linux-pam (aka Linux PAM) before 1.6.0 allows attackers to cause a denial of service (blocked login process) via mkfifo because the openat call (for protectdir) lacks ODIRECTORY.

Other sources

Linux-pam is vulnerable to a denial of service, caused by a flaw in pamnamespace.so. By sending a specially crafted request, a local attacker could exploit this vulnerability to cause a denial of service.

IBM

The pamnamespace 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 protectdir() 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 ODIRECTORY 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 pamnamespace configured will cause the openat() in protectdir() to block, causing a local denial of service.

Red Hat

Affected Software

12 affected componentsFixes available
debian/pam<=1.3.1-5, <=1.4.0-9+deb11u1, <=1.5.2-6+deb12u1, <=1.5.2-9.1
1.5.3-7
ubuntu/pam<1.1.8-3.6ubuntu2.18.04.6+
1.1.8-3.6ubuntu2.18.04.6+
ubuntu/pam<1.3.1-5ubuntu4.7
1.3.1-5ubuntu4.7
ubuntu/pam<1.4.0-11ubuntu2.4
1.4.0-11ubuntu2.4
ubuntu/pam<1.5.2-5ubuntu1.1
1.5.2-5ubuntu1.1
ubuntu/pam<1.5.2-6ubuntu1.1
1.5.2-6ubuntu1.1
ubuntu/pam<1.1.8-1ubuntu2.2+
1.1.8-1ubuntu2.2+
ubuntu/pam<1.1.8-3.2ubuntu2.3+
1.1.8-3.2ubuntu2.3+
redhat/pam<1.6.0
1.6.0
IBM MQ Operator<=CD:  v3.0.0, v3.0.1, v3.1.0 - 3.1.3 LTS: v2.0.0 - 2.0.22 Other Release: v2.4.0 - v2.4.8, v2.3.0 - 2.3.3, v2.2.0 - v2.2.2
IBM supplied MQ Advanced container images<=CD: 9.3.4.0-r1, 9.3.4.1-r1,9.3.5.0-r1,9.3.5.0-r2,9.3.5.1-r1, 9.3.5.1-r2LTS: 9.2.0.1-r1-eus, 9.2.0.2-r1-eus, 9.2.0.2-r2-eus, 9.2.0.4-r1-eus, 9.2.0.5-r1-eus, 9.2.0.5-r2-eus, 9.2.0.5-r3-eus, 9.2.0.6-r1-eus, 9.2.0.6-r2-eus, 9.2.0.6-r3-eus, 9.2.3.0-r1, 9.2.4.0-r1, 9.2.5.0-r1, 9.2.5.0-r2, 9.2.5.0-r3, 9.3.0.0-r1, 9.3.0.0-r2, 9.3.0.0-r3, 9.3.0.1-r1, 9.3.0.1-r2, 9.3.0.1-r3, 9.3.0.1-r4, 9.3.0.3-r1, 9.3.0.4-r1, 9.3.0.4-r2, 9.3.0.5-r1, 9.3.0.5-r2, 9.3.0.5-r3, 9.3.0.6-r1, 9.3.0.10-r1, 9.3.0.10-r2, 9.3.0.11-r1,9.3.0.11-r2, 9.3.0.15-r1, 9.3.0.16-r1, 9.3.0.16-r2, 9.3.0.17-r1, 9.3.0.17-r2 Other Release: 9.2.0.1-r1-eus, 9.2.0.2-r1-eus, 9.2.0.2-r2-eus, 9.2.0.4-r1-eus, 9.2.0.5-r1-eus, 9.2.0.5-r2-eus, 9.2.0.5-r3-eus, 9.2.0.6-r1-eus, 9.2.0.6-r2-eus, 9.2.0.6-r3-eus, 9.2.3.0-r1, 9.2.4.0-r1, 9.2.5.0-r1, 9.2.5.0-r2, 9.2.5.0-r3, 9.3.0.0-r1, 9.3.0.0-r2, 9.3.0.0-r3, 9.3.0.1-r1, 9.3.0.1-r2, 9.3.0.1-r3, 9.3.0.1-r4,  9.3.0.3-r1,  9.3.0.4-r1, 9.3.0.4-r2,  9.3.0.5-r1, 9.3.0.5-r2, 9.3.0.5-r3,  9.3.0.6-r1,  9.3.1.0-r1, 9.3.1.0-r2, 9.3.1.0-r3, 9.3.1.1-r1, 9.3.2.0-r1, 9.3.2.0-r2, 9.3.2.1-r1, 9.3.2.1-r2,  9.3.3.0-r1, 9.3.3.0-r2, 9.3.3.1-r1, 9.3.3.1-r2, 9.3.3.2-r1, 9.3.3.2-r2, 9.3.3.2-r3, ,9.3.3.3-r1,  9.3.3.3-r2
Linux-PAM Linux-PAM<1.6.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade debian/pam to a version that resolves this vulnerability.

    Fixed in 1.5.3-7
  2. Upgrade

    Upgrade ubuntu/pam to a version that resolves this vulnerability.

    Fixed in 1.1.8-3.6ubuntu2.18.04.6+
  3. Upgrade

    Upgrade ubuntu/pam to a version that resolves this vulnerability.

    Fixed in 1.3.1-5ubuntu4.7
  4. Upgrade

    Upgrade ubuntu/pam to a version that resolves this vulnerability.

    Fixed in 1.4.0-11ubuntu2.4
  5. Upgrade

    Upgrade ubuntu/pam to a version that resolves this vulnerability.

    Fixed in 1.5.2-5ubuntu1.1
  6. Upgrade

    Upgrade ubuntu/pam to a version that resolves this vulnerability.

    Fixed in 1.5.2-6ubuntu1.1
  7. Upgrade

    Upgrade ubuntu/pam to a version that resolves this vulnerability.

    Fixed in 1.1.8-1ubuntu2.2+
  8. Upgrade

    Upgrade ubuntu/pam to a version that resolves this vulnerability.

    Fixed in 1.1.8-3.2ubuntu2.3+
  9. Upgrade

    Upgrade redhat/pam to a version that resolves this vulnerability.

    Fixed in 1.6.0
  10. Upgrade

    Upgrade linux-pam (aka Linux PAM) to a version that resolves this vulnerability.

    Fixed in 1.6.0
  11. Configuration

    Update/patch pam_namespace.so so that protect_dir() passes the O_DIRECTORY flag to openat(); this prevents denial-of-service/blocking of login caused by special files (e.g., FIFOs) placed in user-controlled locations (CVE-2024-22365).

    pam_namespace (Linux-PAM) O_DIRECTORY flag in protect_dir()/openat() algorithm = Ensure openat() is called with O_DIRECTORY to avoid blocking on special files like FIFOs
  12. Configuration

    Configure pam_namespace to bind mount each user’s private /tmp and/or /var/tmp (ephemeral temporary directory contents lost after session close) rather than using user-controlled directories under non-root control.

    pam_namespace namespace.conf Bind-mounted polyinstantiated directories location = Use a per-user private /tmp and/or /var/tmp
  13. Compensating control

    If feasible while fixing, avoid setting up pam_namespace polyinstantiated directories that allow user-controlled paths where attackers can place special files (e.g., FIFOs) that interfere with protect_dir() behavior.

Event History

Jan 17, 2024
CVE Published
via Ubuntu·12:00 AM
Feb 6, 2024
CVE Published
via MITRE·12:00 AM
Data Sourced
via MITRE·12:00 AM
Description
Data Sourced
via NVD·08:15 AM
RemedyDescriptionSeverityWeaknessAffected Software
Feb 14, 2024
Data Sourced
via Launchpad·08:17 PM
Description

Parent advisories

This vulnerability appears in the following advisories.

Frequently Asked Questions

1

What is the severity of CVE-2024-22365?

CVE-2024-22365 has a severity rating that indicates a potential denial of service vulnerability that affects login processes.

2

How do I fix CVE-2024-22365?

To fix CVE-2024-22365, upgrade to Linux PAM version 1.6.0 or later.

3

Which versions of Linux PAM are affected by CVE-2024-22365?

Linux PAM versions before 1.6.0 are affected by CVE-2024-22365.

4

What kind of attack does CVE-2024-22365 enable?

CVE-2024-22365 enables attackers to cause a denial of service by blocking the login process.

5

Is there a workaround for CVE-2024-22365 if I cannot upgrade?

Currently, there are no known workarounds for CVE-2024-22365, so upgrading is recommended.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203