Debian GNU/Linux · Filesystem & permissions

Leave no file without a known owner or group

When it fails: Some files belong to a user or group that does not exist. An account created later with the same ID would silently own these files.

CB-DEB-FS-009lowactiveautomatedprofile core

As released in v0.1.1 beta · pre-release. Current state.

Description

Every file and directory on local filesystems (ext2/3/4, XFS, Btrfs, JFS, F2FS, FAT, exFAT and tmpfs) belongs to a user and a group that exist in the account databases.

The scan stays on each filesystem (find -xdev). Network filesystems are not scanned: their IDs come from another system.

Rationale

Orphaned files usually come from deleted accounts or from archives extracted with their original IDs. The next account or group created with that numeric ID becomes their owner and can read or change them. They also point to incomplete account clean-up.

Impact

None: the control only reports.

Audit

For each local filesystem listed by findmnt -knr -o TARGET -t ext2,ext3,ext4,xfs,btrfs,jfs,f2fs,vfat,exfat,tmpfs, run find <mount point> -xdev \( -nouser -o -nogroup \). The command must print nothing.

Automated: every check must pass. Scanners report each check by its id.

unowned

Files and directories without a known owner or group on local filesystems.

script: |
  out=$(for m in $(findmnt -knr -o TARGET -t ext2,ext3,ext4,xfs,btrfs,jfs,f2fs,vfat,exfat,tmpfs); do
    find "$m" -xdev \( -nouser -o -nogroup \) -print 2>/dev/null
  done | sort -u)
  [ -z "$out" ] && { echo "every file has a known owner and group"; exit 0; }
  echo "$(printf '%s\n' "$out" | wc -l) item(s):"
  printf '%s\n' "$out" | head -n 20 | while IFS= read -r f; do stat -c '%n %u:%g' "$f"; done
  exit 1

Remediation

For each reported item, find where it comes from (ls -ln, dpkg -S), then:

  • give it to its current owner with chown <user>:<group> <file>;
  • or delete it if it belonged to a removed account and is no longer needed.

Restore files from archives with tar --no-same-owner (default for non-root) or fix the owner right after extraction.

References

Mappings

How this control relates to the other framework's: equivalent, stricter, looser, partial or related.

Threats mitigated

People and lifecycle

Authors
Verified2026-10-18 by Sn0wAlice on 12, Proxmox VM 922, Debian 12 genericcloud image, kernel 6.1.0-54-cloud-amd64. Passes on fresh install; file with unknown UID/GID detected.
Verified2026-10-18 by Sn0wAlice on 13, Proxmox VM 932, Debian 13 genericcloud image, kernel 6.12.113+deb13-cloud-amd64. Passes on fresh install; file with unknown UID/GID detected.
Introduced inv0.1.0
Created, updated2026-10-18, 2026-10-18
Translationsfr