You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/linux-hardening/privilege-escalation/README.md
-49Lines changed: 0 additions & 49 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -452,55 +452,6 @@ It's possible to create a cronjob **putting a carriage return after a comment**
452
452
#This is a comment inside a cron config file\r* * * * * echo "Surprise!"
453
453
```
454
454
455
-
### pgrep/ps argv spoofing in privileged cron scripts
456
-
457
-
If a root cron/systemd timer script constructs commands from untrusted process listings, you can often escalate privileges by forging a process argv that the script consumes.
458
-
459
-
Vulnerable pattern (real-world example simplified):
460
-
461
-
```bash
462
-
#!/usr/bin/bash
463
-
RET=0
464
-
whileread pid _cmd ;do
465
-
# Replace apache2 with apache2ctl and add -t for test
- Use -f /path/to/attacker.conf to point apache2ctl to a config you fully control; you can also override -d to influence ServerRoot resolution.
494
-
- Craft attacker.conf to leverage Apache behaviors that execute privileged helpers during config parsing/startup (e.g., piped logs or other directives that may spawn programs during validation/startup in your target’s build). This can yield root-level command execution or privileged file writes even if the script runs with -t.
495
-
496
-
Detection and mitigation
497
-
- Never execute strings built from process listings. Use fixed argv arrays and strict allowlists for both program and arguments.
498
-
- If you must inspect processes, parse safely and avoid substituting and executing arbitrary strings; do not pass untrusted data through the shell.
499
-
- Drop privileges in health-check jobs and test configs as an unprivileged user.
500
-
501
-
References
502
-
-[HTB Zero write-up showing this abuse and path to root](https://0xdf.gitlab.io/2025/08/12/htb-zero.html)
0 commit comments