TMAegisBeta
More rules for freebsd

FreeBSD

TMA-FREEBSD-6.1.5

Ensure world writable files and directories are secured

HighLevel 1Automatedfreebsd

Description

World writable files are the least secure. Data in world-writable files can be modified and compromised by any user on the system. World writable files may also indicate an incorrectly written script or program that could potentially be the cause of a larger compromise to the system's integrity. See the chmod(2) man page for more information. Audit: no world-writable files, and no world-writable directories without the sticky bit (outside /tmp and /proc); long running.

How it is checked

Audit method: Shell command

shell
command -v find >/dev/null 2>&1 || exit 1; out=$( { find / \( -path /tmp -o -path /proc \) -prune -o -type f -perm -o=w -print; find / \( -path /tmp -o -path /proc \) -prune -o -type d -perm -o=w ! -perm -1000 -print ; } 2>/dev/null ); [ -z "$out" ] && echo compliant || printf '%s\n' "$out" | head -n 20
Expected output
compliant

How it is fixed

Fix method: Guidance or infrastructure patch

World Writable Files: o It is recommended that write access is removed from other with the command ( chmod o-w <filename> ), but always consult relevant vendor documentation to avoid breaking any application dependencies on a given file. World Writable Directories: o Set the sticky bit on all world writable directories with the command ( chmod a+t <directory_name> ) Run the following script to: Remove other write permission from any world writable files Add the sticky bit to all world writable directories #!/bin/sh # Define paths to exclude (space-separated) a_path_exclusions="! -path '/tmp/*' ! -path '/proc/*'" # Fix world-writable files by removing the write permission for "others" find / \( $a_path_exclusions \) -type f -perm -o=w -print -exec chmod o-w {} \; # Fix world-writable directories without the sticky bit find / \( $a_path_exclusions \) -type d -perm -o=w ! -perm -1000 -print -exec chmod +t,o-w {} \;

Properties

Operating systems
Any
Tags
freebsdpermissions
Reference
CIS FreeBSD 14 Benchmark v1.0.1 - 6.1.5 Ensure world writable files and directories are secured

Check this host

Run this on a machine you are allowed to audit. The scan is read-only.

shell
tmaegis scan --target freebsd