Dev.to Security 🔐 Cybersecurity 👁 0 📖 3 min read

Idmapped Mounts Change Ownership Views and Must Be Tested as Permission Boundaries

Idmapped Mounts Change Ownership Views and Must Be Tested as Permission Boundaries Idmapped mounts let a filesystem present a different user and group ID view for a specific mount. They are useful for containers and sh

Idmapped Mounts Change Ownership Views and Must Be Tested as Permission Boundaries

Idmapped mounts let a filesystem present a different user and group ID view for a specific mount. They are useful for containers and shared storage because ownership can be translated without changing every file on disk. They also make traditional ownership checks incomplete: the process, the filesystem, and the mount's user namespace all participate in the result.

Two ID views exist

The Linux kernel documentation describes idmappings as translations from a range of userspace IDs to kernel IDs. A userspace ID is what a process sees or supplies. A kernel ID is used for permission checks and stored in the inode. The initial user namespace normally has an identity mapping across the full range, while a container or other namespace may map only a smaller range.

An idmapped mount attaches a user namespace to the mount with mount_setattr() and the relevant idmap attributes. When a process accesses a file through that mount, ownership is translated between the filesystem's kernel ID and the caller's view. The same file may therefore appear with different owners depending on the mount.

That is a legitimate feature, but it means screenshots of ls -ln and copied numeric IDs are not sufficient evidence of effective permission.

Test unmapped and overflow IDs

Not every ID has a mapping in every namespace. The kernel documentation explains that an unmapped ID is reported to userspace as the overflow UID or GID. A file owned by an unmapped ID may appear as nobody or another overflow value. Access can fail even though the underlying file looks correctly owned from the host.

Test the boundary in both directions. Create a file through the idmapped mount and inspect its on-disk ownership from the host. Read and write it from a process in the intended namespace. Then test a process whose mapping does not include the file owner. Confirm the denial and record the observed IDs.

Check directory traversal and setgid inheritance as well as direct file ownership. A process can have the right to open a file but lack access to a parent directory. Child files may receive different group ownership depending on the mount and filesystem behavior.

Protect the mount operation

The privilege to create or change an idmapped mount is security-sensitive. If an unauthorized user can choose the mapping or the mount view, they may change which inode ownership the kernel sees during a permission check. Restrict mount creation and mount_setattr() use to trusted orchestration.

Record the source filesystem, mount point, user namespace, mapping range, propagation, and intended workload. Review the ownership of the mount namespace and the ability to bind or move the mount. A correct mapping attached to an unintended path is still a misconfiguration.

Verify application behavior

Application configuration can encode UID and GID assumptions. A service that checks for a numeric owner before opening a file may reject a valid mapping or accept the wrong one. Test the application with the same namespace and mount view used in production.

Inspect logs and audit events for the effective process identity, not only the host account. Compare file creation, modification, backup, and restore paths. A backup tool that runs outside the idmapped mount can preserve host IDs and later produce a different result when data is restored.

The review should capture four pieces: on-disk owner, mount mapping, caller namespace, and effective access. When those four agree, the design is coherent. When one is missing, ownership output alone is weak evidence.

References

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.