Skip to main content

4755

SUID + 755

4755 combines **SUID (4) with standard 755 permissions:

  • Owner: read, write, execute (rwx)
  • Group: read, execute (r-x)
  • Others: read, execute (r-x)
  • **Executes with owners privilege (SUID)

In practice: a file becomes executable by anyone, but **runs as the file owner usually root. Strong capability, high risk if misapplied.

Objective​

Understand 4755, see how it behaves, and enforce safe use on a WordPress VPS.

Concept Breakdown​

Octal structure​

DigitMeaning
4SUID enabled
7Owner rwx
5Group r-x
5Others r-x

Behavior​

  • Any user who runs the file gains the **file owner's execution privileges
  • Usually used by root-owned binaries like passwd

Syntax Formula​

Apply 4755​

chmod 4755 <file>

Remove SUID (restore normal 755)​

chmod u-s <file>

Check​

ls -l <file>

Permission Indicator​

Expected in ls -l:

-rwsr-xr-x

Key marker: **s in the owner execute position.

Real Working Example & Output​

Demo script (proof of behavior)​

echo -e '#!/bin/bashnid' > /usr/local/bin/test-suid.sh
chmod 755 /usr/local/bin/test-suid.sh
chown root:root /usr/local/bin/test-suid.sh

./usr/local/bin/test-suid.sh

Expected output before SUID:

uid=1001(...) gid=1001(...)

Now enable 4755:

chmod 4755 /usr/local/bin/test-suid.sh

Run again:

uid=0(root) gid=1001(...)

Result: script runs with root privileges

WordPress-Relevant Usage​

ScenarioValid?Notes
System binaries (passwd, sudo)✅ OS defaults only
WP CLI scripts❌ Never
Backup / deploy scripts❌ Use sudoers instead
Theme/plugin files❌ Critical risk
User upload paths❌ Severe escalation vulnerability

**WP rule: WordPress files must **never run as root via SUID.

Production Scenarios Guidance​

CaseBest Practice
Admin automationUse sudo policy, not SUID
Shared command for dev & opsUse ACLs
Need temporary elevated scriptsudoers NOPASSWD
Security auditingMonitor for SUID anomalies

Security Considerations​

Risks​

ThreatWhy
Privilege escalationUser gets root rights
Web exploit chainingAttacker uses SUID to break out
Backdoor persistenceRoot shells via SUID script

Audit​

find / -perm -4000 2>/dev/null

Removal​

chmod u-s <file>

Best Practices​

GuidelineReason
Never grant 4755 in /home or /var/wwwWeb risk
Keep SUID only for trusted system binariesDesigned securely
Prefer sudoers rulesLogged, controlled
Run WP CLI as site userPrinciple of least privilege

WordPress Audit Commands​

Check only WP directories:

find /home -perm -4000

Found anything? Remove:

chmod u-s <file>

Go-Live Checklist​

Item✅
No custom 4755 binaries✅
No SUID in wp-content or public web✅
Sudoers configured for automation✅
Cron monitors SUID changes✅

Troubleshooting Matrix​

IssueCauseFix
Script runs as root unexpectedlySUID appliedchmod u-s file
WP files flagged in malware scanSUID tamperingRemove + rescan system
Cannot elevate scriptWrong path or ownershipUse sudo instead

Quick Lab​

Create privileged script safely (sudo instead of SUID):

Edit sudoers:

visudo

Add:

wpadmin ALL=(root) NOPASSWD:/usr/local/bin/wp-maint.sh

Verify:

sudo /usr/local/bin/wp-maint.sh

Cheat Sheet​

CommandPurpose
chmod 4755 fileSet SUID + 755
chmod u-s fileRemove SUID
find / -perm -4000Scan SUID
ls -lCheck for s bit

Mini Quiz​

QuestionAnswer
What does 4 in 4755 do?Enables SUID
What bit appears in ls -l?s on owner exec
Use for WordPress scripts?No
Safer alternative?sudoers