Skip to content

Prevent path traversal (../) in create-profile, select, and backup commands(CWE-22) #471

Open

Description

@ByteHackr

Date: 26 August 2026
Reporter: Sandipan Roy (Red Hat)

Summary

Profile IDs, backup names, and create-profile names are concatenated as dir + "/" + name in several places without rejecting path separators (/) or parent-directory components (..). This allows a root operator to accidentally (or intentionally) write outside the intended profile/backup directories.

Because all mutating authselect commands already gate on getuid() == 0 and the binary is not setuid, this is not a privilege escalation — root can already rewrite PAM and rm -rf /. It is a defense-in-depth / input-validation hardening issue (CWE-22).

Affected code paths

Tested on authselect 1.8.0 (6bd0e16).

1. authselect create-profile

The name argument is used directly in path construction for the custom profile directory under /etc/authselect/custom/. A name like ../../tmp/evil would resolve to /etc/tmp/evil (or higher depending on depth).

2. authselect select (custom profile ID)

A custom profile ID containing ../ can escape the custom profile directory when building the lookup path.

3. Backup names (--backup=NAME, backup-remove, backup-restore)

Backup names are concatenated into the backup directory path. A name containing ../ can reference (and potentially create or delete) directories outside the backup tree.

Reproduction

# All commands require root — this is NOT a privilege escalation.
# It demonstrates the path is not validated.

sudo authselect create-profile '../../tmp/authselect-traversal-test' \
    --base-on sssd 2>&1
# Creates /etc/tmp/authselect-traversal-test/ (or errors depending
# on intermediate dirs) instead of refusing the name.

# Cleanup
sudo rm -rf /etc/tmp/authselect-traversal-test

Classification

  • CWE: CWE-22 (Improper Limitation of a Pathname to a Restricted Directory)
  • Severity: Low (requires root, defense-in-depth only)

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions