>_ IzzyLab

Hands-on task

This task is step 18 of the course “Linux server security”

Audit: world-writable files

medium~5 min

The directory /root/audit contains files writable by everyone (world-writable) — a risk. Find them and remove the write bit for "others", without touching the owner's and group's permissions. After the fix no world-writable files should remain there.

What you'll practise:
  • find
  • chmod
  • world-writable
  • -perm
  • symbolic permissions

Topic breakdown

World-writable files (the write bit for "others") are a classic risk: any user on the system can replace their contents. find can select objects by permission bits: a mask with a minus sign means "all listed bits are present", which lets you pick out exactly the files writable by everyone. Removing one specific bit, without touching the owner's and group's permissions, is done with chmod's symbolic mode, and finding and fixing can be combined via the mechanism for running a command on each match.

What's checked

  1. no world-writable files remain
  2. files are still there (only permissions changed)
  3. owner and group permissions are unchanged

What it looks like