Finding the world-writable files on your server before someone else does

Finding the world-writable files on your server before someone else does

●2 ●39 ●103
calendar_today • schedule1 min read

A world-writable file can be rewritten by every account on the machine — including the service account your web server runs as. Code executing as www-data through a compromised plugin doesn't need root: any chmod 777 you left behind during past debugging is a file it can overwrite or replace outright.

Two details break most homegrown audits. First, find -perm 777 (no dash) matches mode 777 exactly — a 666 file is equally world-writable and slips through. The dash form uses mask semantics and catches every file with the other-write bit set. Second, never fix findings with chmod -R 644: on directories, the execute bit means "may be entered," and stripping it recursively seals off the whole tree. Split the fix by type instead:

find /var/www -type f -perm -o+w 2>/dev/null
find /var/www -type f -exec chmod 644 {} \;
find /var/www -type d -exec chmod 755 {} \;

SSH keys and secrets go tighter, to 600 — OpenSSH refuses group- or world-readable private keys outright.

I keep the longer version as a script with a saved report file, a SUID scan, and a recommended-modes reference: full file-permissions security audit script.


I bundled the scripts I copy onto every new server, plus 10 bonus ones, into the Production Bash Toolkit. 30-day refund if it isn't useful.

Want more #security & #linux deep dives?

Join 6,134+ developers sharing real benchmarks, code breakdowns, and projects. Free forever.

More Posts

The cleanup failed on the night there was nothing to clean

BashSnippets - Dec 2

My hung process had no file open. It was stuck inside open().

BashSnippets - Dec 1

Your AI Agent Doesn't Need Your Token: Edera's Ariadne Conill on Object Capabilities

Tom Smithverified - Nov 5

AAIF Hits 10 Projects. Its CTO on What to Adopt Now and the Security Gaps Left Open

Tom Smithverified - Oct 23

A deploy guard that passes with no token

BashSnippets - Nov 24
chevron_left
4k Points • 144 Badges
North America • bashsnippets.xyz
79Posts
43Comments
14Connections
Linux user who got tired of Googling the same bash commands every time I sat down at a terminal. Sta... Show more

Commenters (This Week)

1 comment
1 comment
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!